<?xml encoding=”UTF-8″>By Adam Nagy
When you create client graphics, you can also specify in which view they will be visible via the GraphicsNode.VisibleInViews collection.
Here is a VBA sample that creates view specific graphics in each view window:
Sub DisplayGraphicsInViewSample()
ThisApplication.Documents.CloseAll
Dim oDoc As PartDocument
Set oDoc = ThisApplication.Documents.Add(kPartDocumentObject)
oDoc.Views.Add
Dim oRangeViews As ControlDefinition
Set oRangeViews = ThisApplication.CommandManager.ControlDefinitions( _
"AppArrangeAllWindowsCmd")
oRangeViews.Execute
Dim oCG As ClientGraphics
Set oCG = oDoc.ComponentDefinition.ClientGraphicsCollection.Add( _
"ClientGraphics")
' graphics in this node will be displayed in the first View
Dim oNode1 As GraphicsNode
Set oNode1 = oCG.AddNode(1)
oNode1.VisibleInViews.Add oDoc.Views(1)
Dim oText1 As TextGraphics
Set oText1 = oNode1.AddTextGraphics
oText1.Text = oDoc.Views(1).Caption
oText1.PutTextColor 255, 0, 0
' graphics in this node will be displayed in the second View
Dim oNode2 As GraphicsNode
Set oNode2 = oCG.AddNode(2)
oNode2.VisibleInViews.Add oDoc.Views(2)
Dim oText2 As TextGraphics
Set oText2 = oNode2.AddTextGraphics
oText2.Text = oDoc.Views(2).Caption
oText2.PutTextColor 0, 255, 0
' update views
oDoc.Views(1).Update
oDoc.Views(2).Update
End Sub
The result:


Leave a Reply