谢谢塔瓦。我将有一个看了一会儿,但在此期间,我将使用下面的VBA一个我刚刚放在一起。
我不确定我会让它工作,所以我没有回来报告。我没有错误捕捉,所以它离理想状态很远。
我希望我没有浪费你太多时间。
- Option Explicit
- Public Sub PickSourceItem()
- Dim myAttributes As Variant
- Dim myObject As AcadObject
- Dim P1 As Variant
- Dim myName As String
- Dim myText As AcadText
- Dim layerColl As AcadLayers
- Dim CloudLayer As AcadLayer
- On Error Resume Next
- ThisDrawing.Utility.GetEntity myObject, P1, "Select Block"
- If Err <> 0 Then
- Err.Clear
- MsgBox "No Object Selected"
- Exit Sub
- End If
- If myObject.EntityName = "AcDbBlockReference" Then
- myAttributes = myObject.GetAttributes
- myName = myAttributes(0).TextString & " LAN A"
-
- ThisDrawing.Utility.GetEntity myObject, P1, "Select Block"
- If myObject.EntityName = "AcDbBlockReference" Then
- myAttributes = myObject.GetAttributes
- myAttributes(0).TextString = myName
- End If
-
- Else
- MsgBox "Block not selected"
- End If
- End Sub
|