明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
12
返回列表 发新帖
楼主: jsliuyun

如何将AcadEntity转换成Polyline之类的实体(

  [复制链接]
发表于 2004-10-9 14:54:00 | 显示全部楼层
Set poly = elem 没有错,是没有必要 Dim ss As AcadSelectionSet
ThisDrawing.SelectionSets("TT").Delete
Set ss = ThisDrawing.SelectionSets.Add("TT")
ss.Select acSelectionSetAll
Dim poly As AcadPolyline
For Each elem In ss '对每一条折线提取顶点坐标
If (elem.ObjectName = "AcDb3dPolyline") Then
pnts = elem.Coordinates
MsgBox pnts(0)
End If Next elem
发表于 2004-10-9 15:44:00 | 显示全部楼层
这样可以吗? Sub aa()
On Error Resume Next
Dim SSet As AcadSelectionSet
If Not IsNull(ThisDrawing.SelectionSets.Item("Example")) Then
Set SSet = ThisDrawing.SelectionSets.Item("Example")
SSet.Delete '及时删除不用的选择集非常重要
End If
Set SSet = ThisDrawing.SelectionSets.Add("Example") SSet.SelectOnScreen

Dim ent As AcadEntity
Dim objPline As AcadLWPolyline
For Each ent In SSet
If TypeOf ent Is AcadLWPolyline Then
Set objPline = ent
Debug.Print objPline.ObjectName
End If
Next ent SSet.Delete
End Sub
实际上,AutoCAD中使用PLINE命令绘制的是轻量多段线。
发表于 2004-10-9 15:44:00 | 显示全部楼层
如果有Set poly = elem 语句则会提示: 《类型不匹配》 没有该语句则不会,那是怎么回事呢?
发表于 2004-10-9 15:47:00 | 显示全部楼层
If (elem.ObjectName = "AcDb3dPolyline") Then
先判断elem的类型是不是polyline,然后才能使用 Set poly = elem。
发表于 2004-10-9 16:24:00 | 显示全部楼层
Dim elem As AcadEntity
Dim ss As AcadSelectionSet
ThisDrawing.SelectionSets("TT").Delete
Set ss = ThisDrawing.SelectionSets.Add("TT")

ss.Select acSelectionSetAll
Dim poly As AcadPolyline
For Each elem In ss '对每一条折线提取顶点坐标
If (elem.ObjectName = "AcDbPolyline") Then
Set poly = elem ' 就是如此啊
End If Next elem 还是提示错
发表于 2004-10-9 16:48:00 | 显示全部楼层
Dim elem As AcadEntity
Dim ss As AcadSelectionSet
ThisDrawing.SelectionSets("TT").Delete
Set ss = ThisDrawing.SelectionSets.Add("TT")
ss.Select acSelectionSetAll

Dim poly As AcadPolyline
For Each elem In ss '对每一条折线提取顶点坐标
If (elem.ObjectName = "AcDbPolyline") Then
Set poly = elem ' 就是如此啊
pnts = poly.Coordinates
MsgBox pnts(0)
End If
Next elem Dim poly As AcadPolyline,那elem.ObjectName应该要为AcDb2DPolyline吧,没有安装ACAD,先自己试试它的对象名称。
 楼主| 发表于 2004-10-9 19:43:00 | 显示全部楼层
我怎么不能访问elem.Coordinates,好象没有这个属性,我试了2000,2002,2004都没有,你们的怎么有这个属性呢,奇怪?
发表于 2009-2-16 16:13:00 | 显示全部楼层
Set poly = elem ,这句不对吧,老是提示类型不匹配。如何解决
发表于 2009-2-23 16:03:00 | 显示全部楼层
12楼正解
发表于 2010-7-1 11:16:00 | 显示全部楼层
转为相应的实体就有相应的属性咯
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 00:27 , Processed in 0.163057 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表