I'm converting a Python script to C# and I'm running into the occasional issue along the way. This time it's with relocating a point from one location to another. In the python script it's line two of the method that I don't know how to convert. I've reviewed the Rhino documentation but I'm still confused.
def move(self):
self.trailPts.append(self.pos)
self.pos = rs.PointCoordinates(rs.MoveObject(self.id, self.vec))
This is where I'm at so far:
Transform trans = new Transform(Transform.Translation(Vec));
Pos = PointID.Transform(Pos, trans, true);
But it's not correct. I'm getting an overload error for Transform on line 2. Any help would be great. Thanks!
Here is my C# constructor as well :
public Agent(Point3d pos, Vector3d vec, Point3d pointID, List<Point3d> listOfAgents, List<Point3d> navPoints, List<Circle> pipeProfiles)
{
Pos = pos;
Vec = vec;
PointID = pointID;
ListOfAgents = listOfAgents;
NavPoints = navPoints;
PipeProfiles = pipeProfiles;
TrailPoints.Add(new Point3d(Pos));
}
And the original python constructor :
def __init__(self, POS, VEC, POINTID, LISTOFAGENTS, NAVPOINTS, PIPEPROFILES):
self.pos = POS
self.vec = VEC
self.id = POINTID
self.list = LISTOFAGENTS
self.nav = NAVPOINTS
self.trailPts = []
self.trailPts.append(self.pos)
self.trailID = "empty"
self.pipeProfiles = PIPEPROFILES
print("made an agent")
MoveObject()
is a wrapper forMoveObjects
where the first result value is returned rather than a list. Looking at the RhinoScript implementation forMoveObjects
we see:where
translation
is aVector3d
object.Then looking at
TransformObjects
the call comes down toThe
PointCoordinates()
function takes the GUID thatMoveObject()
returned and finds you the object again, then gives you the location for the geometry of that object (viacoercegeometry()
and provided.Geometry
is aPoint
instance); skipping tests and functions to convert possible other acceptable types this comes down to:Translating these to RhinoCommon objects would be:
where
vec
is aRhino.Geometry.Vector3d
instance, andid
an object reference.Also see the
Rhino.Geometry.Transform.Translation()
documentation, which include a C# example, and theObjectTable.Transform
methods.Note that the
Rhino.Geometry.Transform.Translation()
static method already returns aTransform
instance, no need to usenew Transform()
here. And there is noPointID
type; perhaps you were looking forRhino.Geometry.Point3D
? ThePoint3D.Transform()
method would operate on that point, however, not on an object with a givenid
.