Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

turning off thousands of work planes

16 REPLIES 16
SOLVED
Reply
Message 1 of 17
Anonymous
2263 Views, 16 Replies

turning off thousands of work planes

Ive started at a company where all of their parts and assemblies have all of the work planes, axis and points visible. Im getting bored of going view, object visibility, turn off all work features everytime i open a new model. has anyone written anything that will turn off these features and only turn them back on when requested.

basically im looking for a shortcut, rather than opening every part and assembly and doing it manually

many thanks
16 REPLIES 16
Message 2 of 17
Anonymous
in reply to: Anonymous

To turn all the sketches off, use this sub
And do similar to axis and points
CVA

Public Sub SketchVisibleOff()
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument

Dim oSketch As PlanarSketch
For Each oSketch In oDoc.ComponentDefinition.Sketches
oSketch.Visible = False
Next
End Sub

--
www.CVAengineering.com

IV11 Pro. sp2 and IV2008 Pro. sp1
Window XP Pro sp2
Pentium 3.2 Ghz, 3.0 GB of RAM
NVIDIA FX 3400 91.85
SpacePilot V 3.3.6
wrote in message news:5696261@discussion.autodesk.com...
Ive started at a company where all of their parts and assemblies have all of
the work planes, axis and points visible. Im getting bored of going view,
object visibility, turn off all work features everytime i open a new model.
has anyone written anything that will turn off these features and only turn
them back on when requested.

basically im looking for a shortcut, rather than opening every part and
assembly and doing it manually

many thanks
Message 3 of 17
Anonymous
in reply to: Anonymous

Thanks chris but im a novice with code... ill try but probibly come back for some more questions
Message 4 of 17
Anonymous
in reply to: Anonymous

ok, i got this to work with induvidual parts, i dont know how to get it to go through an assembly and sub assembly working on all parts and assemblies.
Message 5 of 17
Anonymous
in reply to: Anonymous

replace Dim oDoc As PartDocument with AssemblyDocument
CVA

--
www.CVAengineering.com

IV11 Pro. sp2 and IV2008 Pro. sp1
Window XP Pro sp2
Pentium 3.2 Ghz, 3.0 GB of RAM
NVIDIA FX 3400 91.85
SpacePilot V 3.3.6
wrote in message news:5696315@discussion.autodesk.com...
ok, i got this to work with induvidual parts, i dont know how to get it to
go through an assembly and sub assembly working on all parts and assemblies.
Message 6 of 17
Anonymous
in reply to: Anonymous

that works for assembly sketches, if i have an assembly containing parts and sub assemblies, how do i use it from the top level assembly to turn off the sketches in all subs and parts below? thanks for your patients
Message 7 of 17
Anonymous
in reply to: Anonymous

Not sure if you can dig in parts or subassemblies from a main assembly to
turn off the work features
Anyone ???
CVA

--
www.CVAengineering.com

IV11 Pro. sp2 and IV2008 Pro. sp1
Window XP Pro sp2
Pentium 3.2 Ghz, 3.0 GB of RAM
NVIDIA FX 3400 91.85
SpacePilot V 3.3.6
wrote in message news:5696358@discussion.autodesk.com...
that works for assembly sketches, if i have an assembly containing parts and
sub assemblies, how do i use it from the top level assembly to turn off the
sketches in all subs and parts below? thanks for your patients
Message 8 of 17
Anonymous
in reply to: Anonymous

It is possible to traverse through the entire assembly setting the
visibility of the various objects. However, I don't think that's what you
would really want to do. The problem with this is that you're dirtying all
of the documents that you touch so they'll all want to be saved and you're
changing how that document will appear the next time it's opened. It's
probably better to use the display overrides in the part or assembly. This
just overrides the display for the active document but leaves the referenced
document untouched. Here are two macros that will turn on or off the
display of everything. You can decide what you really want to turn on or
off by commenting out some of the lines. The same macros will work in
either a part or assembly document.

Public Sub TurnOffSketchesWorkFeaturesSurfaces()
Dim colControlDefNames As New Collection
Call colControlDefNames.Add("AppOriginAxesVisibilityCmd") '
Display origin work axes.
Call colControlDefNames.Add("AppOriginPlanesVisibilityCmd") '
Display origin work planes.
Call colControlDefNames.Add("AppOriginPointsVisibilityCmd") '
Display origin work points.
Call colControlDefNames.Add("App3DSketchesVisibilityCmd") '
Display 3D sketches.
Call colControlDefNames.Add("AppAllWorkfeaturesCmd") '
Display all work features (origin and user)
Call colControlDefNames.Add("AppConstructionSurfacesVisibilityCmd") '
Display Construction Surfaces.
Call colControlDefNames.Add("AppSketchesVisibilityCmd") '
Display sketches.
Call colControlDefNames.Add("AppUserWorkAxesVisibilityCmd") '
Display user defined work axes.
Call colControlDefNames.Add("AppUserWorkPlanesVisibilityCmd") '
Display user defined work planes.
Call colControlDefNames.Add("AppUserWorkPointsVisibilityCmd") '
Display user defined work points.

Dim i As Integer
For i = 1 To colControlDefNames.Count
' Get the control definition.
Dim oButtonDef As ButtonDefinition
Set oButtonDef =
ThisApplication.CommandManager.ControlDefinitions.Item(colControlDefNames.Item(i))

If oButtonDef.Pressed Then
oButtonDef.Execute
End If
Next
End Sub

Public Sub TurnOnSketchesWorkFeaturesSurfaces()
Dim colControlDefNames As New Collection
Call colControlDefNames.Add("AppOriginAxesVisibilityCmd") '
Display origin work axes.
Call colControlDefNames.Add("AppOriginPlanesVisibilityCmd") '
Display origin work planes.
Call colControlDefNames.Add("AppOriginPointsVisibilityCmd") '
Display origin work points.
Call colControlDefNames.Add("App3DSketchesVisibilityCmd") '
Display 3D sketches.
Call colControlDefNames.Add("AppAllWorkfeaturesCmd") '
Display all work features (origin and user)
Call colControlDefNames.Add("AppConstructionSurfacesVisibilityCmd") '
Display Construction Surfaces.
Call colControlDefNames.Add("AppSketchesVisibilityCmd") '
Display sketches.
Call colControlDefNames.Add("AppUserWorkAxesVisibilityCmd") '
Display user defined work axes.
Call colControlDefNames.Add("AppUserWorkPlanesVisibilityCmd") '
Display user defined work planes.
Call colControlDefNames.Add("AppUserWorkPointsVisibilityCmd") '
Display user defined work points.

Dim i As Integer
For i = 1 To colControlDefNames.Count
' Get the control definition.
Dim oButtonDef As ButtonDefinition
Set oButtonDef =
ThisApplication.CommandManager.ControlDefinitions.Item(colControlDefNames.Item(i))

If Not oButtonDef.Pressed Then
oButtonDef.Execute
End If
Next
End Sub

--
Brian Ekins
Autodesk Inventor API
Message 9 of 17
Anonymous
in reply to: Anonymous

perfect, after the pagewrap... thanks a lot
Message 10 of 17
josefpfister
in reply to: Anonymous

I keep having all the work planes, features and sketches turn on and can not turn them off. Is there a command or dialogue box that works. I tried using the macro for this but it returns a run error.??

Message 11 of 17
MarcusRowe
in reply to: Anonymous

This is one of those annoying features (or lack of) that make inventor look like a toy CAD program. I have expereinced the same issue. All I can suggest is you start using ProEngineer wherer this problem is solved by clicking one icon. Thats is - simple! One click! No complicated scripting or fancy footwork. One click - all planes are shown, one click all planes are not shown. Easy....are you listening to me autodesk!!!!!!!

Message 12 of 17
josefpfister
in reply to: MarcusRowe

You can actually turn them all off, work planes, axes, work points, sketches the whole kit and kabutal with one click of the menu selection unter view menu left hand side top. It took me a while to find it too. Very disappoint at first, but then I came to realize there are subtle ways of achiving the same things I used to do in other CAD programs. I'm at home so I can't relay the exact steps for you, but am willing to do so tomorrow while I'm at work and I have the screen in front of me. It so easy you'll be surprised.

 

Josef

Message 13 of 17
MarcusRowe
in reply to: josefpfister

Josef, you're a champion. I now hate Inventor 2% less.

Message 14 of 17
ekinsb
in reply to: MarcusRowe

New API functionality has been exposed since I last commented in this thread.  The solution before was setting the visibility of the work features or sketches to be invisible.  This is the same as right-clicking on the object in the browser and specifying it's visibility state.  This is a property of the work feature or sketch and is saved.  This isn't always what you want and is different from what the Object Visibility command does, which I think is probably what most people want in this case.  Especially in an assembly where you want to change the visibility of what you're seeing without dirtying all of the referenced documents.

 

The PartDocument and AssemblyDocument objects support the ObjectVisibility property which returns an ObjectVisibility object.  This object has properties that provide the equivalent functionalty of the Object Visibility command.  For example, the following VBA code will turn off all sketches and work features.

 

Public Sub TurnAllOff()
    ' Make sure a part of assembly is active.
    If ThisApplication.ActiveDocumentType = kAssemblyDocumentObject Or _
            ThisApplication.ActiveDocumentType = kPartDocumentObject Then
       Dim doc As Document
       Set doc = ThisApplication.ActiveDocument
       
       Dim objVis As ObjectVisibility
       Set objVis = doc.ObjectVisibility
       
       objVis.AllWorkFeatures = False
       objVis.Sketches = False
       objVis.Sketches3D = False
    Else
        MsgBox "A part of assembly must be active."
    End If
End Sub

 

 


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 15 of 17
dano0310
in reply to: Anonymous

Hi Brian
I used to find that this method is a little frustrating because as soon as a new workplane is added it turns the visibility back on and there are once again a million planes shown. I don't mind having to save every file and therefore I iterate through all the parts and turn off all the work features that have been left on and save the changes if there are any. Mind you I check to see that there are in fact work features to turn off so that I font have to save more files than necessary.
Dan
Message 16 of 17
xiaodong_liang
in reply to: dano0310

Hi,

 

Actually after running code, you can see the property [Visibility] is still ON. ObjectVisibility only changes the visibility (displaying) of an object temporarily.  This is a consistent behavior to UI View tab >> ObjectVisibility panel. After you toogle Off for all workplanes, and create a new workplane, the previous visible workplanes will become visible again. 

 

except changing the property Visibile of a workplane, I cannot think of other ways at this moment..

 

 

 

 

 

 

 

Message 17 of 17
leblanc2024
in reply to: ekinsb

@ekinsb,

 

Thanks this vba was very helpful.

I added "objVis.WeldmentSymbols = False" to also hide weld symbols to have a clean image export for our catalogue.

 

 

Regards,
Ivon

"You don't know if you can unless you try!"
Tags (1)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report