CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

AddExtrudedSolid Method (ActiveX)

2023-1-4 13:05| 发布者: admin| 查看: 413| 评论: 0|来自: AutoCAD

摘要: 在给定轮廓、高度和锥度角度的情况下创建拉伸实体。

在给定轮廓、高度和锥度角度的情况下创建拉伸实体。

支持的平台:仅窗口

签名

工 务 局:

RetVal = object.AddExtrudedSolid(Profile, Height, TaperAngle)
对象

类型:模型空间,图纸空间

此方法适用的对象。

轮廓

访问:仅输入

类型:区域

配置文件只能是对象。Region

高度

访问:仅输入

类型:

沿对象坐标系的Z轴的拉伸高度。如果输入正数,AutoCAD 将沿正Z轴拉伸对象。如果输入负数,AutoCAD 将沿负Z轴拉伸对象。

锥度角度

访问:仅输入

类型:

挤压件的锥度角必须以弧度为单位。锥角的范围为 -90 至 +90 度。

正角从底座逐渐变细,负角逐渐变细。默认角度 0 表示垂直于其平面的 2D 对象拉伸。

返回值(RetVal)

类型:3DSolid

对象作为新创建的拉伸实体。3DSolid

言论

只能拉伸 2D 平面区域。

锥形拉伸只能用于在顶点处连续的循环。较大的锥度角或较长的挤压高度会导致物体或物体的某些部分在达到挤出高度之前与自身相交。当生成的实体与自身相交时,AutoCAD 不允许拉伸。

例子

工 务 局:

Sub Example_AddExtrudedSolid()
    ' This example extrudes a solid from a region.
    ' The region is created from an arc and a line.
    
    Dim curves(0 To 1) As AcadEntity

    ' Define the arc
    Dim centerPoint(0 To 2) As Double
    Dim radius As Double
    Dim startAngle As Double
    Dim endAngle As Double
    centerPoint(0) = 5#: centerPoint(1) = 3#: centerPoint(2) = 0#
    radius = 2#
    startAngle = 0
    endAngle = 3.141592
    Set curves(0) = ThisDrawing.ModelSpace.AddArc(centerPoint, radius, startAngle, endAngle)
    
    ' Define the line
    Set curves(1) = ThisDrawing.ModelSpace.AddLine(curves(0).startPoint, curves(0).endPoint)
        
    ' Create the region
    Dim regionObj As Variant
    regionObj = ThisDrawing.ModelSpace.AddRegion(curves)
    
    ' Define the extrusion
    Dim height As Double
    Dim taperAngle As Double
    height = 3
    taperAngle = 0
    
    ' Create the solid
    Dim solidObj As Acad3DSolid
    Set solidObj = ThisDrawing.ModelSpace.AddExtrudedSolid(regionObj(0), height, taperAngle)
    
    ' Change the viewing direction of the viewport
    Dim NewDirection(0 To 2) As Double
    NewDirection(0) = -1: NewDirection(1) = -1: NewDirection(2) = 1
    ThisDrawing.ActiveViewport.direction = NewDirection
    ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport
    ZoomAll
        
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_AddExtrudedSolid()
    ;; This example extrudes a solid from a region.
    ;; The region is created from an arc and a line.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    (setq modelSpace (vla-get-ModelSpace doc))

    ;; Define the arc
    (setq centerPoint (vlax-3d-point 5 3 0)
          radius 2
          startAngle 0
          endAngle 3.141592)
    (setq arc (vla-AddArc modelSpace centerPoint radius startAngle endAngle))

    ;; Define the line
    (setq line (vla-AddLine modelSpace (vla-get-StartPoint arc) (vla-get-EndPoint arc)))
  
    (setq curves (vlax-make-safearray vlax-vbObject '(0 . 1)))
    (vlax-safearray-put-element curves 0 arc)
    (vlax-safearray-put-element curves 1 line)
        
    ;; Create the region
    (setq regionObj (vla-AddRegion modelSpace curves))
    
    ;; Define the extrusion
    (setq height 3
          taperAngle 0)
    
    ;; Create the solid
    (setq solidObj (vla-AddExtrudedSolid modelSpace (vlax-safearray-get-element (vlax-variant-value regionObj) 0) height taperAngle))
    
    ;; Change the viewing direction of the viewport
    (setq NewDirection (vlax-3d-point -1 -1 1))
    (setq activeViewport (vla-get-ActiveViewport doc))
    (vla-put-Direction activeViewport NewDirection)
    (vla-put-ActiveViewport doc activeViewport)
    (vla-ZoomAll acadObj)
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-11 15:34

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部