SolidWorks API:测量点坐标
有一个SolidWorks组件,其中包含一个“ P”和一个坐标系框架“ F”。目的是找到 X,Y,Z
codleds“ p” wrt框架“ f”的坐标。 VB代码看起来像
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim bstatus As Boolean
Dim swMeasure As SldWorks.Measure
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
swModel.ClearSelection2 True
bstatus = swModel.Extension.SelectByID2("P", "DATUMPOINT", 0, 0, 0, False, 0, Nothing, 0)
Debug.Assert bstatus
Set swMeasure = swModel.Extension.CreateMeasure
bstatus = swMeasure.Calculate(Nothing)
Debug.Assert bstatus
Debug.Print ("X: " & swMeasure.X)
Debug.Print ("Y: " & swMeasure.Y)
Debug.Print ("Z: " & swMeasure.Z)
End Sub
脚本有效,但是在最近使用的坐标系统框架中提供了坐标。它可以是帧“ F”或默认帧,因此结果是不可预测的。我找不到 MEATUR
类的属性来强制使用必要的帧。有没有办法明确指定框架?有解决方法吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以获取像此示例这样的点坐标,GetCoordinateSystemTransformByName or getDefinition ot坐标系统功能,如果点p在组件中,则需要使用组件矩阵变换
另请参见此相关 post
You can get the point coordinates like this example method, then you might need to multiply that with the matrix of the coordinate system with GetCoordinateSystemTransformByName or GetDefinition ot the Coordinate System Feature, and if the point P is in a component, you will need to multiply previous matrix with the component matrix transform Transform2.
See also this related post