You are currently reviewing an older revision of this page.
A popular tool for querying and modifying element information cal also be controller via VBA:
All data fields that can also be manually changed by the user in this dialog box can also be controlled via VBA with demObjectType PropertyHander. Access to the fields is by the name of the field. In the VBA Help, there are also examples of how to use the Property Brokers. In addition, here is a small example to help the reading out of names of the fields so that you know how to access the fields.
Sub
prophandLine()
Dim
ee
As
ElementEnumerator
oProp
PropertyHandler
found
Boolean
l()
String
val
point
Point3d
Set
ee = ActiveModelReference.GraphicalElementCache.Scan
Do
While
ee.MoveNext
If
ee.Current.Type = msdElementTypeLine
Then
oProp = CreatePropertyHandler(ee.Current)
' All out by name:
l = oProp.GetAccessStrings
found =
False
For
i = LBound(l)
To
UBound(l)
Debug.Print l(i)
' Lists all names in the VBA EDitor
l(i) =
"Segments[0].Start"
True
Next
' Value read amd changed if present:
oProp.SelectByAccessString (
)
point = oProp.GetValueAsPoint3d
point.x = point.x + 1
point.y = point.y - 1
oProp.SetValueAsPoint3d point
End
Loop
In the example, all the graphic elements of the active model are first of all read and checked individually. Only lines are to be further investigated. For each line, a PropertyHandler is created with the information of this line.
About the statement:
It then reads all access names and then checked to see whether a field of "segment [0] .Start" is.
If so, we have then found the origin of the line. This is written for test purposes and is slightly changed (x + 1, y - 1) and back again so that all the starting points of all lines were changed by the end.
See Also
Placing annotation cells with VBA