- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have created a macro with a preview function. It lets the user select an occurrence in an assembly and then displays a form to get some user input. Based on this input, some preview graphics are shown. The preview function uses "normal" ClientGraphics. It adds a few GraphicNodes, adds ComponentGraphics to them, and positions and colors each node. It works, but the adding and positioning of the nodes fills up the undo stack, which I don't want.
So I rewrote the function to use InteractionGraphics. It works with one exception: the nodes are not being colored.
Please find below an excerpt of the code, which adds the nodes, graphics and should set the color.
The only changes between my old and new code are the declaration and assigning of oIE, oIG and oClientGraphics.
Does anyone have a solution?
'-=- Add Preview Items ------------------------------------------------
'Check if the InteractionEvents object was already running. If so, stop and clear it.
If Not oIE Is Nothing Then
oIE.Stop
Set oIE = Nothing
End If
'Set reference to the InteractionEvents object (object has been globally declared)
Set oIE = ThisApplication.CommandManager.CreateInteractionEvents
oIE.Start
'Set reference to the InteractionGraphics object (obtained from InteractionEvents object)
Dim oIG As InteractionGraphics
Set oIG = oIE.InteractionGraphics
'Create new client graphics object from the graphics owner (InteractionGraphics object)
Dim oClientGraphics As ClientGraphics
Set oClientGraphics = oIG.OverlayClientGraphics
'Set reference to componentdefinition of to-be-previewed item
Dim oDef As ComponentDefinition
Set oDef = oSourceOcc.Definition
'Create the preview item color
Dim oColor As Color
Set oColor = ThisApplication.TransientObjects.CreateColor(255, 128, 0)
oColor.Opacity = 0.2
'Declarations
Dim oNode As GraphicsNode
Dim oComponentGraphics As ComponentGraphics
'Add the preview items
For i = 1 To 3
'Add a graphics node to the client graphics object
Set oNode = oClientGraphics.AddNode(i)
'Set node properties
oNode.Selectable = False
oNode.Visible = True
'Add graphic primitives (component graphics) to the node based on referenced componentdefinition
Set oComponentGraphics = oNode.AddComponentGraphics(oDef)
'Set the graphic primitives / component graphic color
oComponentGraphics.Color = oColor
Next i
'-=- End of Add Preview Items -----------------------------------------
<Some code positioning the nodes>
'Update the display
oIG.UpdateOverlayGraphics ThisApplication.ActiveView
Solved! Go to Solution.