The following code selects the two sides of the part, and then adds a reference for the part. The selected area is the first reference area for the reference. In addition, they are in the same direction and overlap. The second is reverse and overlap.
You need to check the part. featuremanager. insertmatereference function. The first parameter is the reference name, and the last three parameters are a set of definitions. The first is the selected entity, followed by the combination type (integer index), positive and reverse (integer index ).
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 "select plane"
End if
Set tempfeat = selmgr. getselectedobject5 (2)
If tempfeat. GetType = 2 then
Set facesed = tempfeat
Set facesedent = facesed
Else
Msgbox "select plane"
End if
Set feature =Part. featuremanager. insertmatereference ("with reference 1", facefstent, 2, 1, facesedent, 2, 2, nothing, 0, 0)
End sub