hangc 发表于 2005-7-23 01:24:00

有哪为老兄有Region炸开后line线连结代码?

有哪为老兄有Region炸开后line线连结代码?我做了一个但是逻辑性不是很强,不敢使用,谢谢了哈?

雪山飞狐_lzh 发表于 2005-7-23 22:36:00

<P>line线连结代码?</P>
<P>什么意思?</P>

hangc 发表于 2005-7-28 00:13:00

<STRONG>Region炸开后全部变成了line,如何将这些line连接形成闭合的Polyline,最主要的问题是Region炸开后line的顺序很难控制,所以很难找到当前Line的下一个Line!</STRONG>

wyj7485 发表于 2005-7-28 09:13:00


On Error Resume Next
Dim sset As AcadSelectionSet
ThisDrawing.SelectionSets.Item("LineSet").Delete
Set sset = ThisDrawing.SelectionSets.Add("LineSet")
sset.SelectOnScreen
ThisDrawing.SendCommand "_pedit" & vbCr & "M" & vbCr & _
"p" & vbCr & vbCr & "Y" & vbCr & "J" & _
vbCr & vbCr & vbCr

hangc 发表于 2005-7-28 10:19:00

<P>高,佩服,我怎么没想到呢?向你学习!!!</P>

hangc 发表于 2005-7-30 09:36:00

<STRONG>紧急求助:各位同仁们帮助看一下这段程序问题在哪里?<BR></STRONG>
<P>Sub ConnectLine()<BR>Dim mySelect As AcadSelectionSet<BR>Dim MyVal(0 To 3) As String<BR>MyVal(0) = "8": MyVal(1) = "TbRegion": MyVal(2) = "0": MyVal(3) = "REGION"<BR>BuildFilter fType, fDate, MyVal<BR>Set sss = ThisDrawing.SelectionSets<BR>On Error Resume Next<BR>ThisDrawing.SelectionSets.Item("mySelects12").Delete<BR>On Error GoTo ErrExit<BR>Set myss = sss.Add("mySelects12")<BR>myss.Select acSelectionSetAll, , , fType, fDate<BR>Dim myExplode As Variant, En As AcadEntity<BR>For Each En In myss<BR>&nbsp;&nbsp; myExplode = En.Explode<BR>&nbsp;&nbsp; Set mySelect = sss.Add("sRegions5")<BR>&nbsp;&nbsp; mySelect.AddItems myExplode&nbsp;&nbsp; '当前选择集已经添加了对象<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp; '问题:为什么下一句中P提示前一个选择集合不存在<BR>&nbsp;&nbsp; ThisDrawing.SendCommand "_pedit" &amp; vbCr &amp; "M" &amp; vbCr &amp; "P" &amp; vbCr &amp; vbCr &amp; "Y" &amp; vbCr &amp; "J" &amp; vbCr &amp; vbCr &amp; vbCr<BR>&nbsp;&nbsp; mySelect.Delete<BR>Next<BR>Exit Sub<BR>ErrExit:<BR>&nbsp;&nbsp; MsgBox Err.Description<BR>End Sub</P>
<P>'创建选择集的过滤规则<BR>Public Sub BuildFilter(typeArray As Variant, dataArray As Variant, ByVal gCodes As Variant)<BR>Dim fType() As Integer, fData() As Variant<BR>Dim Index As Long, i As Long<BR>Index = LBound(gCodes) - 1<BR>'根据gCodes的内容创建过滤数组<BR>For i = LBound(gCodes) To UBound(gCodes) Step 2<BR>&nbsp;&nbsp;&nbsp; Index = Index + 1<BR>&nbsp;&nbsp;&nbsp; ReDim Preserve fType(0 To Index)<BR>&nbsp;&nbsp;&nbsp; ReDim Preserve fData(0 To Index)<BR>&nbsp;&nbsp;&nbsp; fType(Index) = CInt(gCodes(i))<BR>&nbsp;&nbsp;&nbsp; fData(Index) = gCodes(i + 1)<BR>Next<BR>'返回值<BR>typeArray = fType<BR>dataArray = fData<BR>End Sub</P>

sieben 发表于 2005-7-30 18:58:00

<P>myExplode = En.Explode<BR>把这一句改为用Sendcommand方法试试看</P>
<P>'问题:为什么下一句中P提示前一个选择集合不存在</P>

hangc 发表于 2005-7-30 23:09:00

<P>如果用SendCommand的话,好像就不知道Region打散后的对象了哈?</P>

ljq 发表于 2005-8-10 10:56:00

其实,采用pedit是一种没有办法的办法,如果区域是复杂的多个闭合线组合,将有多个线生成才对。这个问题用vba实在无法解决,但使用arx还是可以用程序解决的,我有别人编好的库,实在很好使用。
页: [1]
查看完整版本: 有哪为老兄有Region炸开后line线连结代码?