我正在尝试使用API在Solidworks中创建螺栓生成器。其中一个包含的功能允许用户使用Solidworks wrap功能在螺栓头上浮雕文本。如果为宏记录了这一点,则应用包裹的面是SelectbyRay。这样做的问题是我有很多螺栓大小,所以数组每次都会改变,所以我需要通过ID选择面。
Part.SketchManager.InsertSketch True
boolstatus = Part.Extension.SelectByID2("Sketch6", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Boss-Extrude1", "FACE", D2 / 2, L1, 0#, False, 4, Nothing, 0)
'boolstatus = Part.Extension.SelectByRay(1.74532925199433E-02, 1.74532925199433E-02, False, False, False, False, True, True, True, 0, 0, False)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Sketch6", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Boss-Extrude1", "FACE", D2 / 2, L1 + H1, 0#, False, 4, Nothing, 0)
'boolstatus = Part.Extension.SelectByRay(1.74532925199433E-02, 1.74532925199433E-02, False, False, False, False, True, True, True, 0, 0, False)
Dim myFeature As Object
Set myFeature = Part.FeatureManager.InsertWrapFeature2(0, 0.0001, False, 0, 1)
Part.ClearSelection2 True
被注释掉的行是记录的数组宏,上面是我试图根据Solidworks中的parts工具栏识别面孔的尝试。
有人能帮我吗?
发布于 2020-05-21 14:37:44
最好的方法是用GetFaces或GetFirstFace遍历所有的面,然后通过查看它们的参数(等柱面,等平面,面积,直径等)找到你想要的面。
https://stackoverflow.com/questions/61255215
复制相似问题