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!

change color surfaces

Status
Not open for further replies.

MINIMO4

Automotive
Nov 26, 2016
3
IT
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


Cattura_nxalel.jpg

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
 
Replies continue below

Recommended for you

you script change the color of a new GSD element HybridShapeExtract. This does not change the solid in any way.

not sure what you want to achieve with
Code:
Selection3 = Clear

you need to look at your options to do what you want:

check the B-Rep definition of the extract to find the face of the solid (hard to code, not sure if possible)
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?



Eric N.
indocti discant et ament meminisse periti
 
I need to change color in a mould ( solid body) to differentiate the matching surfaces to part surfaces without manually select.
I'm not an expert in VB code!!! I'm trying to assemble part of code.
 
i know that in Core and Cavity you have Face Color Editor, a function that will just do what you need. you select one face, it does propagate in tangency then you pick a color. Check online doc.

Eric N.
indocti discant et ament meminisse periti
 
Yes! I know that fuction, unfortunately I don't have Core and cavity in my catia!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top