Wednesday 21 December 2016

Component Sketches Off


I hate when people don’t clean up their models. Although not right my mind associates this to a messy person with unclean desk, car, and garage, buried in piles of unneeded stuff.



                OCD is my middle name and while I hate this side of you, I love you as well and I think maybe you weren’t taught how to do it properly.

                I suggest you never use the “Object Visibility” drop down on the View tab.

I NEVER USE IT; except to see if you’ve been cheeky and got this quick fix like a drug addict.

It’s a crapshoot and it will bite you faster than you think. Have you considered the time, effort and stress you are going to experience when using this in large assemblies.

That’s all I am going to say and I will share  a bit of iLogic code I use to clean up this mess I see regularly with sketches not being turned off.

I have another one where I turn off the visibility of workfeatures, WorkPoints, WorkAxis, WorkPlanes and I like to keep it separate from the sketch visibility because when using it with tube and pipe it will turn the routes off and I don’t want that.

Component Sketches Off

I have also wrapped the whole process as a single transaction because if I need to undo the operation I only need to do a single undo not clicking back for each sketch that is off.


Code below and in this download link

-------------------------------------------
'catch and skip errors
On Error Resume Next
'define the active assembly
Dim oAssyDoc As AssemblyDocument
oAssyDoc = ThisApplication.ActiveDocument 

'get user input as True or False
wfBoolean = InputRadioBox("Turn all Sketches On/Off", "On", "Off", False, "iLogic")

' Process the rule, wrapping it in a transaction so the 
' entire process can be undone with a single undo operation. 
Dim trans As Transaction 
trans = ThisApplication.TransactionManager.StartTransaction( _ 
        oAssyDoc, "Sketches Off")

'Check all referenced docs
Dim oDoc As Inventor.Document
For Each oDoc In oAssyDoc.AllReferencedDocuments
    'set Sketch visibility
    For Each oSketch In oDoc.ComponentDefinition.Sketches
    oSketch.Visible = wfBoolean
    Next    
    
Next

'end transaction for single undo
trans.End 

'upate the files
InventorVb.DocumentUpdate()
-------------------------------------------


Later,
ADS
photo credit: Rubina V. Jahrmarkt (license)

No comments:

Post a Comment