我想通过这段CAD VBA代码实现提取"JMD"图层中所有闭合二位多段线的面积统计,但是不知道哪儿错了? 15
'创建新的选择集DimssetAsAcadSelectionSetDimFilterTypeAsVariant,FilterDataAsVariantDimgpCode(...
' 创建新的选择集
Dim sset As AcadSelectionSet
Dim FilterType As Variant, FilterData As Variant
Dim gpCode(2) As Integer, dataValue(2) As Variant
Set sset = ThisDrawing.SelectionSets.Add("ssl")
'创建过滤器
'本例为过滤图层为“JMD”的闭合多段线
'使用的是变体数组进行定义
'多段线过滤器
gpCode(2) = 0
dataValue(2) = "LWPolyline"
'图层过滤器
gpCode(1) = 8
dataValue(1) = "JMD"
FilterType = gpCode
FilterData = dataValue
' 添加至选择集中,在选择过程中进行过滤
' 完成选择后按回车。
sset.Select acSelectionSetAll, , , FilterType, FilterData
' 在选择集中循环并将每一已合条件的对象面积统计输出。
Dim sum As Single
Dim i As Integer
Dim s As Variant
Dim PlineObj As AcadLWPolyline
For i = 0 To ssetObj.Count - 1
i = i + 1
PlineObj = ssetObj.Item(i)
s(i) = PlineObj.Area
sum = sum + s(i)
Next i
ThisDrawing.Utility.Prompt "拆除砌体总面积为:" & sum & "平方米" 展开
Dim sset As AcadSelectionSet
Dim FilterType As Variant, FilterData As Variant
Dim gpCode(2) As Integer, dataValue(2) As Variant
Set sset = ThisDrawing.SelectionSets.Add("ssl")
'创建过滤器
'本例为过滤图层为“JMD”的闭合多段线
'使用的是变体数组进行定义
'多段线过滤器
gpCode(2) = 0
dataValue(2) = "LWPolyline"
'图层过滤器
gpCode(1) = 8
dataValue(1) = "JMD"
FilterType = gpCode
FilterData = dataValue
' 添加至选择集中,在选择过程中进行过滤
' 完成选择后按回车。
sset.Select acSelectionSetAll, , , FilterType, FilterData
' 在选择集中循环并将每一已合条件的对象面积统计输出。
Dim sum As Single
Dim i As Integer
Dim s As Variant
Dim PlineObj As AcadLWPolyline
For i = 0 To ssetObj.Count - 1
i = i + 1
PlineObj = ssetObj.Item(i)
s(i) = PlineObj.Area
sum = sum + s(i)
Next i
ThisDrawing.Utility.Prompt "拆除砌体总面积为:" & sum & "平方米" 展开
展开全部
Public Sub create_sset_PL()
' 创建新的选择集
Dim sset As AcadSelectionSet
Dim FilterType() As Integer, FilterData() As Variant
ReDim gpCode(2) As Integer
ReDim dataValue(2) As Variant
Set sset = ThisDrawing.SelectionSets.Add("ssl")
'创建过滤器
'本例为过滤图层为“JMD”的闭合多段线
'使用的是变体数组进行定义
'多段线过滤器
gpCode(0) = 0
dataValue(0) = "LWPolyline"
gpCode(2) = 70
dataValue(2) = 1
'图层过滤器
gpCode(1) = 8
dataValue(1) = "JMD"
FilterType = gpCode
FilterData = dataValue
' 添加至选择集中,在选择过程中进行过滤
' 完成选择后按回车。
sset.Select acSelectionSetAll, , , FilterType, FilterData
' 在选择集中循环并将每一已合条件的对象面积统计输出。
Dim sum As Double
Dim i As Integer
Dim s As Variant
Dim PlineObj As AcadLWPolyline
sum = 0
For Each PlineObj In sset
sum = sum + PlineObj.Area
Next PlineObj
ThisDrawing.Utility.Prompt "拆除砌体总面积为:" & Str(Round(sum, 3)) & " 平方米"
sset.Delete
End Sub
' 创建新的选择集
Dim sset As AcadSelectionSet
Dim FilterType() As Integer, FilterData() As Variant
ReDim gpCode(2) As Integer
ReDim dataValue(2) As Variant
Set sset = ThisDrawing.SelectionSets.Add("ssl")
'创建过滤器
'本例为过滤图层为“JMD”的闭合多段线
'使用的是变体数组进行定义
'多段线过滤器
gpCode(0) = 0
dataValue(0) = "LWPolyline"
gpCode(2) = 70
dataValue(2) = 1
'图层过滤器
gpCode(1) = 8
dataValue(1) = "JMD"
FilterType = gpCode
FilterData = dataValue
' 添加至选择集中,在选择过程中进行过滤
' 完成选择后按回车。
sset.Select acSelectionSetAll, , , FilterType, FilterData
' 在选择集中循环并将每一已合条件的对象面积统计输出。
Dim sum As Double
Dim i As Integer
Dim s As Variant
Dim PlineObj As AcadLWPolyline
sum = 0
For Each PlineObj In sset
sum = sum + PlineObj.Area
Next PlineObj
ThisDrawing.Utility.Prompt "拆除砌体总面积为:" & Str(Round(sum, 3)) & " 平方米"
sset.Delete
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询