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 Dim oProp As PropertyHandler Dim found As Boolean Dim l() As String Dim val As String Dim point As Point3d Set ee = ActiveModelReference.GraphicalElementCache.Scan Do While ee.MoveNext If ee.Current.Type = msdElementTypeLine Then Set 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 If l(i) = "Segments[0].Start" Then found = True Next ' Value read amd changed if present: If found Then oProp.SelectByAccessString ("Segments[0].Start") point = oProp.GetValueAsPoint3d point.x = point.x + 1 point.y = point.y - 1 oProp.SetValueAsPoint3d point End If End If Loop End Sub
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:
l = oProp.GetAccessStrings
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