Ok now it is working. That link cleared up some things. I guess the objects exposed by pythonnet aren’t known until interpret-time, so an IDE doesn’t have much of a chance to infer anything, at least not without some help. I was hoping for some further magic. Trying Pycharm here and it doesn’t know what is going on. However I am able to subclass Rhino.Geometry.Point3d and help it out, but it feels silly; there are probably more appropriate methods (not too sure about the super attributes):
import rhinoinside
import System
import Rhino
class RiPyPoint(Rhino.Geometry.Point3d):
def __init__(self, x=0.0, y=0.0, z=0.0, from_point3d=None):
if from_point3d:
super().__init__(from_point3d.X, from_point3d.Y, from_point3d.Z)
else:
super().__init__(x, y, z)
self.X = super().X
self.Y = super().Y
self.Z = super().Z
def __add__(self, other):
return RiPyPoint(from_point3d=self.Add(self, other))
def __str__(self):
return 'Subclassed Rhino.Geometry.Point3d({}, {}, {})'.format(self.X, self.Y, self.Z)
p = RiPyPoint(3.0, 2.0, 1.0)
p1 = RiPyPoint(1.0, 2.0, 3.0)
print(p, p1)
p.X = 30
p.Y = 20
p.Z = 10
print(p, p1)
new_point = p + p1
print('{} + {}, {} + {}, {} + {} = {}, {}, {}'.format(p.X,
p1.X,
p.Y,
p1.Y,
p.Z,
p1.Z,
new_point.X,
new_point.Y,
new_point.Z))
output:
Subclassed Rhino.Geometry.Point3d(3.0, 2.0, 1.0) Subclassed Rhino.Geometry.Point3d(1.0, 2.0, 3.0)
Subclassed Rhino.Geometry.Point3d(30.0, 20.0, 10.0) Subclassed Rhino.Geometry.Point3d(1.0, 2.0, 3.0)
30.0 + 1.0, 20.0 + 2.0, 10.0 + 3.0 = 31.0, 22.0, 13.0
I guess one could wrap needed rhinocommon objects, if one wanted intellisense.
Although certainly not intended to, I guess this won’t help in the quest for an in-doc, fully supported python IDE, or at least I don’t see any new opportunities yet. Probably more inline with the intent, as a bridge into the CPython ecosystem, this seems promising.