我正在将一个Python脚本转换为C#,并且在这个过程中遇到了一些偶然的问题。这一次是将一个点从一个位置重新定位到另一个位置。在python脚本中,我不知道如何转换的方法的第二行。我已经看过了Rhino的文档,但是我还是很困惑。在
def move(self):
self.trailPts.append(self.pos)
self.pos = rs.PointCoordinates(rs.MoveObject(self.id, self.vec))
这就是我目前所处的位置:
^{pr2}$但这是不对的。我在第2行得到一个转换的重载错误。任何帮助都会很好。谢谢!在
下面是我的C#构造器:
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));
}
以及最初的python构造函数:
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()
是MoveObjects
的包装器,其中返回第一个结果值而不是列表。看看RhinoScript implementation for ^{其中
translation
是Vector3d
对象。在然后看一下^{} 调用的结果是
^{pr2}$^{} function 获取} ),并提供{}是^{} instance );跳过测试和函数来转换其他可接受的类型这归结为:
MoveObject()
返回的GUID并再次找到该对象,然后为您提供该对象的几何体位置(通过^{将这些转换为RhinoCommon对象将是:
其中
vec
是Rhino.Geometry.Vector3d
实例,id
是对象引用。在另请参见^{} documentation ,其中包括一个C#示例和^{} methods 。在
注意,} ?但是,
Rhino.Geometry.Transform.Translation()
静态方法已经返回了一个Transform
实例,这里不需要使用new Transform()
。而且没有PointID
类型;也许您正在寻找^{Point3D.Transform()
方法将在该点上操作,而不是对具有给定id
的对象进行操作。在相关问题 更多 >
编程相关推荐