ZORANCRO 发表于 2022-7-6 22:26:52

在Autocad中选择“块”,然后重新选择

我的问题是如何在modelspace中选择Acadblock并在him中读取en属性。我有一个带属性的meny块,一个属性是表示Z坐标的文本(Z坐标=0,00)。我习惯用val(属性文本)更改Acadblock的Z坐标。帮助我!
 
布莱恩,谢谢!我想选择块的全局集。

bsamc2000 发表于 2022-7-6 22:44:00

 
您想要选择单个块还是全局块集?
 
布瑞恩

bsamc2000 发表于 2022-7-6 22:45:34

你可以试试这个。它用于选择单个块,然后使用“Z”标记更改属性值。
 
我希望这对你有所帮助。
 
布瑞恩
 

Private Sub Change_it()
   Dim obj As AcadBlockReference
   Dim inspt As Variant

   ThisDrawing.Utility.GetEntity obj, inspt, "Select object:"

   ' Checks if you selected a block.
   If obj.ObjectName = "AcDbBlockReference" Then

       ' Check for attributes.
       If obj.HasAttributes Then

         Dim AttList As Variant

         ' Build a list of attributes for the current block.
         AttList = obj.GetAttributes

         ' Cycle throught the list of attributes.
         For I = LBound(AttList) To UBound(AttList)

               ' Check for the correct attribute tag.
               If AttList(I).TagString = "Z" Then

                   Dim InputString As String

                   ' Get the new value for the attribute.
                   InputString = ThisDrawing.Utility.GetString(True, "New value for z: ")

                   ' Set the new value for the attribute.
                   AttList(I).TextString = InputString

               End If

         Next

       End If

   Else
       MsgBox "You did not select a block."
   End If
End Sub

ZORANCRO 发表于 2022-7-6 22:58:07

 
 
 
 
布莱恩,谢谢!我不需要选择块的全局集。
 
佐兰

BIGAL 发表于 2022-7-6 23:02:20

这里是另一个版本的相同的事情选择一个块,然后更新属性
 

Public Sub ModifyLabelSTNcoords()
' adds x and y co ords of picked point to labelstn block

Dim objENT As AcadEntity

Dim pt1 As Variant
Dim attribs As Variant

On Error Resume Next
ThisDrawing.Utility.GetEntity objENT, basepnt, "pick Label stn block : "
         attribs = objENT.GetAttributes


pt1 = ThisDrawing.Utility.GetPoint(, " pick stn point")

txtx1 = "E " + CStr(FormatNumber(pt1(0), 3))
TXTY1 = "N " + CStr(FormatNumber(pt1(1), 3))
TXTz1 = "RL " + CStr(FormatNumber(pt1(2), 3))

attribs(2).TextString = txtx1
attribs(2).Update

attribs(3).TextString = TXTY1
attribs(3).Update
attribs(4).TextString = TXTz1
attribs(4).Update

End Sub

Itc 发表于 2022-7-6 23:13:17

如何使用for循环确定块名“Acadblock”,然后更改z属性?

moniz 发表于 2022-7-6 23:25:27

 
 
您可以发布代码更改以选择一组块吗?
 
谢谢

BIGAL 发表于 2022-7-6 23:33:19

若你们对pick满意,那个么只需在上面代码的开头添加循环,然后重复。有些人喜欢J=50。。。。接下来看看上面的代码。一种更智能的方法是检查拾取的对象nil=exit,用J=50替换Else-Msgbox
 
可以选择多个块,这取决于您打算如何一次选择“entities”“W”“C”1等。多个块的问题是,它们都有相同的Z吗?一次选择一整批,然后以某种方式跳转到每一批,这样就可以输入正确的Z,这将很复杂。
页: [1]
查看完整版本: 在Autocad中选择“块”,然后重新选择