×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Reset graphical properties
2

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.

Best regards,
Stely

RE: Reset graphical properties

2
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

RE: Reset graphical properties

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

RE: Reset graphical properties

(OP)
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

RE: Reset graphical properties

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

RE: Reset graphical properties

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

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 "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 smile      

Regards
Fernando

RE: Reset graphical properties

(OP)
Great job Fernando! Thanks a lot (mii de multzumiri smile ), it works amazingly!!!

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

Best regards,
Stely

RE: Reset graphical properties

You are welcome ( big smile )

Regards
Fernando

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources