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: 

Macro to hide sketch

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
diego.deluis
1079 Views, 5 Replies

Macro to hide sketch

Hello everyone,

 

I´m trying to find a macro to be able to turn off all sketches. It should work if I have a part open, a simple assembly or a big assembly with sub-assemblies. 

 

I know there is an option to hide them, but I would like to do it in one click.

 

Thank you all,

 

Diego

5 REPLIES 5
Message 2 of 6
VdVeek
in reply to: diego.deluis

This is a VBA-macro to hide Sketches and workplanes in parts and assemblies. I use it on a daily basis.

Rob.

Autodesk Inventor 2015 Certified Professional & Autodesk Inventor 2012 Certified Professional.
Message 3 of 6
diego.deluis
in reply to: VdVeek

Thanks, macro is working perfectly.

 

But I realize that for my problem, press F10 is enough 😄

 

 

Thank you anyway,

 

D.

Message 4 of 6
mlkuselan
in reply to: VdVeek

Hi

Thanks for the macro.

The macro is working fine to make all sketches visible.

once again when we run the macro to make all sketches invisible, the macro makes invisible only sketches that were made visible by the macro.

The initial sketches(manually turned visible in the browser) that were visible before the macro was run remains unchanged.

Please advice.

M.L.Kuselan

Message 5 of 6
WCrihfield
in reply to: mlkuselan

You might need to alter your Design View Represenations for those components that aren't responding.  If these components are in an assembly, and you don't want to modify the individual Design View Representations, you will need to make sure their Representations aren't set as "Associative" within the assembly or sub-assembly.

Also, I've had an external iLogic rule that does the same thing, and I noticed that within the oPartDoc portion of your code you are redefining oDoc As Inventor.Document, as you did in the Assembly portion of your code, but it isn't needed for the Part portion of the code.  So you could probably delete that line.

Wesley Crihfield

EESignature

Message 6 of 6
mlkuselan
in reply to: WCrihfield

Hi

I copied the code from another post of same requirement and made some alteration.

But iam getting error (For Each oSketch In oSketches) Type Mismatch error

Please someone check and rectify.

Regards

M.L.Kuselan

 

Public Sub Skt_Invi_prox()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

Dim oCompDef As AssemblyComponentDefinition
Set oCompDef = oDoc.ComponentDefinition


Dim oLeafOccs As ComponentOccurrencesEnumerator
Set oLeafOccs = oCompDef.Occurrences.AllLeafOccurrences

Dim RefPartDef As PartComponentDefinition
Dim RefAssyDef As AssemblyComponentDefinition

Dim oOcc As ComponentOccurrence

Dim RefPlanes As WorkPlanes
Dim RefPlane As WorkPlane
Dim oSkeches As PlanarSketches
Dim oSkectch As PlanarSketch

Dim ProxyPlane As WorkPlaneProxy
Dim oSketchProxy As PlanarSketchProxy

For Each oOcc In oLeafOccs
MsgBox (oOcc.Name)
If oOcc.Suppressed = False Then

If oOcc.DefinitionDocumentType = kPartDocumentObject Then

Set RefPartDef = oOcc.Definition
Set RefPlanes = RefPartDef.WorkPlanes
Set oSkecthes = RefPartDef.Sketches

For Each RefPlane In RefPlanes
Call oOcc.CreateGeometryProxy(RefPlane, ProxyPlane)
ProxyPlane.Visible = False
Next

For Each oSketch In oSketches
MsgBox (oSketch.Name)
Call oOcc.CreateGeometryProxy(oSketch, oSketchProxy)
oSketchProxy.Visible = False
Next

ElseIf oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
RefAssyDef = oOcc.Definition

End If

End If
Next

ThisApplication.ActiveDocument.Update
End Sub

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

Post to forums  

Autodesk Design & Make Report