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.
對於以上問答,如果您有任何的疑惑都可以在評論區留言,我們會及時回覆。此係列的問答教程我們會持續更新,如果您感興趣,可以多多關注本教程。