Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reset graphical properties 2

Status
Not open for further replies.

slcad

Automotive
Nov 7, 2006
95
CA
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.



Best regards,
Stely
 
Replies continue below

Recommended for you

Hi

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
 
OK, now its clear...

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
 
Thank you for your time, Fernando

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
 
 http://files.engineering.com/getfile.aspx?folder=dc531d35-9251-4069-a646-48bb74e762ff&file=macro_error.jpg
Interesting, on a HP workstation with r16 its OK...did you copy-paste in a CATScript file?

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
 
I guess that you have done it with VB ferdo, if I'm not misstaken you have to puncuate all variable declarations.

example:
Dim productDocument1 As Document
has to be:
Dim productDocument1 'As Document

Put a comma in front of all As
 
Language="VBSCRIPT"

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
 
Great job Fernando! Thanks a lot (mii de multzumiri :) ), it works amazingly!!!

If I could give you more stars, I would surely do so...

Best regards,
Stely
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top