求助:选择集内直线问题
选择集内有2条相交直线,现在通过"break"命令实现了在交点处打断,打断之后,选择集就只有2条线 但是怎样让选择集重新包含打断了的4条直线呢? 利用selectpoint方法。 <p>ReSelSet:</p><p> '建立选择集</p><p> LineSelset.Select acSelectionSetAll, , , LineType, LineData</p><p> '打断直线</p><p> LineSelSet.Clear '清空选择集</p><p> goto ReSelSet '重新建立选择集 </p><p></p><p>LZ:请问两条直线在交点处打断,通过VBA是怎么实现的?</p> 可以调用cad命令,你可以具体看看论坛上的,cad转换双元表 <p>程序如下,但是还是不能实现直线长度小于2000的自动删除,有时候可以,有时候不行,在vba界面里面按执行按钮可以,在cad里面里面点击“宏”运行就不行,为什么呢?</p><p>Sub r4() '相交的直线彼此打断</p><p> Dim returnObj As AcadEntity<br/> Dim y(1 To 3) As Double<br/> Dim ss(100000) As Variant<br/> Dim det As String<br/> Dim det1 As String<br/> Dim lspPnt As String<br/> <br/> <br/> On Error Resume Next<br/> SsetName = "au100"<br/> On Error Resume Next<br/> For i = 0 To ThisDrawing.SelectionSets.Count - 1<br/> Set SsetObj = ThisDrawing.SelectionSets.Item(i)<br/> If SsetObj.Name = "au100" Then SsetObj.Delete<br/> Next i<br/> Set SsetObj = ThisDrawing.SelectionSets.Add(SsetName)<br/> SsetObj.SelectOnScreen<br/> <br/> j = SsetObj.Count<br/> MsgBox j<br/> k = 0<br/> <br/> For i = 0 To j - 1<br/> For ii = 0 To j - 1<br/> If Abs(SsetObj.Item(i).Angle - SsetObj.Item(ii).Angle) > 0.5 Then<br/> ss(k) = SsetObj.Item(i).IntersectWith(SsetObj.Item(ii), acExtendBoth)<br/> det = GetDoubleEntTable(SsetObj.Item(i), ss(k))<br/> det1 = GetDoubleEntTable(SsetObj.Item(ii), ss(k))<br/> lspPnt = axPoint2lspPoint(ss(k))<br/> ThisDrawing.SendCommand "_break" & vbCr & det & vbCr & lspPnt & vbCr<br/> ThisDrawing.SendCommand "_break" & vbCr & det1 & vbCr & lspPnt & vbCr<br/> <br/> SsetObj.SelectAtPoint ss(k)<br/> k = k + 1<br/> End If<br/> Next<br/> Next <br/> For i = 0 To SsetObj.Count<br/> If SsetObj.Item(i).Length < 2000 Then SsetObj.Item(i).Delete<br/> Next<br/> End Sub</p><p>'转换双元表的函数<br/>Public Function GetDoubleEntTable(entObj As AcadEntity, Pnt As Variant) As String<br/> Dim entHandle As String<br/> entHandle = entObj.Handle<br/> GetDoubleEntTable = "(list(handent " & Chr(34) & entHandle & Chr(34) & _<br/> ")(list " & Str(Pnt(0)) & Str(Pnt(1)) & Str(Pnt(2)) & "))"</p> liuyang4740发表于2008-6-16 20:15:00static/image/common/back.gif选择集内有2条相交直线,现在通过\"break\"命令实现了在交点处打断,打断之后,选择集就只有2条线 但是怎样让选择集重新包含打断了的4条直线呢?<p>在没打断前获得选择集的 minPoint,maxPoint坐标,如.GetBoundingBox可以获得实体的minPoint,maxPoint,打断后在重新定义sset选择集用minPoint,maxPoint</p> .GetBoundingBox没法获得选择集的minPoint,maxPoint坐标,只有实体才能用.GetBoundingBox方法阿!
页:
[1]