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