[Ironpython-users] COM Interop argument convert error
mr.kamu at gmail.com
Wed Jan 25 05:06:29 CET 2012
Having a problem passing 'None' to a COM Interop method that can
accept 'Nothing' (in VBA)
My code (with considerable snippage):
t = System.Type.GetTypeFromProgID("MicroStationDGN.Application")
self.ms = System.Activator.CreateInstance(t)
elem = self.ms.CreateLineElement2(None, point3d1, point3d2)
Now, I know that the point3d objects are working fine, and self.ms is
working fine as it is part of a library I am putting together and they
are working fine with other methods. How ever, I run it and get this
Traceback (most recent call last):
File "titleblocknew.py", line 26, in <module>
File "E:\py\ustation.py", line 162, in create_line
ValueError: Could not convert argument 2 for call to CreateLineElement2.
ILSpy says this about the method:
LineElement CreateLineElement2([MarshalAs(28)] [In] Element Template,
[In] [Out] ref Point3d StartPoint, [In] [Out] ref Point3d EndPoint);
MicroStation documentation says this:
Set LineElement = object.CreateLineElement2 (Template, StartPoint, EndPoint)
The CreateLineElement2 method syntax has these parts:
object A valid object. (Application object)
Template An Element expression. An existing element whose settings are
used to initialize the new element. If Nothing, the new element's
settings are initialized from MicroStation's active settings.
StartPoint A Point3d expression.
EndPoint A Point3d expression.
My basic understanding is that it is trying to convert None into an
'Element' object, but is unable to do so. Is there a way around this?
More information about the Ironpython-users