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!

STORE/SAVE COLOR ARRAY OF PARTBODY

Status
Not open for further replies.

Thosnow

Aerospace
Feb 23, 2017
68
CA
Hello Ferdo and Others,

I am able to obtain color of part body in CATIA V5 in term of color array (ex: r = 255, g = 128, b = 0)

1) How do I declare variable(s) (as Long, Double...ext)
2) How do I store/save those color array elements (r, g, b values) in variable(s) so that I can retrieve and re-apply those color values back to part body (using visProperties1.SetRealColor r, g, b, 1)?

3) What is the syntax or example to achieve above challenge?

Thank you All in advance

Quin
 
Replies continue below

Recommended for you

it's all explain in the v5automation.chm file... plz read

Eric N.
indocti discant et ament meminisse periti
 
Hi itsmyjob,

I have read the the v5automation.chm file at GetRealColor and SetRealColor function but not able to figure out how to store color array numbers in variables and apply them back to partbody later.

Could you please kindly point me exactly where in the v5automation.chm file I should read?

Thank you

Quin
 
did you try your first question on google?

you said:
How do I declare variable(s) (as Long, Double...ext)?

Code:
dim x as Long

you said:
2) How do I store/save those color array elements (r, g, b values) in variable(s) so that I can retrieve and re-apply those color values back to part body (using visProperties1.SetRealColor r, g, b, 1)?

Code:
CATIA.ActiveDocument.Selection.VisProperties.GetRealColor rInit, gInit, bInit

CATIA.ActiveDocument.Selection.VisProperties.SetRealColor rSecondValue, gSecondValue, bSecondValue, 1

CATIA.ActiveDocument.Selection.VisProperties.SetRealColor rInit, gInit, bInit, 1

Eric N.
indocti discant et ament meminisse periti
 
Thank you itsmyjob,

I will try and let you know.

Below is my VBA code and it encounters "method" error as seen on attached image and noted below.

Could you please help me to correct the code so that it can cycle through the captures and display captures one by one for printing captures?

============================== VBA CODE =============

Sub CATMain()

'//// Browse active document
Dim Part, PartDoc, oAnnotationSets, oSelection
Set PartDoc = CATIA.ActiveDocument
Set Part = PartDoc.Part
Set oAnnotationSets = Part.AnnotationSets

MsgBox "Number of annotation sets in active document: " & oAnnotationSets.Count

Dim AnnotSet1, oCaptures
Set AnnotSet1 = oAnnotationSets.Item(1)

Set oCaptures = AnnotSet1.Captures

Dim IdxCapt
For IdxCapt = 1 To oCaptures.Count
Set oCaptures = AnnotSet1.Item(IdxCapt) (<== Error Message is here)
oCaptures.DisplayCapture
Next
End Sub

Thank you

Quin
 
 http://files.engineering.com/getfile.aspx?folder=2789dddb-4678-41c1-aba4-ec08b7f8fe88&file=Capture.JPG
Hi itsmyjob.

In response to your previous guidance, below is my simple VBA code.

Dim rInit, gInit, bInit as Long
CATIA.ActiveDocument.Selection.VisProperties.GetRealColor rInit, gInit, bInit

It says "ByRef argument Type mismatched"
I am still not quite sure how to store those color array numbers.

Could you please be more specific?

Thank you

Quin
 
you cant dim several variable like that in one line

Eric N.
indocti discant et ament meminisse periti
 
please use the proper function to upload image into post

Eric N.
indocti discant et ament meminisse periti
 
So you mean to declare variables like below?

Dim rInit As Long
Dim gInit As Long
Dim Init As Long

Quin
 
did you try it?

Eric N.
indocti discant et ament meminisse periti
 
yes, I tried and it worked. Thank you again

Quin
 
it would be nice to post your final code so other could learn

Eric N.
indocti discant et ament meminisse periti
 
Below VBA code is for others for reference.


Dim visProperties1 '//// As VisProperty
Set visProperties1 = CATIA.ActiveDocument.Selection.VisProperties

Dim R, G, B

'//// Retrieve real color of current PartBody in selection collection
visProperties1.GetRealColor R, G, B

'//// Store color array for future usage
Dim rInit As Long
Dim gInit As Long
Dim bInit As Long

CATIA.ActiveDocument.Selection.VisProperties.GetRealColor rInit, gInit, bInit

'//// Set color of PartBody to white
visProperties1.SetRealColor 255, 255, 255, 0
 
you might not need

Code:
Dim R, G, B

Eric N.
indocti discant et ament meminisse periti
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top