Hi,
How to make invisible all the feature sketches that are make visible in the assembly?
Solved! Go to Solution.
Solved by Andrii_Humeniuk. Go to Solution.
Hi @Hubert_Los . Try this iLogic code. It makes all sketches in all components of the main assembly invisible.
Private Sub Main()
Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oTrans As Transaction = ThisApplication.TransactionManager.StartTransaction(oDoc, "SetVisibleSketch")
For Each oRefDoc As Document In oDoc.AllReferencedDocuments
If TypeOf oRefDoc Is PartDocument And oRefDoc.IsModifiable Then
Dim oPDoc As PartDocument = oRefDoc
Call SetVisibleSketch(oPDoc.ComponentDefinition.Sketches)
End If
Next
oTrans.End()
End Sub
Private Function SetVisibleSketch(oSkets As PlanarSketches, Optional bVisible As Boolean = False)
For i As Integer = 1 To oSkets.Count
If oSkets.Item(i).Visible Then oSkets.Item(i).Visible = bVisible
Next
End Function
Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor
LinkedIn | My free Inventor Addin | My Repositories
Did you find this reply helpful ? If so please use the Accept as Solution/Like.
Hi @Andrii_Humeniuk ,
Unfortunately your code only works on "shered skeches" I have a different situation. I enable sketch editing from the assembly level and this sketch is not share.
Not sure I understood you correctly, but made the changes to the code. Now the visibility of sketches is turned off in the main assembly and in subassemblies and in details. The code also includes a check for the ability to modify documents.
Private Sub Main()
Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oTrans As Transaction = ThisApplication.TransactionManager.StartTransaction(oDoc, "SetVisibleSketch")
If oDoc.IsModifiable Then Call SetVisibleSketch(oDoc.ComponentDefinition.Sketches)
For Each oRefDoc As Document In oDoc.AllReferencedDocuments
If oRefDoc.IsModifiable Then
Call SetVisibleSketch(oRefDoc.ComponentDefinition.Sketches)
End If
Next
oTrans.End()
End Sub
Private Function SetVisibleSketch(oSkets As PlanarSketches, Optional bVisible As Boolean = False)
For i As Integer = 1 To oSkets.Count
On Error Resume Next
If oSkets.Item(i).Visible Then oSkets.Item(i).Visible = bVisible
Next i
End Function
Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor
LinkedIn | My free Inventor Addin | My Repositories
Did you find this reply helpful ? If so please use the Accept as Solution/Like.
Hi @Hubert_Los . I finally understood you. Thanks for the video explaining what you need it really helped. Here is the code that determines the visibility of all proxy skeaths and makes them invisible:
Private Sub Main()
Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oTrans As Transaction = ThisApplication.TransactionManager.StartTransaction(oDoc, "SetVisibleSketch")
Call SetVisibleSketch(oDoc.ComponentDefinition.Occurrences)
oTrans.End()
End Sub
Private Function SetVisibleSketch(oOccs As ComponentOccurrences, Optional bVisible As Boolean = False)
For Each oOcc As ComponentOccurrence In oOccs
If oOcc.DefinitionDocumentType = DocumentTypeEnum.kPartDocumentObject Then
On Error Resume Next
Dim oOccDef As PartComponentDefinition = oOcc.Definition
For Each oSketch As PlanarSketch In oOccDef.Sketches
Dim oSketchProxy As PlanarSketchProxy : oOcc.CreateGeometryProxy(oSketch, oSketchProxy)
If oSketchProxy.Visible Then oSketchProxy.Visible = False
Next
Else If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
If oOcc.SubOccurrences.Count > 0 Then
Call SetVisibleSketch(oOcc.SubOccurrences)
End If
End If
Next
End Function
Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor
LinkedIn | My free Inventor Addin | My Repositories
Did you find this reply helpful ? If so please use the Accept as Solution/Like.
Can't find what you're looking for? Ask the community or share your knowledge.