名前で指定されたテンプレートに基づいて、挿入点、尺度、回転を指定して、Shape 図形を作成します。
サポートされているプラットフォーム: Windows のみ
VBA:
RetVal = object.AddShape(Name, InsertionPoint, ScaleFactor, Rotation)
タイプ: Block、ModelSpace、PaperSpace
このメソッドが適用されるオブジェクト。
アクセス: 入力のみ
タイプ: 文字列
挿入するシェイプの名前。
アクセス: 入力のみ
タイプ: バリアント型(3 要素の倍精度浮動小数点数型配列)
シェイプの挿入位置を示す 3D WCS 座標。
アクセス: 入力のみ
タイプ: 倍精度浮動小数点数型
シェイプに適用される尺度係数。指定しない場合は 1.0 を使用します。正の数値でなければなりません。
アクセス: 入力のみ
タイプ: 倍精度浮動小数点数型
シェイプに適用される回転角度(ラジアン)。
タイプ: Shape
新しく作成される Shape オブジェクト。
シェイプを挿入する前に、LoadShapeFile メソッドを使用して、挿入するシェイプが入っているファイルをロードする必要があります。
VBA:
Sub Example_AddShape()
' This example creates a BAT shape from the ltypeshp.shx file.
' Load the shape file containing the shape you wish to create.
' Note: Replace the ltypeshp.shx file name
' with a valid shape file for your system.
On Error GoTo ERRORHANDLER
ThisDrawing.LoadShapeFile ("C:/Program Files/AutoCAD/Support/ltypeshp.shx")
Dim shapeObj As AcadShape
Dim shapeName As String
Dim insertionPoint(0 To 2) As Double
Dim scalefactor As Double
Dim rotation As Double
' "diode" is defined in es.shx file
shapeName = "BAT"
insertionPoint(0) = 2#: insertionPoint(1) = 2#: insertionPoint(2) = 0#
scalefactor = 1#
rotation = 0# ' Radians
' Create the diode shape object in model space
Set shapeObj = ThisDrawing.ModelSpace.AddShape(shapeName, insertionPoint, scalefactor, rotation)
Exit Sub
ERRORHANDLER:
MsgBox "Cannot find the shape file.", , "AddShape Example"
End Sub
Visual LISP:
(vl-load-com)
(defun c:Example_AddShape()
;; This example creates a BAT shape from the ltypeshp.shx file.
(setq acadObj (vlax-get-acad-object))
(setq doc (vla-get-ActiveDocument acadObj))
;; Load the shape file containing the shape you wish to create.
;; Note: Replace the ltypeshp.shx file name
;; with a valid shape file for your system.
(setq shapeFile ".\\ltypeshp.shx")
(if (/= (findfile shapeFile) nil)
(progn
(vla-LoadShapeFile doc (findfile shapeFile))
;; "diode" is defined in es.shx file
(setq insertionPoint (vlax-3d-point 2 2 0)
shapeName "BAT"
scalefactor 1
rotation 0) ;; Radians
;; Create the diode shape object in model space
(setq modelSpace (vla-get-ModelSpace doc))
(setq shapeObj (vla-AddShape modelSpace shapeName insertionPoint scalefactor rotation))
)
(alert "Cannot find the shape file.")
)
)