Here is the second of four articles on Client Graphics. This was originally in a technical paper written by Autodesk Developer Network engineer Xiaodong Liang.

Note: Segment 1 is here

**This zip file has a VB.NET project with the examples discussed in this section.**

**Download ClientGraphics_Segment_2**

**Start of segment 2**

**Graphic Primitives**

*Point*

Point is the simplest graphics object available. You could change the point style such as circular dot, a cross etc, and from Inventor 2011, a Point can be displayed with an image. (This section uses VBA code snippets. In 64 bit using iPictureDisp from out of process is a known limitation. In 64 bit VBA is out of process)

' <code snippet : Point>

Dim oPointCoords(8) As Double

oPointCoords(0) = 0: oPointCoords(1) = 0: oPointCoords(2) = 0

oPointCoords(3) = 0: oPointCoords(4) = 1: oPointCoords(5) = 0

oPointCoords(6) = 1: oPointCoords(7) = 1: oPointCoords(8) = 1

' Create an image set

Dim oImageSet As GraphicsImageSet

Set oImageSet = oDataSets.CreateImageSet(oDataSets.count + 1)

Dim oImage As IPictureDisp

Set oImage = LoadPicture("C:\Temp\MyImage.bmp")

Call oImageSet.Add(1,oImage)

‘add point graphics and assign the data

Call oCoordSet.PutCoordinates(oPointCoords)

Dim oPointGraphics As PointGraphics

Set oPointGraphics = oPointNode.AddPointGraphics oPointGraphics.PointRenderStyle = kFilledCrossPointStyle

oPointGraphics.CoordinateSet = oCoordSet

oPointGraphics.BurnThrough = True

* *

*Line *

These are individual line segments. Line graphics use two coordinates to define a line, and then the next two coordinates to define the next line, and so on through the defined coordinates.

*Line Strip *

These are a connected set of lines. Line strips use the first two coordinates to define the first line and then the last point of the first line becomes the first point of the second line and the next coordinate is used as the end point of the second line. This results in the set of points being connected by a continuous set of lines, drawing a continuous curve. So to define 2 connected lines, just 3 coordinates would be required.

‘<code snippet: Line or LineStrip> Dim oPointCoords(11) As Double ‘create 4 points

oPointCoords(0) = 0: oPointCoords(1) = 0: oPointCoords(2) = 0

oPointCoords(3) = 1: oPointCoords(4) = 1: oPointCoords(5) = 0

oPointCoords(6) = 2: oPointCoords(7) = 0: oPointCoords(8) = 0

oPointCoords(9) = 3: oPointCoords(10) = 1: oPointCoords(11) = 0

Call oCoordSet.PutCoordinates(oPointCoords)

‘Line: every 2 points for 1 Line

Dim oGraphic As LineGraphics

Set oGraphic = oGraphicsNode.AddLineGraphics

‘Line strip: totally, 3 lines

‘Dim oGraphic As LineStripGraphics

‘Set oGraphic = oGraphicsNode.AddLineStripGraphics

*Triangle *

These are used to define individual triangles. Each set of three coordinates defines a triangle. The next three coordinates then define the next triangle, and so on through all of the coordinates that are provided.

*Triangle Strip *

These provide a connected set of triangles. The first three coordinates define a triangle and the next coordinate defines another triangle using the previous two coordinates. You could also specify the strip length. This is provided for performance reasons.

‘<code snippet: Triangle or Triangle Strip>

Dim oPointCoords(20) As Double ‘create 7 points,

oPointCoords(0) = 0: oPointCoords(1) = 0: oPointCoords(2) = 0

oPointCoords(3) = 1: oPointCoords(4) = 1: oPointCoords(5) = 0

oPointCoords(6) = 2: oPointCoords(7) = 0: oPointCoords(8) = 0

oPointCoords(9) = 3: oPointCoords(10) = 1: oPointCoords(11) = 0

oPointCoords(12) = 4: oPointCoords(13) = 0: oPointCoords(14) = 0

oPointCoords(15) = 5: oPointCoords(16) = 1: oPointCoords(17) = 0

oPointCoords(15) = 5: oPointCoords(16) = 1: oPointCoords(17) = 0

oPointCoords(18) = 6: oPointCoords(19) = 0: oPointCoords(20) = 0

Call oCoordSet.PutCoordinates(oPointCoords)

‘Triangle: every 3 points for 1 triangle

Dim oGraphic As TriangleGraphics

Set oGraphic = oGraphicsNode.AddTriangleGraphics

‘or Triangle Strip: totally 5 triangles

‘Dim oGraphic As TriangleStripGraphics

‘Set oGraphic = oGraphicsNode.AddTriangleStripGraphics

oGraphic.CoordinateSet = oCoordSet

**Graphics**

*Triangle Fan *

This defines a set of connected triangles. The first coordinate is shared in all triangles. The first three coordinates define a triangle. And the next coordinate defines another triangle using the previous coordinates: one of which is the first coordinate. If all the coordinates surround the first point, then the resulting graphics looks like a fan. Again this facility is provided primarily for performance reasons.

* *

*TextGraphics*

‘<code snippet: Text>

Dim oTG As TransientGeometry

Set oTG = ThisApplication.TransientGeometry

Dim oTextGraphics As TextGraphics

Set oTextGraphics = oNode.AddTextGraphics

oTextGraphics.Text = Text

oTextGraphics.Anchor = oPosition

oTextGraphics.Bold = True

oTextGraphics.Font = "Arial"

oTextGraphics.FontSize = 40

oTextGraphics.HorizontalAlignment = kAlignTextLeft

oTextGraphics.Italic = True

Call oTextGraphics.PutTextColor(0, 255, 0)

*Curve *

Curves include the following objects: LineSegment, Circle, Arc3d, EllipseFull, EllipticalArc and BSplineCurve. The object TransientGeometry is used to create the geometry and client graphics then uses this geometry as input. You can also use the geometry from a model’s native data too.

‘<code snippet: Curve>

Dim oTG As TransientGeometry

Set oTG = ThisApplication.TransientGeometry

Dim oCircle As Inventor.Circle

Set oCircle = oTG.CreateCircle(oTG.CreatePoint(0, 0, 0),

oTG.CreateUnitVector(0, 0, 1), 5#)

Dim oGraphic As CurveGraphics

Set oGraphic = oGraphicsNode.AddCurveGraphics(oCircle)

*Surface *

TransientBrep is used to create the underlying geometry data, and client graphics objects then use this geometry. Again you can use the model’s native data: face, faces or face collection too.

‘<code snippet: Surface>

Dim oTransientBRep As TransientBRep

Set oTransientBRep = ThisApplication.TransientBRep

Dim oTG As TransientGeometry

Set oTG = ThisApplication.TransientGeometry

Dim oBody As SurfaceBody

Set oBody = oTransientBRep.CreateSolidCylinderCone _

(oTG.CreatePoint(0, 0, 0), _

oTG.CreatePoint(0, 10, 0), _

5, 5, 0) Dim oSurfaceGraphics As SurfaceGraphics

Set oSurfaceGraphics = oSurfacesNode. _

AddSurfaceGraphics(oBody)

End of Segment 2

-Wayne