Solidworks二次开发—09--添加配合参考

类别:.NET开发 点击:0 评论:0 推荐:
下面的代码选择了零件的两个面,然后为此零件添加一个配合参考,先选择的面为配合参考的第一参考面。并且是同向、重合配合。第二个为反向、重合配合。

需要看Part.FeatureManager.InsertMateReference函数。第一个参数是配合参考的名称,后面三个为一组定义一个参考。第一个为选择的实体entity,然后是配合类型(整数索引),正反向(整数索引)。

Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.ModelDoc2
Dim selmgr As SldWorks.SelectionMgr
Dim Feature As SldWorks.Feature
Dim facefst As SldWorks.face2
Dim facesed As SldWorks.face2
Dim facefstent As SldWorks.Entity
Dim facesedent As SldWorks.Entity
Dim tempfeat As Object


Sub addcleatmateref()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set selmgr = Part.SelectionManager

Set tempfeat = selmgr.GetSelectedObject5(1)
If tempfeat.GetType = 2 Then
Set facefst = tempfeat
Set facefstent = facefst
Else
MsgBox "请选择平面"
End If
Set tempfeat = selmgr.GetSelectedObject5(2)
If tempfeat.GetType = 2 Then
Set facesed = tempfeat
Set facesedent = facesed
Else
MsgBox "请选择平面"
End If
Set Feature = Part.FeatureManager.InsertMateReference("配合参考1", facefstent, 2, 1, facesedent, 2, 2, Nothing, 0, 0)
End Sub

本文地址:http://com.8s8s.com/it/it41190.htm