CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

关于创建和命名图层 (VBA/ActiveX)

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

摘要: 您可以创建新图层并为这些图层指定颜色和线型属性。

您可以创建新图层并为这些图层指定颜色和线型属性。

每个单独的层都是集合的一部分。使用该方法创建新图层并将其添加到集合中。LayersAddLayers

您可以在创建图层时为其指定名称。要在创建图层后更改图层的名称,请使用属性。图层名称最多可包含 31 个字符,并包含字母、数字和特殊字符美元符号 ($)、连字符 (-) 和下划线 (_),但不能包含空格。Name

创建一个新图层,为其指定红色,然后向该图层添加对象

以下代码创建一个圆和一个新图层。新图层被指定为红色。圆被分配给图层,圆的颜色也会相应更改。

Sub Ch4_NewLayer()
  ' Create a circle
  Dim circleObj As AcadCircle
  Dim center(0 To 2) As Double
  Dim radius As Double
  center(0) = 2: center(1) = 2: center(2) = 0
  radius = 1
  Set circleObj = ThisDrawing.ModelSpace.AddCircle(center, radius)

  ' Create a color object
  Dim col As New AcadAcCmColor
  col.ColorMethod = AutoCAD.acColorMethodForeground

  ' Set the layer to the color
  Dim layColor As AcadAcCmColor
  Set layColor = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor." & _
                                                    Left(AcadApplication.Version, 2))
  Call layColor.SetRGB(122, 199, 25)
  ThisDrawing.ActiveLayer.TrueColor = layColor
  col.ColorMethod = AutoCAD.acColorMethodByLayer

  ' Assign the circle the color "ByLayer" so
  ' that the circle will automatically pick
  ' up the color of the layer on which it resides
  circleObj.Color = acByLayer
  circleObj.Update
End Sub

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-12 05:47

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部