CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

模型空间属性 (ActiveX)

2023-1-3 10:47| 发布者: admin| 查看: 425| 评论: 0|来自: AutoCAD

摘要: 获取文档的模型空间集合。

获取文档的模型空间集合。

支持的平台:仅窗口

签名

工 务 局:

object.ModelSpace
对象

类型:数据库文档

此属性适用的对象。

属性值

只读:是的

类型:模型空间

文档的集合。ModelSpace

言论

没有额外的评论。

例子

工 务 局:

Sub Example_ModelSpace()
    ' This example adds a line and a circle to model space.
    ' The line is added using a user-defined variable representing
    ' the model space. The circle is added without using the
    ' user-defined variable. Either use of the ModelSpace
    ' property is valid.
    
    ' Define the line
    Dim lineObj As AcadLine
    Dim startPoint(0 To 2) As Double
    Dim endPoint(0 To 2) As Double
    startPoint(0) = 0: startPoint(1) = 0: startPoint(2) = 0
    endPoint(0) = 4: endPoint(1) = 4: endPoint(2) = 0
    
    ' Add the line to model space using the mspace variable
    Dim mspace As AcadModelSpace
    Set mspace = ThisDrawing.ModelSpace
    Set lineObj = mspace.AddLine(startPoint, endPoint)
    
    ' Define a circle
    Dim circleObj As AcadCircle
    Dim center(0 To 2) As Double
    Dim radius As Double
    center(0) = 4: center(1) = 4: center(2) = 0
    radius = 1
    
    ' Add the circle to model space without using the mspace variable
    Set circleObj = ThisDrawing.ModelSpace.AddCircle(center, radius)
    
    ZoomAll
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_ModelSpace()
    ;; This example adds a line and a circle to model space.
    ;; The line is added using a user-defined variable representing
    ;; the model space. The circle is added without using the
    ;; user-defined variable. Either use of the ModelSpace
    ;; property is valid.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    ;; Define the line
    (setq startPoint (vlax-3d-point 0 0 0)
          endPoint (vlax-3d-point 4 4 0))
    
    ;; Add the line to model space using the mspace variable
    (setq mspace (vla-get-ModelSpace doc))
    (setq lineObj (vla-AddLine mspace startPoint endPoint))
    
    ;; Define a circle
    (setq center (vlax-3d-point 4 4 0)
          radius 1)
    
    ;; Add the circle to model space without using the mspace variable
    (setq circleObj (vla-AddCircle mspace center radius))
    
    (vla-ZoomAll acadObj)
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-19 13:20

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部