How can I color planar surfaces bounded by ClientGraphics Line and Arc entities?

bkhabeer
Explorer
Explorer

How can I color planar surfaces bounded by ClientGraphics Line and Arc entities?

bkhabeer
Explorer
Explorer

Hi,

I create a ClientGraphics of a planar parametric geometry structure made from straight lines and arcs using Inventor ClientGraphics API.
I would like create surfaces enclosed by the closed loops made from those lines and arcs, and then MotorPreviewUsingClientGraphics.pngcolor them by assigning color each created surface.
How can i do it, using SurfaceGraphics for example, without going through creating solidsurfaces with Sketch methods or Part methods.

Below attached picture showing an example of planar geometry drawn with ClientGraphics.

 

Any help and idea is welcomed, thank you in advance.

0 Likes
Reply
256 Views
4 Replies
Replies (4)

CCarreiras
Mentor
Mentor

HI!

 

I'm not sure about what you mean, but...

You have to create the surfaces using Extrude, Patch, Revolve, etc, depending the situation.

In this case, I believe Patch will be the tool to use.

After that, you can assign an appearance (color) to every surface.

 

ccarreiras_0-1662133585769.png

 

CCarreiras

EESignature

0 Likes

bkhabeer
Explorer
Explorer

Hi @CCarreiras,
Thank you for your suggestion.
But what i meant i want to create the surfaces or patches and color them  without using Part Features like Extrude, Patch, Revolve, etc, or Sketch operations. I would like to do it only by using ClientGraphics and SurfaceGraphics if possible.

 

Regards,

Taieb

0 Likes

JelteDeJong
Mentor
Mentor

Have a look at the following example, which I have taken from my blog. It creates a label like this.

JelteDeJong_0-1662142548025.png

In the function: "Label.New(doc As Document, name As String, point1 As Point, vector As UnitVector)" I create a red cone-shaped SurfaceBody (and text and a line) using ClientGraphics. 

Public Class ThisRule

    Sub Main()

        Dim orign As Point = ThisApplication.TransientGeometry.CreatePoint(0, 0, 0)
        Dim direction As UnitVector = ThisApplication.TransientGeometry.CreateUnitVector(1, 0, 0)


        Dim l1 As New Label(ThisDoc.Document, "www.hjalte.nl", orign, direction)

    End Sub


End Class

Public Class Label

    Private oClientGraphics As ClientGraphics
    Private oDataSets As GraphicsDataSets
    Private ThisApplication As Inventor.Application
    Private name As String
    Private orign As Point

    Public Sub New(doc As Document, name As String, point1 As Point, vector As UnitVector)

        Me.ThisApplication = doc.Parent
        Dim oTg As TransientGeometry = ThisApplication.TransientGeometry
        Dim arrowLength As Double = 0.2
        Dim arrowRadius As Double = 0.05
        Dim labelLength As Double = 2
        Me.name = name
        Me.orign = point1
        Dim point2 = oTg.CreatePoint(vector.X * labelLength + point1.X,
                                    vector.Y * labelLength + point1.Y,
                                    vector.Z * labelLength + point1.Z)
        Dim point3 = oTg.CreatePoint(vector.X * arrowLength + point1.X,
                                    vector.Y * arrowLength + point1.Y,
                                    vector.Z * arrowLength + point1.Z)

        Dim ClientGraphicsName = "hjalte.ClientGraphics-" & name
        Dim GraphicsDataSet = "hjalte.GraphicsDataSet-" & name

        Dim oCompDef As ComponentDefinition = doc.ComponentDefinition

        Try
            oClientGraphics = oCompDef.ClientGraphicsCollection.Add(ClientGraphicsName)
            oDataSets = doc.GraphicsDataSetsCollection.Add(GraphicsDataSet)
        Catch ex As Exception
            oClientGraphics = oCompDef.ClientGraphicsCollection.Item(ClientGraphicsName)
            oDataSets = doc.GraphicsDataSetsCollection.Item(GraphicsDataSet)
            Return
        End Try

        ' Create the cone!
        Dim oSurfacesNode As GraphicsNode = oClientGraphics.AddNode(1)
        Dim oTransientBRep As TransientBRep = ThisApplication.TransientBRep

        Dim oBody As SurfaceBody = oTransientBRep.CreateSolidCylinderCone(point3, point1, arrowRadius, arrowRadius, 0)

        Dim oSurfaceGraphics As SurfaceGraphics = oSurfacesNode.AddSurfaceGraphics(oBody)
        oSurfaceGraphics.Color = ThisApplication.TransientObjects.CreateColor(255, 0, 0)

        'Create text
        Dim textGraphics As TextGraphics = oSurfacesNode.AddTextGraphics()
        textGraphics.Text = name
        textGraphics.Anchor = point2
        textGraphics.HorizontalAlignment = HorizontalTextAlignmentEnum.kAlignTextCenter
        textGraphics.VerticalAlignment = VerticalTextAlignmentEnum.kAlignTextMiddle
        textGraphics.Bold = True
        textGraphics.FontSize = 21
        textGraphics.PutTextColor(0, 0, 255)
        textGraphics.BurnThrough = True
        textGraphics.DepthPriority = -10000000

        'Create line
        Dim LineGraphic As LineGraphics = oSurfacesNode.AddLineGraphics()
        Dim oCoordSet As GraphicsCoordinateSet = oDataSets.CreateCoordinateSet(1)
        oCoordSet.Add(1, point1)
        oCoordSet.Add(2, point2)

        LineGraphic.CoordinateSet = oCoordSet

        Dim oGraphicsColorSet As GraphicsColorSet = oDataSets.CreateColorSet(1)
        oGraphicsColorSet.Add(1, 0, 0, 0)
        oGraphicsColorSet.Add(2, 0, 0, 0)
        LineGraphic.ColorSet = oGraphicsColorSet

        ThisApplication.ActiveView.Update()
    End Sub

End Class

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes

bkhabeer
Explorer
Explorer

@JelteDeJong,

 

First i want to thank you for your great suggestion. It seems to me an interesting idea for me to try out. I'll try it and let you know if it works well for me. In the meantime, I have some concern about the performance in term of speed in the operation of creating SurfaceBody from TransientBrep solids that i have to create from the curves an the lines.

 

Regards,

Taieb

 

0 Likes