ILogic: Color Machined Faces in Weldment

ILogic: Color Machined Faces in Weldment

petr.meduna
Advocate Advocate
425 Views
0 Replies
Message 1 of 1

ILogic: Color Machined Faces in Weldment

petr.meduna
Advocate
Advocate

Hello,

I recently discovered this rule for coloring machined face in weldment document on Autodesk forum here and it should work for both part and subassemblies. However, when i put subassembly in weldment, create some machining and activate the rule, nothing happens, it only reset view in document. But when I put the parts into the weldment first, I activate the rule and then place a subassembly, the rule works fine. Problem is, that I need to run this rule in finished welds with subassemblies. 

 

'Farben definieren
Dim Bauteilfarbe As String
Bauteilfarbe = "Glatt - Elfenbein"
Dim Bearbeitungsfarbe As String
Bearbeitungsfarbe = "Dunkelgrau"

'Bauteilende vor das erste Feature setzen
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
Dim oFirstFeature As PartFeature
oFirstFeature = oAsmDoc.ComponentDefinition.Features.Item(1)
Feature.InventorFeature(oFirstFeature.Name).SetEndOfPart(True)

'Bearbeitung aktivieren
Dim oAsmCompDef As WeldmentComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim oOccs As ComponentOccurrences
oOccs = oAsmCompDef.Occurrences
oAsmCompDef.Machining.Edit()

'Alle Körper- u. Flächenfarben überschreiben
For Each oOcc In oOccs
oOcc.SetRenderStyle(37121)
Dim oBody As SurfaceBody
For Each oBody In oOcc.SurfaceBodies
Dim oBodyProxy As SurfaceBodyProxy
oBodyProxy = oBody
Dim oBodyNative As SurfaceBody
oBodyNative = oBodyProxy.NativeObject

Dim oDoc As Document
oDoc = oBodyNative.ComponentDefinition.Document
oBodyNative.SetRenderStyle(37123, oDoc.RenderStyles.Item(Bearbeitungsfarbe))

Dim oFace As Face
For Each oFace In oBody.Faces
Dim oFaceProxy As FaceProxy
oFaceProxy = oFace
Dim oFaceNative As Face
oFaceNative = oFaceProxy.NativeObject

oDoc = oFaceNative.Parent.ComponentDefinition.Document
oFaceNative.SetRenderStyle(37123, oDoc.RenderStyles.Item(Bauteilfarbe))

Next oFace
Next oBody
Next oOcc

'Bearbeitung deaktivieren
oAsmCompDef.Machining.ExitEdit()

ThisApplication.ActiveView.GoHome
ThisApplication.ActiveView.Fit
iLogicVb.UpdateWhenDone = True

 

I there anyone, who knows, how to make the rule run properly?

0 Likes
426 Views
0 Replies
Replies (0)