InsertBlock Method (ActiveX)

InsertBlock Method (ActiveX)

http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-17F86FDD-B7FC-4F43-9F16-B4958F73A66D

Object Model (ActiveX)

Click on a class in the image to open its associated topic.

Related Reference

Inserts a drawing file or a named block that has been defined in the current drawing.

Supported platforms: Windows only

Signature

VBA:

RetVal = object.InsertBlock(InsertionPoint, Name [, Xscale [, Yscale [, ZScale [, Rotation [, Password]]]]])

object

Type: BlockModelSpacePaperSpace

The objects this method applies to.

InsertionPoint

Access: Input-only

Type: Variant (three-element array of doubles)

The 3D WCS coordinates specifying the location in the drawing to insert the block.

Name

Access: Input-only

Type: String

The name of the AutoCAD drawing file or the name of the block to insert. If it is a file name, include the .dwg extension and any path information necessary for AutoCAD to find the file.

Xscale

Access: Input-only; optional

Type: Double

The default equals 1.0. Must be a positive number.

Yscale

Access: Input-only; optional

Type: Double

The default equals 1.0. Must be a positive number.

Zscale

Access: Input-only; optional

Type: Double

The default equals 1.0. Must be a positive number.

Rotation

Access: Input-only; optional

Type: Double

The default equals 0.0 radians.

Password

Access: Input-only; optional

Type: Variant

The password that was applied to the drawing file when it was saved.

Return Value (RetVal)

Type: BlockReference

The placed block as a Block Reference object.

Remarks

Inserting a block into another block will create nested blocks.

Attempting to call the InsertBlock method with an uninitialized Name parameter results in unexpected behavior.

Examples

VBA:

Sub Example_InsertBlock()
    ' This example creates a block containing a circle.
    ' It then inserts the block.

    ' Create the block
    Dim blockObj As AcadBlock
    Dim insertionPnt(0 To 2) As Double
    insertionPnt(0) = 0#: insertionPnt(1) = 0#: insertionPnt(2) = 0#
    Set blockObj = ThisDrawing.Blocks.Add(insertionPnt, "CircleBlock")
    
    ' Add a circle to the block
    Dim circleObj As AcadCircle
    Dim center(0 To 2) As Double
    Dim radius As Double
    center(0) = 0: center(1) = 0: center(2) = 0
    radius = 1
    Set circleObj = blockObj.AddCircle(center, radius)
   
    ' Insert the block
    Dim blockRefObj As AcadBlockReference
    insertionPnt(0) = 2#: insertionPnt(1) = 2#: insertionPnt(2) = 0
    Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, "CircleBlock", 1#, 1#, 1#, 0)
    
    ZoomAll
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_InsertBlock()
    ;; This example creates a block containing a circle.
    ;; It then inserts the block.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    ;; Create the block
    (setq insertionPnt (vlax-3d-point 0 0 0))
    (setq blockObj (vla-Add (vla-get-Blocks doc) insertionPnt "CircleBlock"))
    
    ;; Add a circle to the block
    (setq center (vlax-3d-point 0 0 0)
          radius 1)
    (setq circleObj (vla-AddCircle blockObj center radius))
   
    ;; Insert the block
    (setq insertionPnt (vlax-3d-point 2 2 0))
    (setq modelSpace (vla-get-ModelSpace doc))
    (setq blockRefObj (vla-InsertBlock modelSpace insertionPnt "CircleBlock" 1 1 1 0))
    
    (vla-ZoomAll acadObj)
)

-INSERT(命令)

涵盖的产品和版本 

作者: 

Help

2018 年 7 月 26 日产品内视图 

分享

添加到集合

将块或图形插入当前图形中。

将显示以下提示:

块名

指定要插入的块的名称。

注: 插入图形中的编组对象作为未命名编组插入。在 AutoCAD LT 中,可以通过在“对象编组”对话框中选择“未命名编组”列出未命名的编组。在 AutoCAD LT 中,可以通过在编组管理器中选择“包括未命名的编组”列出未命名编组。

输入波浪号 (~) 可显示“选择图形文件”对话框(标准文件选择对话框)。

您可以使用以下方法控制块的插入方式:

  • 插入分解块:在块名前加星号 (*) 将分解块并插入块的各个部分。块定义并不添加到图形中。
  • 更新块路径:如果输入的块名没有路径名,INSERT 将先按照该名称在当前图形数据中搜索现有块定义。您可以通过输入 block name=file name,将现有块定义替换为外部文件。
  • 升级块定义:如果修改插入到图形中的块文件,并希望更改现有块定义而不创建新的块插入,请在“插入点”提示(位于“块名”提示后)下输入以下内容:

    块名=

    如果在块名后输入 =,则将显示以下提示:

块“当前”已存在。是否重定义?

指定“是”或“否”。

如果选择重新定义块,新的块定义将替换现有块定义。重生成图形,并将新定义应用于块定义的所有现有插入。如果不希望将新块插入到图形中,请在提示输入插入点时按 Esc 键。

?—列出块名称

列出图形中当前定义的块。

插入点

指定块或图形的位置。

比例因子

块或图形的所有 X 和 Y 标注将乘以 X 和 Y 比例因子。块或图形以插入点作为旋转中心按指定角度旋转。

角点

同时以插入点和另一点作为长方体的角点,定义 X 和 Y 的比例因子。长方体的 X 和 Y 标注成为 X 和 Y 的比例因子。插入点是第一角点。

XYZ

设定 XY 和 Z 比例因子。

  • X 比例因子: 为块或图形定义 XY 和 Z 比例因子
  • 角点: 同时,使用插入点和另一点作为长方体的角点,定义 X 和 Y 比例,然后定义 Z 比例。

基点

将块临时放置到其当前所在的图形中,并允许在将块参考拖动到位时为其指定新基点。这不会影响为块参照定义的实际基点。

比例

为 XY 和 Z 轴设定比例因子。Z 轴比例是指定比例因子的绝对值。

X

设定 X 比例因子。

Y

设定 Y 比例因子。

Z

设定 Z 比例因子。

旋转

设定块插入的旋转角度。

地理

将附着文件的地理位置设定为参照。

相关概念

猜你喜欢

转载自blog.csdn.net/hailiannanhai/article/details/81322055