I'm trying to loop through existing concentric mates and rotation locking only certain ones. For some reason EditMate3 doesn't want to enable the Lock rotation. I can get the same macro to uncheck the Lock Rotation by setting LockRotation to false, but when I set it to true it does nothing. Any help is appreciated.
I'm using the Edit Mate Example as a base.
I find it ironic that the SolidWorks Jive forum doesn't support VBA .
<p>Option Explicit</p><p></p><p>Sub main()</p><p> Dim swApp As SldWorks.SldWorks</p><p> Dim swModel As SldWorks.ModelDoc2</p><p> Dim swFeat As SldWorks.Feature</p><p> Dim swBomFeat As SldWorks.BomFeature</p><p> Dim swSubFeat As SldWorks.Feature</p><p> Dim swBOMAnnotation As SldWorks.BomTableAnnotation</p><p> Dim swBOMFeature As SldWorks.BomFeature</p><p> Dim swTableAnn As SldWorks.TableAnnotation</p><p> Dim blnRtn As Boolean</p><p> Dim swMateEnt() As SldWorks.MateEntity2</p><p> Dim i As Integer</p><p> Dim swMate As SldWorks.Mate2</p><p> Dim nRetVal As Long</p><p> </p><p> Set swApp = Application.SldWorks</p><p> Set swModel = swApp.ActiveDoc</p><p> Set swFeat = swModel.FirstFeature</p><p> </p><p> Do While Not swFeat Is Nothing</p><p></p><p></p><p> If swFeat.GetTypeName2 = "MateGroup" Then</p><p> Set swSubFeat = swFeat.GetFirstSubFeature ' Get the features of the drawing</p><p> Do While Not swSubFeat Is Nothing</p><p> ' If swSubFeat.GetTypeName2 = "MateConcentric" Then</p><p> If swSubFeat.Name = "Concentric165" Then</p><p> Debug.Print " Feature Name : " & swSubFeat.Name</p><p> Debug.Print " Feature Type Name : " & swSubFeat.GetTypeName</p><p> Set swMate = swSubFeat.GetSpecificFeature2</p><p> For i = 0 To swMate.GetMateEntityCount - 1</p><p> blnRtn = SelectMateEntity(swApp, swModel, swMate.MateEntity(i), 1)</p><p> Next i</p><p> blnRtn = swSubFeat.Select2(True, 0)</p><p> swModel.EditMate3 _</p><p> swMate.Type, _</p><p> swMate.Alignment, _</p><p> swMate.Flipped, _</p><p> 0#, _</p><p> swMate.MaximumVariation, _</p><p> swMate.MinimumVariation, _</p><p> 0#, _</p><p> 0#, _</p><p> 0#, _</p><p> swMate.MaximumVariation, _</p><p> swMate.MinimumVariation, _</p><p> False, _</p><p> <strong>True, _</strong></p><p> 0, _</p><p> nRetVal</p><p> Debug.Print "nRetVal: " & nRetVal</p><p> blnRtn = swModel.EditRebuild3</p><p> Exit Sub</p><p> End If</p><p> Set swSubFeat = swSubFeat.GetNextSubFeature</p><p> Loop</p><p> End If</p><p> Set swFeat = swFeat.GetNextFeature</p><p> Loop</p><p>End Sub</p><p></p><p></p><p>Function SelectMateEntity(swApp As SldWorks.SldWorks, swModel As SldWorks.ModelDoc2, swMateEnt As SldWorks.MateEntity2, nMark As Long) As Boolean</p><p></p><p></p><p> Dim swEnt As SldWorks.Entity</p><p> Dim swSelMgr As SldWorks.SelectionMgr</p><p> Dim swSelData As SldWorks.SelectData</p><p> Dim bRet As Boolean</p><p></p><p></p><p> Select Case swMateEnt.ReferenceType</p><p></p><p></p><p> Case swMateEntity2ReferenceType_Point, _</p><p> swMateEntity2ReferenceType_Line, _</p><p> swMateEntity2ReferenceType_Circle, _</p><p> swMateEntity2ReferenceType_Plane, _</p><p> swMateEntity2ReferenceType_Cylinder, _</p><p> swMateEntity2ReferenceType_Sphere, _</p><p> swMateEntity2ReferenceType_Cone, _</p><p> swMateEntity2ReferenceType_SweptSurface</p><p></p><p></p><p> Set swSelMgr = swModel.SelectionManager</p><p> Set swSelData = swSelMgr.CreateSelectData</p><p> Set swEnt = swMateEnt.Reference</p><p></p><p></p><p> swSelData.Mark = nMark</p><p></p><p></p><p> bRet = swEnt.Select4(True, swSelData)</p><p></p><p></p><p> SelectMateEntity = bRet</p><p></p><p></p><p> Exit Function</p><p></p><p> Case swMateEntity2ReferenceType_Set, _</p><p> swMateEntity2ReferenceType_MultipleSurface, _</p><p> swMateEntity2ReferenceType_GenSurface, _</p><p> swMateEntity2ReferenceType_Ellipse, _</p><p> swMateEntity2ReferenceType_GeneralCurve, _</p><p> swMateEntity2ReferenceType_UNKNOWN</p><p></p><p> Case Else</p><p></p><p> End Select</p><p></p><p> SelectMateEntity = False</p><p></p><p>End Function</p>SolidworksApi macros
