torch 发表于 2004-8-6 11:37:00

多边形转化为CP区域选择的问题

Sub Test()<BR>Dim ssetObj As AcadSelectionSet<BR>Dim CC As AcadCircle<BR>Dim points(59) As Double


Dim retCoord As Variant<BR>Dim pntcnt As Integer


On Error Resume Next<BR>Set ssetObj = ThisDrawing.SelectionSets.Add("TEST_SSET2")


On Error GoTo ErrHandle<BR>Dim pFrom, pTo<BR>Dim p1(3) As Double, p2(1) As Double<BR>Dim pPL As AcadLWPolyline<BR>pFrom = ThisDrawing.Utility.GetPoint(, vbCr &amp; "Pls Input First Point:")<BR>pTo = ThisDrawing.Utility.GetPoint(pFrom, vbCr &amp; "Pls Input Second Point")<BR>p1(0) = pFrom(0): p1(1) = pFrom(1)<BR>p1(2) = pTo(0): p1(3) = pTo(1)<BR>Set pPL = ThisDrawing.ModelSpace.AddLightWeightPolyline(p1)<BR>Do While True<BR>pTo = ThisDrawing.Utility.GetPoint(pTo, vbCr &amp; "Pls Input Next Point")<BR>p2(0) = pTo(0): p2(1) = pTo(1)<BR>pPL.AddVertex (UBound(pPL.Coordinates) + 1) / 2, p2<BR>Loop<BR>ErrHandle:<BR>pPL.Closed = True


'points = pPL.Coordinates<BR>retCoord = pPL.Coordinates<BR>pntcnt = UBound(retCoord)<BR>Dim i As Integer<BR>Dim j As Integer<BR>'Dim points As Double<BR>                       i = 0<BR>                       Dim dip As String<BR>                       For j = 0 To pntcnt - 1 Step 2<BR>                       points(i) = retCoord(j)<BR>                       points(i + 1) = retCoord(j + 1)<BR>                       points(i + 1) = 0<BR>                       i = i + 3<BR>                       <BR>                       Next j<BR>                       Dim m As Integer<BR>                       <BR>ssetObj.SelectByPolygon acSelectionSetCrossingPolygon, points


For Each CC In ssetObj


On Error Resume Next


CC.color = acBlue<BR>CC.Update<BR>Next CC<BR>ssetObj.Clear<BR>ssetObj.Erase<BR>ssetObj.Delete<BR>End Sub


此程序是在随风大侠的帮助下编写的多线段定义的多边形转化为CP区域选择的问题,但是在运行中会出现“Run-time error“91”:


                                                                                                                                                                                                                                       Object variable or With block variable not set”


请大侠帮我修改与完善次代码,本人涕泪感激!
页: [1]
查看完整版本: 多边形转化为CP区域选择的问题