> Андрей
Ага, нашел наконец...
Option Explicit
Function IsBlockExist(bName As String) As Boolean
Dim oBlock As AcadBlock
IsBlockExist = False
On Error Resume Next
For Each oBlock In ThisDrawing.Blocks
If StrComp(oBlock.Name, bName, vbTextCompare) = 0 Then
IsBlockExist = True
End If
Next
End Function
Public Sub AddCommentsToBlock(bName As String, descStr As String)
Dim oBlock As AcadBlock
On Error GoTo Exit_Control
If IsBlockExist(bName) = True Then
Set oBlock = ThisDrawing.Blocks(bName)
oBlock.Comments = descStr
ThisDrawing.Regen acAllViewports
Else
MsgBox "Block " & bName & " does not exist"
End If
Exit_Here:
Exit Sub
Exit_Control:
MsgBox Err.Description
Resume Exit_Here
End Sub
Sub AddDescriptionTest()
Dim oEnt As AcadEntity
Dim varPt
Dim oBlkRef As AcadBlockReference
Dim oBlock As AcadBlock
Dim bName As String
Dim descStr As String
On Error GoTo Exit_Control
ThisDrawing.Utility.GetEntity oEnt, varPt, vbCrLf & "Select the block instance >>"
If oEnt Is Nothing Then
MsgBox "0 selected, try again"
Exit Sub
End If
If Not TypeOf oEnt Is AcadBlockReference Then
MsgBox "Selected entity is not a block reference. Error"
Exit Sub
End If
Set oBlkRef = oEnt
If oBlkRef.IsDynamicBlock Then
bName = oBlkRef.EffectiveName
Else
bName = oBlkRef.Name
End If
descStr = InputBox(vbCrLf & "The block description is follows here:", "Add Comments Example", "Bolt M10 is the best bolt around the World! But my bolt is too short")
Call AddCommentsToBlock(bName, descStr)
Exit_Here:
ThisDrawing.Regen acAllViewports
Exit Sub
Exit_Control:
MsgBox Err.Description
Resume Exit_Here
End Sub
~'J'~