VarianAPIs / PyESAPI

Python interface to Eclipse Scripting API
MIT License
69 stars 32 forks source link

SetTargetStructureIfNoDose #18

Closed mfizyczka closed 2 years ago

mfizyczka commented 2 years ago

Hi,

I'd like to set target structure with pyesapi.

For c# this works:

Structure targetStructure = originalPlan.StructureSet.Structures.Where(s => s.Id.Equals(originalPlan.TargetVolumeID)).Single();
StringBuilder ErrorHint = new StringBuilder("Error while setting Target Structure");
newPlan.SetTargetStructureIfNoDose(targetStructure, ErrorHint);

But I cannot make it work with pyesapi.

targetStructure = originalPlan.StructureSet.StructuresLot(originalPlan.TargetVolumeID)
ErrorHint = "Error while setting Target Structure"
newPlan.SetTargetStructureIfNoDose(targetStructure)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: No method matches given arguments for SetTargetStructureIfNoDose: (<class 'VMS.TPS.Common.Model.API.Structure'>)

Simmilar effect for:

newPlan.SetTargetStructureIfNoDose(targetStructure, ErrorHint)

TypeError: No method matches given arguments for SetTargetStructureIfNoDose: (<class 'VMS.TPS.Common.Model.API.Structure'>, <class 'str'>)

How can I set target structure with pyesapi?

mvarsta commented 2 years ago

I’ll look into it but rather looks like string builder issue. I think you should be able to instantiate string builder as well. Look at python.net (that’s what pyESAPI uses) for clues.

Sent from my iPhone

On 2. Nov 2021, at 3.37, mfizyczka @.***> wrote:



Hi,

I'd like to set target structure with pyesapi.

For c# this works:

Structure targetStructure = originalPlan.StructureSet.Structures.Where(s => s.Id.Equals(originalPlan.TargetVolumeID)).Single(); StringBuilder ErrorHint = new StringBuilder("Error while setting Target Structure"); newPlan.SetTargetStructureIfNoDose(targetStructure, ErrorHint);

But I cannot make it work with pyesapi.

targetStructure = originalPlan.StructureSet.StructuresLot(originalPlan.TargetVolumeID) ErrorHint = "Error while setting Target Structure" newPlan.SetTargetStructureIfNoDose(targetStructure)

Traceback (most recent call last): File "", line 1, in TypeError: No method matches given arguments for SetTargetStructureIfNoDose: (<class 'VMS.TPS.Common.Model.API.Structure'>)

Simmilar effect for:

newPlan.SetTargetStructureIfNoDose(targetStructure, ErrorHint)

TypeError: No method matches given arguments for SetTargetStructureIfNoDose: (<class 'VMS.TPS.Common.Model.API.Structure'>, <class 'str'>)

How can I set target structure with pyesapi?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FVarianAPIs%2FPyESAPI%2Fissues%2F18&data=04%7C01%7Cmarkus.varsta%40varian.com%7C36642b2ef5c64dadabd508d99ddbf05e%7Cc49d9c494b114ccdb13772f88c68a252%7C1%7C0%7C637714390228471429%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=paJWXlrh2hAz3aN2CPba4W5sBJbbCgQe5%2FrZDWgh53c%3D&reserved=0, or unsubscribehttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABNWD6CV6L7Z7I6HYYMVM6LUJ6PKZANCNFSM5HF3S4ZA&data=04%7C01%7Cmarkus.varsta%40varian.com%7C36642b2ef5c64dadabd508d99ddbf05e%7Cc49d9c494b114ccdb13772f88c68a252%7C1%7C0%7C637714390228481384%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=ixPaHgtvG0Xquh9raFYYyhZ1IHKn4YDxpLNQukfLTQQ%3D&reserved=0. Triage notifications on the go with GitHub Mobile for iOShttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapps.apple.com%2Fapp%2Fapple-store%2Fid1477376905%3Fct%3Dnotification-email%26mt%3D8%26pt%3D524675&data=04%7C01%7Cmarkus.varsta%40varian.com%7C36642b2ef5c64dadabd508d99ddbf05e%7Cc49d9c494b114ccdb13772f88c68a252%7C1%7C0%7C637714390228481384%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=odVJ8%2FwTBYGiabk2JtaFuCzcJOabtx5Qi7g7%2FzXDvo8%3D&reserved=0 or Androidhttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26referrer%3Dutm_campaign%253Dnotification-email%2526utm_medium%253Demail%2526utm_source%253Dgithub&data=04%7C01%7Cmarkus.varsta%40varian.com%7C36642b2ef5c64dadabd508d99ddbf05e%7Cc49d9c494b114ccdb13772f88c68a252%7C1%7C0%7C637714390228491339%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=N2%2Ft2kVVaux9xahrQQnUqdffIL3yXlGbyKO4dxi5EYQ%3D&reserved=0.

mfizyczka commented 2 years ago

You're right. With this changes it works:

import clr # load Python.NET
# the CLR namespaces are now recognized as Python packages
import System
import System.Text

targetStructure = originalPlan.StructureSet.StructuresLot(originalPlan.TargetVolumeID)
ErrorHint = System.Text.StringBuilder("ThisStringIsOptional")  
newPlan.SetTargetStructureIfNoDose(targetStructure, ErrorHint)

Thanks for help and good hint :-)