SOLIDWORKS Secondary Development -09 - Add Teamwork Reference

xiaoxiao2021-03-05  25

The following code selects two faces of the part, and then add a fit reference to this part, first selecting the first reference surface of the reference reference. And it is coheed, coincident. The second is reversed and coincidentally cooperated.

Need to see the part.featureManager.insertmateReference function. The first parameter is the name of the reference, followed by three for a set of references. The first is the selected entity Entity, and then the mating type (integer index), the forward (integer index).

Dim swApp As SldWorks.SldWorksDim Part As SldWorks.ModelDoc2Dim selmgr As SldWorks.SelectionMgrDim Feature As SldWorks.FeatureDim facefst As SldWorks.face2Dim facesed As SldWorks.face2Dim facefstent As SldWorks.EntityDim facesedent As SldWorks.EntityDim tempfeat As Object

Sub addcleatMateRef () set swapp = Application.sldWorksset Part = swapp.activedocset selmgr = part.selectionManager

Set tempfeat = selmgr.GetSelectedObject5 (1) If tempfeat.GetType = 2 ThenSet facefst = tempfeatSet facefstent = facefstElseMsgBox "Select plane" End IfSet tempfeat = selmgr.GetSelectedObject5 (2) If tempfeat.GetType 2 ThenSet facesed = tempfeatSet facesedent = = facesedElseMsgBox "Please select the plane" end ifset feature = part.featureManager.insertmatereference ("Comply 1", Facefstent, 2, 1, FaceSed, 2, 2, Nothing, 0, 0) End Sub

转载请注明原文地址:https://www.9cbs.com/read-35303.html

New Post(0)