Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Drawing Client Graphics?

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
gerrardhickson
223 Views, 2 Replies

Drawing Client Graphics?

Hi all,

 

I had an idea I wanted to explore to help with a special case of sketched symbols (think dynamic sketched symbols). I wanted to allow the user to select 2 or more points, use client graphics to draw a preview of the sketched symbol, then on confirmation from the user - create the actual sketched symbol.

However, I didn't make it far - it seems there is no client graphics object for drawings.

So, my question is this - when you move a text box, or drag a table column, those objects are temporarily replaced by a rectangle, then, when you release the cursor, the object re-appears in its new location or size.

 

Is this functionality available to the API under a different object name or is there another work around that might help in this case?

 

Regards

2 REPLIES 2
Message 2 of 3

You might want to have a look at this help example. I translated it to iLogic/vb.net. Have a look at the code it sort of works in a drawing.

JelteDeJong_0-1666213696934.png

 

Dim oDoc As Document = ThisDoc.Document

Dim oIE = ThisApplication.CommandManager.CreateInteractionEvents
oIE.Start()

Dim oIG As InteractionGraphics = oIE.InteractionGraphics

Dim oDataSets As GraphicsDataSets = oIG.GraphicsDataSets

' Set a reference to the transient geometry object for use later.
Dim oTransGeom As TransientGeometry = ThisApplication.TransientGeometry

' Create a coordinate set.
Dim oCoordSet As GraphicsCoordinateSet = oDataSets.CreateCoordinateSet(1)

' Create an array that contains coordinates that define a set
' of outwardly spiraling points.
Dim oPointCoords(90) As Double
Dim i As Long
Dim dRadius As Double = 1
Dim dAngle As Double
For i = 0 To 29
	' Define the X, Y, and Z components of the point.
	oPointCoords(i * 3 + 1) = dRadius * Math.Cos(dAngle)
	oPointCoords(i * 3 + 2) = dRadius * Math.Sin(dAngle)
	oPointCoords(i * 3 + 3) = i / 2

	' Increment the angle and radius to create the spiral.
	dRadius = dRadius + 0.25
	dAngle = dAngle + (3.14159265358979 / 6)
Next

' Assign the points into the coordinate set.
oCoordSet.PutCoordinates(oPointCoords)

' Create the ClientGraphics object.
Dim oClientGraphics As ClientGraphics = oIG.OverlayClientGraphics

' Create a new graphics node within the client graphics objects.
Dim oLineNode As GraphicsNode = oClientGraphics.AddNode(1)

' Create a LineGraphics object within the node.
Dim oLineSet As LineGraphics = oLineNode.AddLineGraphics

' Assign the coordinate set to the line graphics.
oLineSet.CoordinateSet = oCoordSet

' Update the view to see the resulting spiral.
oIG.UpdateOverlayGraphics(ThisApplication.ActiveView)

' Create another graphics node for a line strip.
Dim oLineStripNode As GraphicsNode = oClientGraphics.AddNode(2)

' Create a LineStripGraphics object within the new node.
Dim oLineStrip As LineStripGraphics = oLineStripNode.AddLineStripGraphics

' Assign the same coordinate set to the line strip.
oLineStrip.CoordinateSet = oCoordSet

' Create a color set to use in defining a explicit color to the line strip.
Dim oColorSet As GraphicsColorSet = oDataSets.CreateColorSet(1)

' Add a single color to the set that is red.
oColorSet.Add(1, 255, 0, 0)

' Assign the color set to the line strip.
oLineStrip.ColorSet = oColorSet

' The two spirals are currently on top of each other so translate the
' new one in the x direction so they're side by side.
Dim oMatrix As Matrix = oLineStripNode.Transformation
oMatrix.SetTranslation(oTransGeom.CreateVector(15, 0, 0))
oLineStripNode.Transformation = oMatrix

' Update the view to see the resulting spiral.
oIG.UpdateOverlayGraphics(ThisApplication.ActiveView)

'oIE.Stop


MsgBox("See the stuff")

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

Message 3 of 3

That's what I'm looking for - thanks for that!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report