斑竹,帮我看看
下面代码中,没有错误,只是为什么再执行到for循环语句时没有msgbox显示呀!!谢谢!!public sstext1 as acadselectionset
public acadobj as acadobjec
public entobj as acadentity
public line as acadline
public aa as acadarc
public ellispe as acadellispe
publid sub aa()
'选择集选择对象
Dim mode As Integer
'Dim sstext1 As AcadSelectionSet
Set sstext1 = thisdrawing.ActiveDocument.SelectionSets.Add("ss1")
Dim corner1(0 To 2) As Double
Dim corner2(0 To 2) As Double
'选择集参数设置
mode = acSelectionSetCrossing
corner1(0) = -800
corner1(1) = 700
corner1(2) = 0
corner2(0) = 1830
corner2(1) = -196
corner2(2) = 0
'选择过滤条件
Dim gpcode(0) As Integer
Dim datavalue(0) As Variant
gpcode(0) = 8
datavalue(0) = "layer1"
Dim filtertype As Variant
Dim filterdata As Variant
filtertype = gpcode
filterdata = datavalue
sstext1.Select mode, corner1, corner2, filtertype, filterdata
Dim entcount As Integer
entcount = sstext1.Count
MsgBox "选择集中的图元数量:" & entcount
'Dim entobj As AcadEntity
Dim j As Integer
' 提取选择集中对象的属性
For j = 0 To entcount - 1
Set acadobj = sstext1.Item(j)
Select Case acadobj.ObjectName
Case "AcDbline"
Set line = thisdrawing.ActiveDocument.SelectionSets.Item(j)
MsgBox "选择集中图元名称:" & acadobj.ObjectName
'startpt1 = line.StartPoint(0)
'startpt2 = line.StartPoint(1)
'endpt1 = line.EndPoint(0)
'endpt2 = line.EndPoint(1)
'leng = line.length
MsgBox " 直线的起始横坐标" & line.StartPoint(0)
MsgBox "直线的起始纵坐标" & line.startpoint(1)
MsgBox "直线的终点横坐标" & line.endpoint(0)
MsgBox "直线的终点纵坐标" & line.endpoint(1)
MsgBox "直线的长度" & line.length
Case "AcDbarc"
Set aa = thisdrawing.ActiveDocument.SelectionSets.Item(j)
MsgBox "选择集中图元名称:" & entobj.ObjectName
'startpt1 = aa.Center(0)
'startpt2 = aa.Center(1)
'cenrad = aa.Radius
'cenare = aa.Area
MsgBox " 圆的中心横坐标" & aa.Center(0)
MsgBox "圆的中心纵坐标" & aa.center(1)
MsgBox "圆的半径" & aa.radius
MsgBox "圆的面积" & aa.are
'Call save
Case "AcDbellispe"
Set ellispe = thisdrawing.ActiveDocument.SelectionSets.Item(j)
MsgBox "选择集中图元名称:" & entobj.ObjectName
startpt1 = ellispe.Center(0)
startpt2 = ellispe.Center(1)
cenare = ellispe.Area
End Select
Next
end sub
AcDbline应为AcDbLine ,而AcDbarc应为AcDbArc,注意大小写
正是如此
实体的图元名都有一定规律的。
页:
[1]