Hi my friends , mm I want there are a method to select geometric tolerance in assembly and get the face related to this tolerance using vba macro ? .Thank you very much
geometric tolerances are a part feature.
Run this macro below on a part to select the faces associated with all geometric tolerances.
If you want it for the assembly you will have to loop through the parts.
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim boolstatus As Boolean
Dim AnnArr As Variant
Dim Ann As Variant
Dim swAnn As SldWorks.Annotation
Dim EntArr As Variant
Dim Ent As Variant
Dim swEnt As SldWorks.Entity
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swModelDocExt = swModel.Extension
AnnArr = swModelDocExt.GetAnnotations
If swModelDocExt.GetAnnotationCount > 0 Then
For Each Ann In AnnArr
Set swAnn = Ann
If swAnn.GetType = swAnnotationType_e.swGTol Then
EntArr = swAnn.GetAttachedEntities2
For Each Ent In EntArr
Set swEnt = Ent
If swEnt.GetType = swSelectType_e.swSelFACES Then
boolstatus = swEnt.Select4(True, Nothing)
Thank you very much dear friend its worked fine !
Just I have another question , how can I get the name of the seledted face ? thank you
Faces don't have name.
You can get their Persistent Reference ID with below code, but whatever you're trying to do: I wouldn't go that way.
Dim vId As Variant
vId = swModel.Extension.GetPersistReference3(swEnt)
Debug.Print "Face ID:" & vbCr & ConvertToBase64String(vId)
Function ConvertToBase64String(vArr As Variant) As String
Dim xmlDoc As Object
Dim xmlNode As Object
Set xmlDoc = CreateObject("MSXML2.DOMDocument")
Set xmlNode = xmlDoc.createElement("b64")
xmlNode.DataType = "bin.base64"
xmlNode.nodeTypedValue = vArr
ConvertToBase64String = xmlNode.Text
Thank you for ur answer. I got the way , I found a method to get the name of selected faces alreadu associated or attached to geometrical tolerances.Thank you very much
Retrieving data ...