- 积分
- 987
- 明经币
- 个
- 注册时间
- 2004-2-13
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
Sub Test() Dim ssetObj As AcadSelectionSet Dim CC As AcadCircle Dim points(59) As Double
Dim retCoord As Variant Dim pntcnt As Integer
On Error Resume Next Set ssetObj = ThisDrawing.SelectionSets.Add("TEST_SSET2")
On Error GoTo ErrHandle Dim pFrom, pTo Dim p1(3) As Double, p2(1) As Double Dim pPL As AcadLWPolyline pFrom = ThisDrawing.Utility.GetPoint(, vbCr & "Pls Input First Point:") pTo = ThisDrawing.Utility.GetPoint(pFrom, vbCr & "Pls Input Second Point") p1(0) = pFrom(0): p1(1) = pFrom(1) p1(2) = pTo(0): p1(3) = pTo(1) Set pPL = ThisDrawing.ModelSpace.AddLightWeightPolyline(p1) Do While True pTo = ThisDrawing.Utility.GetPoint(pTo, vbCr & "Pls Input Next Point") p2(0) = pTo(0): p2(1) = pTo(1) pPL.AddVertex (UBound(pPL.Coordinates) + 1) / 2, p2 Loop ErrHandle: pPL.Closed = True
'points = pPL.Coordinates retCoord = pPL.Coordinates pntcnt = UBound(retCoord) Dim i As Integer Dim j As Integer 'Dim points As Double i = 0 Dim dip As String For j = 0 To pntcnt - 1 Step 2 points(i) = retCoord(j) points(i + 1) = retCoord(j + 1) points(i + 1) = 0 i = i + 3 Next j Dim m As Integer ssetObj.SelectByPolygon acSelectionSetCrossingPolygon, points
For Each CC In ssetObj
On Error Resume Next
CC.color = acBlue CC.Update Next CC ssetObj.Clear ssetObj.Erase ssetObj.Delete End Sub
此程序是在随风大侠的帮助下编写的多线段定义的多边形转化为CP区域选择的问题,但是在运行中会出现“Run-time error“91”:
Object variable or With block variable not set”
请大侠帮我修改与完善次代码,本人涕泪感激! |
|