0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AutoCAD VBA 指定名のブロック定義を取得するFunction

0
Last updated at Posted at 2025-04-17

指定名のブロック定義を取得する

構文  : RetVal = zfGetBlockByName( aoDoc, aBlockName )
引数1 : 図面          | aoDoc      As AcadDocument
引数2 : ブロック定義名 | aBlockName As String
戻り値: ブロック定義   | RetVal     As AcadBlock
備考  : 指定名のブロック定義が存在しなかった場合、Nothing を返す
AutoCAD VBA
Public Function zfGetBlockByName(ByVal aoDoc As AcadDocument _
                          , ByVal aBlockName As String _
                                           ) As AcadBlock
  ' 指定名のブロック定義が存在しなかったらエラールーチンへ
  On Error GoTo EH

  ' 指定名のブロックを取得
  Set zfGetBlockByName = aoDoc.Blocks.Item(aBlockName)

  ' 終了
  Exit Function

EH:
  ' エラーをクリア
  Err.Clear

  ' Nothing を格納
  Set zfGetBlockByName = Nothing

  ' 警告を表示して終了
  Dim vMes As String
  vMes = "'" & aBlockName & "' という名前のブロック定義はありません。"
  MsgBox Title:="AutoCAD VBA", Prompt:=vMes, Buttons:=vbExclamation

End Function
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?