×
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

STORE/SAVE COLOR ARRAY OF PARTBODY

STORE/SAVE COLOR ARRAY OF PARTBODY

STORE/SAVE COLOR ARRAY OF PARTBODY

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

RE: STORE/SAVE COLOR ARRAY OF PARTBODY

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

Eric N.
indocti discant et ament meminisse periti

RE: STORE/SAVE COLOR ARRAY OF PARTBODY

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

RE: STORE/SAVE COLOR ARRAY OF PARTBODY

did you try your first question on google?

Quote (you)

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

CODE --> VBA

dim x as Long 

Quote (you)

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 --> VBA

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

RE: STORE/SAVE COLOR ARRAY OF PARTBODY

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

RE: STORE/SAVE COLOR ARRAY OF PARTBODY

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

RE: STORE/SAVE COLOR ARRAY OF PARTBODY

you cant dim several variable like that in one line

Eric N.
indocti discant et ament meminisse periti

RE: STORE/SAVE COLOR ARRAY OF PARTBODY

please use the proper function to upload image into post

Eric N.
indocti discant et ament meminisse periti

RE: STORE/SAVE COLOR ARRAY OF PARTBODY

(OP)
So you mean to declare variables like below?

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

Quin

RE: STORE/SAVE COLOR ARRAY OF PARTBODY

did you try it?

Eric N.
indocti discant et ament meminisse periti

RE: STORE/SAVE COLOR ARRAY OF PARTBODY

(OP)
yes, I tried and it worked. Thank you again

Quin

RE: STORE/SAVE COLOR ARRAY OF PARTBODY

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

Eric N.
indocti discant et ament meminisse periti

RE: STORE/SAVE COLOR ARRAY OF PARTBODY

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

RE: STORE/SAVE COLOR ARRAY OF PARTBODY

you might not need

CODE --> vba

Dim R, G, B 

Eric N.
indocti discant et ament meminisse periti

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