Macro of turning visibility off of all working planes and axis and sketches

Macro of turning visibility off of all working planes and axis and sketches

gowthamnaidu84
Observer Observer
1,962 Views
4 Replies
Message 1 of 5

Macro of turning visibility off of all working planes and axis and sketches

gowthamnaidu84
Observer
Observer

Hi

I would like to have macro for turning off the visibility of all the working planes and sketches and axis in inventor.

I know you can turn them off in the view command. But this command will not turn off the visibility.

I want a macro to turn off the visibility, so that when I send them or open them in other computers I would have them turned off as default.

there are about 50 planes and sketches which I need to turn the visibility off which is difficult to do manually.

can anybody help me with a macro.

Thank you

0 Likes
Accepted solutions (1)
1,963 Views
4 Replies
Replies (4)
Message 2 of 5

AlexFielder
Advisor
Advisor
Accepted solution

Here you go from my github rule:

 

Sub Main()
    'user feedback tools start
    Dim sw As New Stopwatch()
    sw.Start()
    'get user input as True or False
    Dim Assyboolean As Boolean = InputRadioBox("Turn all Work Features On/Off", "On", "Off", False, "iLogic")

    If ThisApplication.ActiveDocument.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
        ToggleParts(ThisApplication.ActiveDocument, Assyboolean)
    ElseIf ThisApplication.ActiveDocument.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
        'Dim wfBoolean As Boolean = InputRadioBox("Turn all Work Features & Sketches On/Off", "On", "Off", False, "iLogic")
        ToggleAssemblies(ThisApplication.ActiveDocument, Assyboolean)
    End If
    sw.Stop()
    Dim timeElapsed As Timespan = sw.elapsed
    messagebox.show("Processing took: " & String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                        timeElapsed.Hours,
                                                        timeElapsed.Minutes,
                                                        timeElapsed.Seconds,
                                                        timeElapsed.Milliseconds / 10))
End Sub

Sub ToggleAssemblies(ByVal oAssyDoc As AssemblyDocument, ByVal wfBoolean As Boolean)
    'Toggle this document
    'set work plane visibility
    For Each oWorkPlane In oAssyDoc.ComponentDefinition.WorkPlanes
        oWorkPlane.Visible = wfBoolean
    Next

    'set work axis visibility
    For Each oWorkAxis In oAssyDoc.ComponentDefinition.WorkAxes
        oWorkAxis.Visible = wfBoolean
    Next

    'set work point visibility
    For Each oWorkPoint In oAssyDoc.ComponentDefinition.WorkPoints
        oWorkPoint.Visible = wfBoolean
    Next
    'Check all referenced docs
    Dim oDoc As Inventor.Document
    For Each oDoc In oAssyDoc.AllReferencedDocuments
        If TypeOf oDoc Is partdocument Then
            ToggleParts(oDoc, wfBoolean)
        Else
            'set work plane visibility
            For Each oWorkPlane In oDoc.ComponentDefinition.WorkPlanes
                oWorkPlane.Visible = wfBoolean
            Next

            'set work axis visibility
            For Each oWorkAxis In oDoc.ComponentDefinition.WorkAxes
                oWorkAxis.Visible = wfBoolean
            Next

            'set work point visibility
            For Each oWorkPoint In oDoc.ComponentDefinition.WorkPoints
                oWorkPoint.Visible = wfBoolean
            Next
            ToggleAssemblies(oDoc, wfBoolean)
        End If
    Next
    'update the files
    InventorVb.DocumentUpdate()
End Sub

Sub ToggleParts(ByVal oDoc As document, ByVal wfBoolean As Boolean)
    Dim PartDoc As PartDocument = oDoc
    ''get user input as True or False
    '    Dim partboolean As Boolean = Nothing
    '    If wfBoolean = Nothing Then
    '        partboolean = InputRadioBox("Turn all Work Features On/Off", "On", "Off", False, "iLogic")
    '    Else
    '        partboolean = wfBoolean
    '    End If
    For Each oWorkPlane In PartDoc.ComponentDefinition.WorkPlanes
        oWorkPlane.Visible = wfBoolean
    Next
    'set work axis visibility
    For Each oWorkAxis In PartDoc.ComponentDefinition.WorkAxes
        oWorkAxis.Visible = wfBoolean
    Next
    'set work point visibility
    For Each oWorkPoint In PartDoc.ComponentDefinition.WorkPoints
        oWorkPoint.Visible = wfBoolean
    Next
    togglePartSketches(oDoc, wfBoolean)
    InventorVb.DocumentUpdate()
End Sub

Sub togglePartSketches(ByVal doc As document, ByVal wfBoolean As Boolean)
    For Each o2DSketch As Sketch In doc.ComponentDefinition.Sketches
        o2DSketch.Visible = wfBoolean
    Next

    For Each o3DSketch As Sketch3D In doc.ComponentDefinition.Sketches3D
        o3DSketch.Visible = wfBoolean
    Next

    'wfBoolean = InputRadioBox("Toggle Sketch Dimension display On/Off", "On", "Off", False, "iLogic")
    For Each o2DSketch As Sketch In doc.ComponentDefinition.Sketches
        o2DSketch.DimensionsVisible = wfBoolean
    Next
End Sub

This rule also turns off sketches.

 

🙂

Message 3 of 5

gowthamnaidu84
Observer
Observer

Hey , Thank you for the code but, Its got a Syntax Error

Please help

0 Likes
Message 4 of 5

gowthamnaidu84
Observer
Observer

Its Working fine as a Ilogic Code. Thank you so much

0 Likes
Message 5 of 5

mrCharles1
Participant
Participant
Works amazing, thank you!!
0 Likes