10-26-2020
11:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
10-26-2020
11:57 AM
Since you can access the API by several different means, I thought I would show the regular iLogic way to do it.
Here is a simple iLogic rule you can use to toggle the visibility of all 3D sketches in all parts within the active assembly.
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
MsgBox("This rule '" & iLogicVb.RuleName & "' only works for Assembly Documents.",vbOKOnly, "WRONG DOCUMENT TYPE")
Return
End If
Dim oADoc As AssemblyDocument = ThisAssembly.Document
Dim oOnOff As Boolean
For Each oRefDoc As Document In oADoc.AllReferencedDocuments
If oRefDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
Dim oPDoc As PartDocument = oRefDoc
If oPDoc.ComponentDefinition.Sketches3D.Count > 0 Then
For Each oSketch3D As Sketch3D In oPDoc.ComponentDefinition.Sketches3D
oOnOff = oSketch3D.Visible
oSketch3D.Visible = (Not oOnOff)
Next
End If
End If
NextIf you want to change this rule from a toggle functionality to a direct (turn them all off) functionality, all you need to do is
- assign the value of False to the Boolean variable near the beginning of the code (it should already be false though, by default)
- Replace these two lines [oOnOff = oSketch3D.Visible] & [oSketch3D.Visible = (Not oOnOff)] with the following:
- oSketches3D.Visible = oOnOff
Like this:
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
MsgBox("This rule only works for Assembly Documents.",vbOKOnly, "WRONG DOCUMENT TYPE")
Return ' or Exit Sub
End If
Dim oADoc As AssemblyDocument = ThisAssembly.Document
Dim oOnOff As Boolean = False
For Each oRefDoc As Document In oADoc.AllReferencedDocuments
If oRefDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
Dim oPDoc As PartDocument = oRefDoc
If oPDoc.ComponentDefinition.Sketches3D.Count > 0 Then
For Each oSketch3D As Sketch3D In oPDoc.ComponentDefinition.Sketches3D
oSketch3D.Visible = oOnOff
Next
End If
End If
NextIf this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE'
.
If you have time, please... Vote For My IDEAS
and Explore My CONTRIBUTIONS
Inventor 2020 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum
Wesley Crihfield
(Not an Autodesk Employee)