需要看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