change color surfaces
change color surfaces
(OP)
hello
I need to change the tangent surfaces only selecting only one surface, I wrote this macro but doesn't work fine, it shows me all surfaces selected but doesen't change the color on the screen!!
someone can help me?
Thanks

Sub CATMain()
Dim InputObjectType(0)
Set Document = CATIA.ActiveDocument
Set Selection = Document.Selection
Dim prtPart As Part
Set prtPart = CATIA.ActiveDocument.Part
Dim oHSF As HybridShapeFactory
Set oHSF = prtPart.HybridShapeFactory
InputObjectType(0) = "Face"
Status = Selection.SelectElement2(InputObjectType, "Select a face", True)
If (Status = "cancel") Then Exit Sub
Set FirstFace = Selection.Item(1).Value
Selection.Clear
Dim newelement1 As HybridShapeExtract
Set newelement1 = oHSF.AddNewExtract(FirstFace)
newelement1.PropagationType = 2
newelement1.ComplementaryExtract = False
newelement1.IsFederated = False
prtPart.UpdateObject newelement1
Selection.Add newelement1
Set visPropertySet1 = Selection.VisProperties
visPropertySet1.SetRealColor 255, 0, 0, 0
Selection3 = Clear
End Sub
I need to change the tangent surfaces only selecting only one surface, I wrote this macro but doesn't work fine, it shows me all surfaces selected but doesen't change the color on the screen!!
someone can help me?
Thanks

Sub CATMain()
Dim InputObjectType(0)
Set Document = CATIA.ActiveDocument
Set Selection = Document.Selection
Dim prtPart As Part
Set prtPart = CATIA.ActiveDocument.Part
Dim oHSF As HybridShapeFactory
Set oHSF = prtPart.HybridShapeFactory
InputObjectType(0) = "Face"
Status = Selection.SelectElement2(InputObjectType, "Select a face", True)
If (Status = "cancel") Then Exit Sub
Set FirstFace = Selection.Item(1).Value
Selection.Clear
Dim newelement1 As HybridShapeExtract
Set newelement1 = oHSF.AddNewExtract(FirstFace)
newelement1.PropagationType = 2
newelement1.ComplementaryExtract = False
newelement1.IsFederated = False
prtPart.UpdateObject newelement1
Selection.Add newelement1
Set visPropertySet1 = Selection.VisProperties
visPropertySet1.SetRealColor 255, 0, 0, 0
Selection3 = Clear
End Sub





RE: change color surfaces
not sure what you want to achieve with
CODE -->
you need to look at your options to do what you want:
or
sew the extract on the solid then color the new solid feature (easiest)
or
get area, Cog of each face (and any other valuable info to identify a face) from the extract and cycle thru the solid to find the same face, then select and change color (the one you really want but might be slow, try to run in batch and see if faster)
maybe someone does have a better idea?
indocti discant et ament meminisse periti
RE: change color surfaces
I'm not an expert in VB code!!! I'm trying to assemble part of code.
RE: change color surfaces
indocti discant et ament meminisse periti
RE: change color surfaces