Cancel
Showing results for 
Search instead for 
Did you mean: 

Solid Edge Face Colors

Creator
Creator

Hi ,

i want know if exist a way (with a macro) to know the color of a face for an imported model with no facestyle.

 

Thanks

8 REPLIES 8

Re: Solid Edge Face Colors

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

Hi @Gennaro 

  

face.GetRGBAVals() is the closest that you can get to the facestyle on natively created faces.

A macro can be written if you need.

  

Regards,

Tushar

www.SurfAndCode.IN

Re: Solid Edge Face Colors

Creator
Creator
Hi Tushar,
I'm using solid Edge 2019 and this method not exist. Is There an alternative way?
Thanks

Re: Solid Edge Face Colors

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

Here's the code I used to check:

 

Imports System.Runtime.InteropServices
Imports SolidEdgeFramework

Module Module1

    Sub Main()

        Dim application As SolidEdgeFramework.Application = Nothing
        Dim partDocument As SolidEdgePart.PartDocument = Nothing
        Dim models As SolidEdgePart.Models = Nothing
        Dim model As SolidEdgePart.Model = Nothing
        Dim body As SolidEdgeGeometry.Body = Nothing
        Dim faces As SolidEdgeGeometry.Faces = Nothing
        Dim face As SolidEdgeGeometry.Face = Nothing

        Try
            ' Attempt to connect to a running instance of Solid Edge.
            application = DirectCast(Marshal.GetActiveObject("SolidEdge.Application"), SolidEdgeFramework.Application)
            partDocument = TryCast(application.ActiveDocument, SolidEdgePart.PartDocument)

            If partDocument IsNot Nothing Then
                models = partDocument.Models
                model = models.Item(1)
                body = CType(model.Body, SolidEdgeGeometry.Body)

                Dim FaceType = SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll
                faces = CType(body.Faces(FaceType), SolidEdgeGeometry.Faces)

                Dim st1 As FaceStyle = Nothing
                Dim dR As Double, dG As Double, dB As Double, dA As Double

                For i As Integer = 1 To faces.Count
                    face = CType(faces.Item(i), SolidEdgeGeometry.Face)
                    st1 = face.Style
                    face.GetRGBAVals(dR, dG, dB, dA)
                    Debug.Print("{" + dR.ToString + ", " + dG.ToString + ", " + dB.ToString + "}")
                Next i
            End If
        Catch ex As System.Exception
            Console.WriteLine(ex)
        End Try
    End Sub

End Module

Re: Solid Edge Face Colors

Creator
Creator

Hi Tushar,

thank you so much for your help.

I Solved .

 

Gennaro

Re: Solid Edge Face Colors

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

Hi @Gennaro 

 

Do you mean you solved on your own  - in that case, can you kindly share how?

If it was my post that solved the issue, kindly mark my post as "Accepted Solutions" for future reference.

 

Thank you.

~Tushar

Re: Solid Edge Face Colors

Creator
Creator

Hi All,

I would like to be able to do the same thing in catia v5 (loops through model,body, faces...), but despite my research I did not find anything, so I ask you for help once again. 

can anyone help me?

thanks

Highlighted

Re: Solid Edge Face Colors

Valued Contributor
Valued Contributor

Gennaro, are you asking how to use CATIA in a Solid Edge forum?  What you ask is probably available in the VBA programming for CATIA.  (If not that then the C++ extension mechanism would definitely have it, but that's a little involved for a simple thing like finding colors.)  Yet that's a little beyond the scope of discussion here.

------------------
Alan Baljeu
Owner, Cornerstone Intelligent Software
Developer of custom CAD software

Re: Solid Edge Face Colors

Creator
Creator

you are right, but I didn't find anything onthe web and I thought that someone with more experience than me could help me.
Sorry