Comments (6)
I apologize for the inconvenience. The solution is to create a DLL with a C# static method wrapping GetEditableParameters to return the editable parameters type explicitly. Then import the DLL with pyesapi.clr (which is interface to pythonnet). I have an example somewhere, I'll try to find it and paste it here.
from pyesapi.
If you could find an example that would be brilliant. thanks.
from pyesapi.
DLL code
namespace ProtonHelperNS
{
public static class ProtonHelper
{
public static IonBeamParameters GetEditableIonBeamParameters(IonBeam iBeam)
{
return (iBeam.GetEditableParameters() as IonBeamParameters); // soo casted
}
}
}
from pyesapi.
PyESAPI code
# ...
# path to compiled proton helper DLL:
sys.path.append(r'C:\\Users\\Varian\\Documents\\Eclipse Scripting API\\Projects\\ProtonHelper\\bin\\debug')
pyesapi.clr.AddReference('ProtonHelper')
from ProtonHelperNS import ProtonHelper
#...
editable_params = ProtonHelper.GetEditableIonBeamParameters(beam)
from pyesapi.
Note, I ran into an issue with .NET Framework 4.6.1 (target for next release of Eclipse). The namespace should be different than the DLL name, otherwise, import will fail (name collision perhaps). See here: https://github.com/pythonnet/pythonnet/wiki/How-to-call-a-dynamic-library
I've edited examples above.
from pyesapi.
The elegant solution was found using reflection (in C# reflection can do literally anything). The issue was the function was overloaded due to IonBeam basing off of Beam class and pythonnet called the base method (there is a bigger issue here related to how methods are differentiated by their input parameter types only in pythonnet, so when there are no input parameters, there is ambiguity... I personally think the output type should also be used to differentiate the method). Technically, the "override" modifier should have been set on the GetEditableIonBeamParameters method in IonBeam class (ESAPI source). Anyway, here is the fix, I'll roll this into PyESAPI proper sooner or later:
import pyesapi
import atexit
def get_editable_IonBeamParameters(beam):
for mi in beam.GetType().GetMethods():
if mi.ReturnType.ToString() == 'VMS.TPS.Common.Model.API.IonBeamParameters':
return mi.Invoke(beam,[])
pyesapi.IonBeam.GetEditableIonBeamParameters = get_editable_IonBeamParameters # monkey patch like a boss
if not 'app' in locals():
app = pyesapi.CustomScriptExecutable.CreateApplication('python_demo')
atexit.register(app.Dispose);
from pyesapi.
Related Issues (17)
- Mean dose HOT 3
- GettingStarted notebook: AttributeError HOT 2
- AddVMATBeam throwing error HOT 2
- CopyPlanSetup fails when attempting to copy a plan that is approved
- Python3 compatibility HOT 2
- PyESAPI: Getting Started HOT 3
- SetTargetStructureIfNoDose HOT 2
- CalculateDVHEstimates in pyESAPI throws "Cannot locate TPS Core" Error
- Plan Uncertainty Doses calculation
- EvaluationDose and GetDoseAtVoxel, GetVoxelAtDose, GetDVHCumulativeData
- Eclipse v16? HOT 1
- Problem with 'import pyesapi' HOT 1
- Error in intersects_location
- PyESAPI on Citrix HOT 9
- Problem installing PyESAPI HOT 3
- File Not Found Exception HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyesapi.