<?xml encoding=”UTF-8″>By Adam Nagy
As mentioned here, you can create TransientBRep objects and then use them for ClientGraphics. This makes it easy to create 3D shapes, e.g. cylinders and cones, that we could use to create a 3D arrow.
The Inventor API Help already contains a VBA sample that does just that :)
Public Sub ClientGraphics3DPrimitives()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
' Set a reference to component definition of the active document.
' This assumes that a part or assembly document is active
Dim oCompDef As ComponentDefinition
Set oCompDef = ThisApplication.ActiveDocument.ComponentDefinition
' Check to see if the test graphics data object already exists.
' If it does clean up by removing all associated of the client
' graphics from the document. If it doesn't create it
On Error Resume Next
Dim oClientGraphics As ClientGraphics
Set oClientGraphics = _
oCompDef.ClientGraphicsCollection.Item("Sample3DGraphicsID")
If Err.Number = 0 Then
On Error GoTo 0
' An existing client graphics object was successfully
' obtained so clean up
oClientGraphics.Delete
' Update the display to see the results
ThisApplication.ActiveView.Update
Else
Err.Clear
On Error GoTo 0
' Set a reference to the transient geometry object
' for user later
Dim oTransGeom As transientGeometry
Set oTransGeom = ThisApplication.transientGeometry
' Create the ClientGraphics object.
Set oClientGraphics = _
oCompDef.ClientGraphicsCollection.Add("Sample3DGraphicsID")
' Create a new graphics node within the client graphics objects
Dim oSurfacesNode As GraphicsNode
Set oSurfacesNode = oClientGraphics.AddNode(1)
Dim oTransientBRep As TransientBRep
Set oTransientBRep = ThisApplication.TransientBRep
' Create a point representing the center of the bottom of
' the cone
Dim oBottom As Point
Set oBottom = _
ThisApplication.transientGeometry.CreatePoint(0, 0, 0)
' Create a point representing the tip of the cone
Dim oTop As Point
Set oTop = _
ThisApplication.transientGeometry.CreatePoint(0, 10, 0)
' Create a transient cone body
Dim oBody As SurfaceBody
Set oBody = oTransientBRep.CreateSolidCylinderCone( _
oBottom, oTop, 5, 5, 0)
' Reset the top point indicating the center of the top of
' the cylinder
Set oTop = ThisApplication.transientGeometry.CreatePoint( _
0, -40, 0)
' Create a transient cylinder body
Dim oCylBody As SurfaceBody
Set oCylBody = oTransientBRep.CreateSolidCylinderCone( _
oBottom, oTop, 2.5, 2.5, 2.5)
' Union the cone and cylinder bodies
Call oTransientBRep.DoBoolean( _
oBody, oCylBody, kBooleanTypeUnion)
' Create client graphics based on the transient body
Dim oSurfaceGraphics As SurfaceGraphics
Set oSurfaceGraphics = oSurfacesNode.AddSurfaceGraphics(oBody)
' Update the view to see the resulting curves
ThisApplication.ActiveView.Update
End If
End Sub
The result:


Leave a Reply