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
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
indocti discant et ament meminisse periti
RE: STORE/SAVE COLOR ARRAY OF PARTBODY
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
CODE --> VBA
CODE --> VBA
indocti discant et ament meminisse periti
RE: STORE/SAVE COLOR ARRAY OF PARTBODY
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
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
indocti discant et ament meminisse periti
RE: STORE/SAVE COLOR ARRAY OF PARTBODY
indocti discant et ament meminisse periti
RE: STORE/SAVE COLOR ARRAY OF PARTBODY
Dim rInit As Long
Dim gInit As Long
Dim Init As Long
Quin
RE: STORE/SAVE COLOR ARRAY OF PARTBODY
indocti discant et ament meminisse periti
RE: STORE/SAVE COLOR ARRAY OF PARTBODY
Quin
RE: STORE/SAVE COLOR ARRAY OF PARTBODY
indocti discant et ament meminisse periti
RE: STORE/SAVE COLOR ARRAY OF PARTBODY
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
CODE --> vba
indocti discant et ament meminisse periti