我以前没有将扩展数据附着到块,因为我总是将其添加到块参照中。
但现在我发现,如果将它添加到现有的块定义中,它会自动成为acad设计中心数据的一部分。
这里有几个例子来展示它。
如果运行第一个,您将得到预期的(和想要的)结果
1001您的
1000 CCCC
第二个debug . prints
1001 ACAD
1000设计中心数据
1002 {
1070 1
1070 1
1002 }
1001您的
1000 CCCC
- Sub MakeBlockwithXdata()
- Dim oBlock As AcadBlock
- Dim Zero(2) As Double
- Set oBlock = ThisDrawing.Blocks.Add(Zero, "L")
- oBlock.AddCircle Zero, 4
- Dim DataType(1) As Integer
- Dim Data(1) As Variant
- DataType(0) = 1001: Data(0) = "Yours"
- DataType(1) = 1000: Data(1) = "CCCC"
- oBlock.SetXData DataType, Data
- getxd "L"
-
- End Sub
- Sub AddXdatatoBlock()
- Dim oBlock As AcadBlock, P
- Dim br As AcadBlockReference
- ThisDrawing.Utility.GetEntity br, P, "Pick"
- Set oBlock = ThisDrawing.Blocks(br.Name)
- Dim DataType(1) As Integer
- Dim Data(1) As Variant
- DataType(0) = 1001: Data(0) = "Yours"
- DataType(1) = 1000: Data(1) = "CCCC"
- oBlock.SetXData DataType, Data
- getxd oBlock.Name
-
- End Sub
- Function getxd(sBlock As String)
- Dim oBlock As AcadBlock
- Set oBlock = ThisDrawing.Blocks(sBlock)
- Dim sMt As String
- Dim xdataOut As Variant
- Dim xtypeOut As Variant
- Dim i As Integer
-
- Debug.Print
- oBlock.GetXData "", xtypeOut, xdataOut
- If IsEmpty(xtypeOut) = False Then
- For i = 0 To UBound(xtypeOut)
- Debug.Print xtypeOut(i), xdataOut(i)
- Next
- End If
-
- End Function
本帖以下内容被隐藏保护;需要你回复后,才能看到! 游客,如果您要查看本帖隐藏内容请 回复 |