Hi,
Recently I had to do something like you wish, so here is the code in CATScript (you can comment some messages to decrease number of clicks). This macro can be used for any feature not only Join.
Sub CATmain ()
CATIA.DisplayFileAlerts = False
' What do you want to select
Dim EnableSelectionFor(0)
EnableSelectionFor(0) = "AnyObject"
' Reset the Selection
Set sSEL = CATIA.ActiveDocument.Selection
sSEL.Clear
' Define Selection
MsgBox "Please Select the FEATURE from which you want to get the color"
UserSelection = sSEL.SelectElement2(EnableSelectionFor, "Please Select the FEATURE from which you want to get the color", False)
' Evaluation if the selection is correct or not
If UserSelection <> "Normal" Then
MsgBox "Error with the selection"
Exit Sub
Else
'//////getting rgb color of a selected feature in the tree
Dim visProperties1 As VisProperty
Set visProperties1 = CATIA.ActiveDocument.Selection.VisProperties
Dim r, g, b
r = CLng(0)
g = CLng(0)
b = CLng(0)
visProperties1.GetRealColor r, g, b
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''#
' What do you want to select
Dim EnableSelectionFor1(0)
EnableSelectionFor1(0) = "AnyObject"
' Reset the Selection
Set sSEL1 = CATIA.ActiveDocument.Selection
sSEL1.Clear
' Define Selection
MsgBox "Please Select now the FEATURE which you want to give same color like previously selected"
UserSelection = sSEL.SelectElement2(EnableSelectionFor1, "Please Select now the FEATURE which you want to give same color like previously selected ", False)
' Evaluation if the selection is correct or not
If UserSelection <> "Normal" Then
MsgBox "Error with the selection"
Exit Sub
Else
'//////getting rgb color of a selected feature in the tree
Dim visProperties2 As VisProperty
Set visProperties2 = CATIA.ActiveDocument.Selection.VisProperties
visProperties2.SetRealColor r,g,b,1
End If
End If
End Sub
Regards
Fernando