Reset graphical properties
Reset graphical properties
(OP)
Hi there,
Is there any easy way to reset the graphical properties (color, transparency etc) of a whole assembly in one shot? Of course the components are colored individually in each file, and we would need a new assembly where everything has the default color and no transparency.
What I'm looking for is something similar to the "Reset properties / Apply to children" contextual command that you can apply to a body within a part.
Is there any easy way to reset the graphical properties (color, transparency etc) of a whole assembly in one shot? Of course the components are colored individually in each file, and we would need a new assembly where everything has the default color and no transparency.
What I'm looking for is something similar to the "Reset properties / Apply to children" contextual command that you can apply to a body within a part.
Best regards,
Stely





RE: Reset graphical properties
I tried to create a macro to do that...
Up to now I have
Language="VBSCRIPT"
Sub CATMain()
Dim productDocument1 As Document
Set productDocument1 = CATIA.ActiveDocument
Dim selection1 As Selection
Set selection1 = productDocument1.Selection
selection1.Search "CATAsmSearch.Part,all"
'~ ******* change color of selection (to change in magenta for example - RGB code 255,0,255,1 - if you want something else put the right RGB code)
Set visPropertySet1 = selection1.VisProperties
visPropertySet1.SetRealColor 255,0,255,1
selection1.Clear
Dim specsAndGeomWindow1 As Window
Set specsAndGeomWindow1 = CATIA.ActiveWindow
Dim viewer3D1 As Viewer
Set viewer3D1 = specsAndGeomWindow1.ActiveViewer
viewer3D1.Reframe
Dim viewpoint3D1 As Viewpoint3D
Set viewpoint3D1 = viewer3D1.Viewpoint3D
End Sub
I remember what Eric said once, its better to create a counter to select parts....if you want....
Now for the transparency I have a problem...maybe someone else can help us....
I know how to get the transparency for a selected component (code bellow from DS docs)
Language="VBSCRIPT"
Sub CATMain()
Dim productDocument1 As Document
Set productDocument1 = CATIA.ActiveDocument
Dim selection1 As Selection
Set selection1 = productDocument1.Selection
Dim op
op = CLng(0)
Set visProperties1 = CATIA.ActiveDocument.Selection.VisProperties
visProperties1.GetRealOpacity op
MsgBox "opacity = " & op
End Sub
but I don't know how to set it!!! (its giving me an error...)
Any help?
Regards
Fernando
RE: Reset graphical properties
Language="VBSCRIPT"
Sub CATMain()
Dim productDocument1 As Document
Set productDocument1 = CATIA.ActiveDocument
Dim selection1 As Selection
Set selection1 = productDocument1.Selection
selection1.Search "CATAsmSearch.Part,all"
'~ ******* change color of selection (to change in magenta for example - RGB code 255,0,255,1)
Set visPropertySet1 = selection1.VisProperties
visPropertySet1.SetRealColor Auto,Auto,Auto,Auto
Set visProperties1 = CATIA.ActiveDocument.Selection.VisProperties
visProperties1.SetRealOpacity 255,1
selection1.Clear
Dim specsAndGeomWindow1 As Window
Set specsAndGeomWindow1 = CATIA.ActiveWindow
Dim viewer3D1 As Viewer
Set viewer3D1 = specsAndGeomWindow1.ActiveViewer
viewer3D1.Reframe
Dim viewpoint3D1 As Viewpoint3D
Set viewpoint3D1 = viewer3D1.Viewpoint3D
End Sub
Regards
Fernando
RE: Reset graphical properties
I have to admit I have limited to no knowledge about macros... I tried to run it and it gave me the error message in the attached picture.
From what I could understand from your script, it would reset the color of an entire part from a product, right? What I would need was a little deeper... Basically, I would need to do the "Reset properties" of the bodies within the parts from a product... So, the bodies were created using features of various colors, and that's what I need to reset...
It's not a major thing, it has to do with our procedures of keeping different revisions of the tool and color-marking the differences. If it take too much time, don't waste your time with it. I hoped there would be a simple way that I didn't know about...
Thanks anyway!
Best regards,
Stely
RE: Reset graphical properties
The CATScript its changing graphic properties of all CATParts within a CATProduct. I didn't tested for your case and now I don't have CATIA.....maybe tomorrow if I will have time.
Regards
Fernando
RE: Reset graphical properties
example:
Dim productDocument1 As Document
has to be:
Dim productDocument1 'As Document
Put a comma in front of all As
RE: Reset graphical properties
Sub CATMain()
Dim productDocument1 As Document
Set productDocument1 = CATIA.ActiveDocument
Dim selection1 As Selection
Set selection1 = productDocument1.Selection
selection1.Search "CATPrtSearch.MechanicalFeature,all"
Set visPropertySet1 = selection1.VisProperties
visPropertySet1.SetRealColor 210,210,255,1
Set visProperties1 = CATIA.ActiveDocument.Selection.VisProperties
visProperties1.SetRealOpacity 255,1
selection1.Clear
selection1.Search "CATAsmSearch.Part,all"
Set visPropertySet1 = selection1.VisProperties
visPropertySet1.SetRealColor 210,210,255,1
Set visProperties1 = CATIA.ActiveDocument.Selection.VisProperties
visProperties1.SetRealOpacity 255,1
selection1.Clear
Dim specsAndGeomWindow1 As Window
Set specsAndGeomWindow1 = CATIA.ActiveWindow
Dim viewer3D1 As Viewer
Set viewer3D1 = specsAndGeomWindow1.ActiveViewer
viewer3D1.Reframe
Dim viewpoint3D1 As Viewpoint3D
Set viewpoint3D1 = viewer3D1.Viewpoint3D
End Sub
To Azrael: Thanks, its also working 'as you said
Regards
Fernando
RE: Reset graphical properties
If I could give you more stars, I would surely do so...
Best regards,
Stely
RE: Reset graphical properties
Regards
Fernando