版主:如何根据选择的线条来创建面域?
我的代码如下:
'On Error Resume Next Dim SsetObj As AcadSelectionSet Dim FilterType(7) As Integer Dim FilterData(7) As Variant frmMain.Hide ThisDrawing.SelectionSets("AA").Delete Set SsetObj = ThisDrawing.SelectionSets.Add("AA") FilterType(0) = -4 FilterData(0) = "<or" FilterType(1) = 0 FilterData(1) = "Arc" FilterType(2) = 0 FilterData(2) = "Circle" FilterType(3) = 0 FilterData(3) = "Ellipse" FilterType(4) = 0 FilterData(4) = "Line" FilterType(5) = 0 FilterData(5) = "Pline" FilterType(6) = 0 FilterData(6) = "Spline" FilterType(7) = -4 FilterData(7) = "or>" SsetObj.SelectOnScreen FilterType, FilterData
Dim m As Integer '选择集中的元素个数 m = SsetObj.Count Dim element() As AcadEntity ReDim element(m) For i = 1 To m Set element(i - 1) = SsetObj.Item(i - 1) Next Dim Region As Variant Region = ThisDrawing.ModelSpace.AddRegion(element) tdArea.Text = Region.Area
'返回对话框 frmMain.Show
这句代码处提示:(方法'Addregion'作用于对象'IaCadModelSpace'时失败)
Region = ThisDrawing.ModelSpace.AddRegion(element)
改为了以下代码后:
Dim element() As AcadEntity ReDim element(m - 1) For i = 0 To m - 1 Set element(i) = SsetObj.Item(i) Next Dim Region As Variant Region = ThisDrawing.ModelSpace.AddRegion(element) msgbox Region.area
在msgbox Region.area出错提示:“要求对象”