CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

关于指定线型比例 (VBA/ActiveX)

2023-1-4 23:42| 发布者: admin| 查看: 580| 评论: 0|来自: AutoCAD

摘要: 您可以为创建的对象指定线型比例。

您可以为创建的对象指定线型比例。

比例越小,每个绘图单元生成的图案重复次数就越多。默认情况下,AutoCAD 使用全局线型比例 1.0,等于一个图形单位。可以更改所有图形对象、属性参照和组的线型比例。

要更改线型比例,请使用属性。LinetypeScale

AutoCAD CELTSCALE 系统变量为新创建的对象设置线型比例。LTSCALE 全局更改现有对象以及新对象的线型比例。要使用 AutoCAD ActiveX 自动化更改系统变量的值,请使用该方法。SetVariable

更改圆的线型比例

Sub Ch4_ChangeLinetypeScale()
  ' Save the current linetype
  Set currLineType = ThisDrawing.ActiveLinetype

  ' Change the active linetype to Border, so the scale change will
  ' be visible.
  ' First see if the Border linetype is already loaded
  On Error Resume Next          'Turn on error trapping
  ThisDrawing.ActiveLinetype = ThisDrawing.Linetypes.Item("BORDER")
  If Err.Number = -2145386476 Then
    ' Error indicates linetype is not currently loaded, so load it.
    ThisDrawing.Linetypes.Load "BORDER", "acad.lin"
    ThisDrawing.ActiveLinetype = _
          ThisDrawing.Linetypes.Item("BORDER")
  End If

  On Error GoTo 0               ' Turn off error trapping

  ' Create a circle object in model space
  Dim center(0 To 2) As Double
  Dim radius As Double
  Dim circleObj As AcadCircle
  center(0) = 2
  center(1) = 2
  center(2) = 0
  radius = 4
  Set circleObj = ThisDrawing.ModelSpace.AddCircle(center, radius)
  circleObj.Update
  MsgBox ("Here is the circle with the original linetype")

  ' Set the linetype scale of a circle to 3
  circleObj.LinetypeScale = 3#
  circleObj.Update
  MsgBox ("Here is the circle with the new linetype")

  ' Restore original active linetype
  ThisDrawing.ActiveLinetype = currLineType
End Sub

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-12 08:31

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部