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

Posted at

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

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

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

  ' 終了
  Exit Function

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

  ' Nothing を格納
  Set uFnGetBlockByName = Nothing

  ' 警告を表示して終了
  Dim uPrompt     As String
  uPrompt = "'" & aBlockName & "' という名前のブロック定義はありません。"
  MsgBox Title:="AutoCAD VBA", Prompt:=uPrompt, 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?