VectorDraw常见问题整理:如何使用XProperties链接图层和Vdraw实体对象?

  VectorDraw Developer Framework(VDF)是一个用于应用程序可视化的图形引擎库。有了VDF提供的功能,您可以轻松地创建、编辑、管理、输出、输入和打印2D和3D图形文件。   


 问:

    如何使用XProperty链接图层和Vdraw实体对象?我想在特定图层中引用多个vdraw实体,并在多个图层中引用特定vdraw实体。

答:

    您是拥有一些图层和一些vdText对象的。在图层内,您可以设置XProperties文本的句柄ID。因此,您的图层具有一个或多个Text对象的handle ID。因此,您需要通过存储在图层中的handle ID值来获取这些文本,但是您还想获取包含特定图层的handle ID值的图层。

VB .net

    要从图层的xproperties获取对象,请执行以下操作:

'In this example we are using the documen't active layer.
Dim layer As VectorDraw.Professional.vdPrimaries.vdLayer = doc.ActiveLayer
Dim id As Integer
If (layer.XProperties.Count > 0) Then
    Integer.TryParse(layer.XProperties(0).PropValue, id)
    Dim handle As VectorDraw.Professional.vdObjects.vdHandle = New VectorDraw.Professional.vdObjects.vdHandle(Convert.ToUInt64(id))
    Dim text As VectorDraw.Professional.vdFigures.vdText = doc.FindFromHandle(handle, GetType(VectorDraw.Professional.vdFigures.vdText))
    'After this line, you may want to check if text is a valide object.
    MessageBox.Show("obtained text with the value: " + text.TextString)
End If
To get all the layers “referencing” a specific text object:Dim text As New VectorDraw.Professional.vdFigures.vdText
Dim pickedPoint As New VectorDraw.Geometry.gPoint
doc.ActionUtility.getUserEntity(text, pickedPoint, VectorDraw.Professional.vdObjects.vdDocument.LockLayerMethodEnum.Default)
Dim layerArr As New VectorDraw.Generics.vdArray(Of VectorDraw.Professional.vdPrimaries.vdLayer)
For Each layerObj In doc.Layers
    Dim layer As VectorDraw.Professional.vdPrimaries.vdLayer = layerObj
    For Each xpropObj In layer.XProperties
        Dim xproperty As VectorDraw.Professional.vdObjects.vdXProperty = xpropObj
        If (String.Compare(xproperty.PropValue, text.Handle.ToString()) = 0) Then
            layerArr.AddItem(layer)
        End If
    Next
Next
MessageBox.Show(layerArr.Count.ToString() + " layers linked to this text object.")
In the code XPropeties are assumed to be String values.

    对于以上问答,如果您有任何的疑惑都可以在评论区留言,我们会及时回复。此系列的问答教程我们会持续更新,如果您感兴趣,可以多多关注本教程。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章