Monday 14 August 2017

Translucent Off via iLogic

                If you import foreign cad models you might get the import as surfaces which show up as orange, translucent objects.

                I had one the other day that I needed to import as assembly but having all surfaces translucent did not cut it for me so being lazy I had written a code to change all parts and remove transparency.

                Short and sweet, here it is:

Dim oAsmDoc As AssemblyDocument 
oAsmDoc = ThisApplication.ActiveDocument 

' Get the assembly component definition. 
Dim oAsmDef As AssemblyComponentDefinition 
oAsmDef = oAsmDoc.ComponentDefinition 

' Get all of the leaf occurrences of the assembly. 
Dim oLeafOccs As ComponentOccurrencesEnumerator 
oLeafOccs = oAsmDef.Occurrences.AllLeafOccurrences 

Dim oPartDoc As PartDocument
Dim oOcc As ComponentOccurrence 

' Process the occurrences, 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( _ 
        oAsmDoc, "Translucent Off")

    For Each oOcc In oLeafOccs 
        oPartDoc = oOcc.Definition.Document
        Dim oWorkSurfaces As WorkSurfaces
        oWorkSurfaces = oPartDoc.ComponentDefinition.WorkSurfaces
        Dim oWorkSurface As WorkSurface
        For Each oWorkSurface In oWorkSurfaces
            oWorkSurface.Translucent = False
'end transaction


photo credit: Laura Tabakman Tabakman_Floating-bottom view (license)

No comments:

Post a Comment