CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

关于爆炸对象 (VBA/ActiveX)

2023-1-5 00:48| 发布者: admin| 查看: 813| 评论: 0|来自: AutoCAD

摘要: 分解对象会将对象从单个对象转换为其组成部分,但没有可见效果。

分解对象会将对象从单个对象转换为其组成部分,但没有可见效果。

例如,分解会形成来自 3D 多边形、折线、多边形网格和区域的简单直线和弧。它将块引用替换为组成块的简单对象的副本。

分解折线

本示例创建一个轻型折线对象。然后,它将折线分解为单独的对象。然后,该示例循环遍历生成的对象,并显示一个消息框,其中包含每个对象的名称和其在分解对象列表中的索引。

Sub Ch4_ExplodePolyline()
  Dim plineObj As AcadLWPolyline
  Dim points(0 To 11) As Double

  ' Define the 2D polyline points
  points(0) = 1: points(1) = 1
  points(2) = 1: points(3) = 2
  points(4) = 2: points(5) = 2
  points(6) = 3: points(7) = 2
  points(8) = 4: points(9) = 4
  points(10) = 4: points(11) = 1

  ' Create a light weight Polyline object
  Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)

  ' Set the bulge on one segment to vary the
  ' type of objects in the polyline
  plineObj.SetBulge 3, -0.5
  plineObj.Update

  ' Explode the polyline
  Dim explodedObjects As Variant
  explodedObjects = plineObj.Explode

  ' Loop through the exploded objects
  ' and display a message box with
  ' the type of each object
  Dim I As Integer
  For I = 0 To UBound(explodedObjects)
    explodedObjects(I).Update
    MsgBox "Exploded Object " & I & ": " & explodedObjects(I).ObjectName
    explodedObjects(I).Update
  Next
End Sub

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-12 14:12

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部