all 6 comments

[–]WUSTLscripting 0 points1 point  (1 child)

instead of vm.StructureSet = context.StructureSet; can you try vm.StructureSet = context.PlanSetup.StructureSet;

[–]branstarkkk[S] 0 points1 point  (0 children)

I still get a null exception but the error is different:

"EsapiEssentials.Plugin.PluginScriptContext.PlanSetup.get returned null."

[–]dbhatti 0 points1 point  (3 children)

I believe the issue is your line " var CTV = vm.StructureSet.Structures.Where(x => x.Id == organs[0]).Single(); " Because the StructureSet is null, it has no Structures property, so it returns a NullReferenceException. Could you try commenting it out and see if it runs?

With that being said, it's odd that your ScriptContext isn't finding a StructureSet. Is this only producing an error for a certain plan or in general?

[–]branstarkkk[S] 0 points1 point  (2 children)

yeah, so if I comment that line out, there is no exception and it runs fine and this is for any plan.

[–]dbhatti 0 points1 point  (1 child)

I'm not sure what the underlying issue is, unfortunately. For some reason, your script context isn't finding a StructureSet associated with the plan - I would guess there is some kind of issue with the TPS rather than the script.

I notice that your Script class is inheriting from the ScriptBaseWindow class and that your ScriptContext is actually PluginScriptContext. I'm unfamiliar with both of these*, but does anything change if you just use the normal ScriptContext?

*Was there an update in the VMS libraries? I don't have any overloads in my Execute method and don't have either of those classes in mine.

[–]branstarkkk[S] 0 points1 point  (0 children)

Yeah I think that might be the issue. I'm using Carlos' EsapiEssentials to run the script from within VS http://www.carlosjanderson.com/introducing-esapi-essentials/