Quantcast
Channel: From the Trenches with Autodesk Inventor
Viewing all articles
Browse latest Browse all 61

Traverse Assembly to Turn Off all Work Features and Sketches with iLogic

$
0
0


Issue:
An update to an older post on this topic:
http://inventortrenches.blogspot.com/2013/03/turn-onoff-all-workfeatures-with-ilogic.html

Solution:
You can use this example iLogic rule to traverse the assembly (and subassemblies) to turn off all work features and sketches.


SubMain

DimoDocAsAssemblyDocument = ThisApplication.ActiveDocument
DimoOccsAsComponentOccurrences = oDoc.ComponentDefinition.Occurrences

DimsNameAsString
sName = oDoc.DisplayName

'set vis in the top level
CallSetVis(oDoc, sName)

CallTraverseAssembly(oOccs)

EndSub

SubTraverseAssembly(oOccsAsComponentOccurrences)

DimoOccAsComponentOccurrence
ForEachoOccInoOccs

DimoDocAsDocument
oDoc = oOcc.Definition.Document

DimsNameAsString
sName = oOcc.Name

'set vis in the component
CallSetVis(oOcc.Definition.Document, sName)

'if sub assembly step into it's Occurrences collection
IfoOcc.DefinitionDocumentType = _
DocumentTypeEnum.kAssemblyDocumentObjectThen
Logger.Info("Stepping into: "& sName)

oSubOccs = oDoc.ComponentDefinition.Occurrences
CallTraverseAssembly(oSubOccs)
EndIf
Next

EndSub

SubSetVis(oDocAsDocument, sNameAsString)

DimoDefAsComponentDefinition
oDef = oDoc.ComponentDefinition


ForEachoItemInoDef.Workplanes
Try
oItem.visible = False
Catch
Logger.Info("Could not set work plane vis for: "& sName)
EndTry
Next

ForEachoItemInoDef.WorkAxes
Try
oItem.visible = False
Catch
Logger.Info("Could not set work axis vis for: "& sName)
EndTry
Next

ForEachoItemInoDef.WorkPoints
Try
oItem.visible = False
Catch
Logger.Info("Could not set work point vis for: "& sName)
EndTry
Next

ForEachoItemInoDef.Sketches
Try
oItem.visible = False
Catch
Logger.Info("Could not set sketch vis for: "& sName)
EndTry
Next

EndSub


Viewing all articles
Browse latest Browse all 61

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>