当前版块:问答社区 > CASS

【AutoCAD二次开发】第五节实体编辑

Windows10
其他
CASS9
'第五节 实体编辑
Sub EditEntity() '编辑点
   Dim objPnt As AcadPoint
   Dim xy(2) As Double, xxyy(2) As Double
   xy(0) = 100: xy(1) = 200: xy(2) = 0
   xxyy(0) = 101: xxyy(1) = 201: xxyy(2) = 0
   Set objPnt = ThisDrawing.Application.ActiveDocument.ModelSpace.AddPoint(xy)
   objPnt.Thickness = 123456
   objPnt.Layer = "hello"
   objPnt.color = acGreen
   objPnt.Move xy, xxyy
   MsgBox "移动后的坐标为:(" & objPnt.Coordinates(0) & "," & objPnt.Coordinates(1) & "," & objPnt.Coordinates(2) & ")"
End Sub
Sub EditLwPolyline() '编辑轻量多段线
   Dim objLwPl As AcadLWPolyline
   Dim xy(5) As Double
   xy(0) = 100: xy(1) = 200
   xy(2) = 300: xy(3) = 300
   xy(4) = 500: xy(5) = 600
   Set objLwPl = ThisDrawing.Application.ActiveDocument.ModelSpace.AddLightWeightPolyline(xy)
   objLwPl.Closed = True '闭合
   objLwPl.ConstantWidth = 0 '全局宽度
   objLwPl.Linetype = "10421" '线型(加载了才可用)
   objLwPl.Highlight True '高亮显示
   MsgBox "ID=" & objLwPl.ObjectID
   MsgBox "类型=" & objLwPl.ObjectName
   MsgBox "句柄=" & objLwPl.Handle
   MsgBox "多段线坐标为:(" & objLwPl.Coordinates(0) & "," & objLwPl.Coordinates(1) & "),(" & objLwPl.Coordinates(2) & "," & objLwPl.Coordinates(3) & "),(" & objLwPl.Coordinates(4) & "," & objLwPl.Coordinates(5) & ")"
End Sub
Sub EditText() '编辑文字
   Dim objText As AcadText
   Dim xy(2) As Double
   xy(0) = 100: xy(1) = 200: xy(2) = 300
   Set objText = ThisDrawing.Application.ActiveDocument.ModelSpace.AddText("Hello World!", xy, 30)
   MsgBox "插入点位置:(" & objText.insertionPoint(0) & "," & objText.insertionPoint(1) & "," & objText.insertionPoint(2) & ")"
   objText.Alignment = acAlignmentBottomRight '对齐方式
   objText.height = 20 '高度
   objText.StyleName = "STANDARD" '样式
   objText.TextString = "AutoCAD VBA 测绘" '文字内容
End Sub

全部评论

等级:LV30
积分:54876
hkai2658 2019-12-20 08:56
👍
回复 0
1
提交
悬赏回复规则
1、悬赏期为24小时,从发布时间起算;
2、悬赏期内提问者如设置评论为“精选评论”,视为悬赏结束,该精选评论人将获得本题全部悬赏积分;
3、悬赏期内如提问者未设置“精选评论”,则前5位评论者平分悬赏积分(如仅有一位评论,该评论者获得50%悬赏积分);
4、悬赏积分会自动发放到生态圈账户中,请留意站内信通知。
知道了

距离打开宝箱还剩7

是否花费200积分补签?
确认
取消