lijinjie 发表于 2006-1-20 00:32:00

问一个关于VBA处理...线与块的问题.

<P></P>
<P>像上面的程序..我希望用..VBA把..那个外部插入时..自动..把中间的线给分开成2段...达到下面那个图的效果.......再把..2段线..分另接到..这个块的..两端.</P>
<P>希望老大帮忙一下..</P>

MJTD_7777 发表于 2006-1-24 16:59:00

<P>是画气路图吗?哈哈,同道中人.</P>

lijinjie 发表于 2006-1-24 21:39:00

<P>哈哈。。是的。。电气原理图。。我是做成套设备的。。温州这里的。</P>
<P>具体的方法找不到。。现在只能用另一个麻烦些的办法来实现。</P>
<P>&nbsp;</P>
<P>Public Sub addWblock(strFilePath As String)<BR>On Error Resume Next</P>
<P>&nbsp;&nbsp; Dim InsertPoint As Variant<BR>&nbsp;&nbsp; Dim x, y, z As Double<BR>&nbsp;&nbsp; Dim myblock As AcadBlockReference<BR>&nbsp;&nbsp; Dim rstr As String<BR>&nbsp;&nbsp; Dim pos As Variant<BR>&nbsp;&nbsp; Dim tempstr As String<BR>fun:<BR>&nbsp;&nbsp; x = 1<BR>&nbsp;&nbsp; y = 1<BR>&nbsp;&nbsp; z = 1<BR>&nbsp;&nbsp; NL = Chr(13) &amp; Chr(10)<BR>&nbsp;&nbsp; UserForm1.Hide<BR>&nbsp;&nbsp; InsertPoint = ThisDrawing.Utility.GetPoint(, NL)<BR>&nbsp;&nbsp; Set myblock = ThisDrawing.ModelSpace.InsertBlock(InsertPoint, strFilePath, x, y, z, 0, "")<BR>&nbsp;&nbsp;&nbsp; myblock.Update<BR>&nbsp; <BR>&nbsp;&nbsp; GetCursorPos (pos)<BR>&nbsp; ' If (strFilePath = "交叉点(跨越).dwg") Or (strFilePath = "交叉点(竖直).dwg") Or (Left$(strFilePath, 4) = "(开关)") Or (Left$(strFilePath, 2) = "按钮") Then<BR>&nbsp;&nbsp;&nbsp; Dim pnt1 As Variant<BR>&nbsp;&nbsp;&nbsp; Dim entObj1 As AcadEntity<BR>&nbsp;&nbsp; ' ThisDrawing.Utility.GetEntity entObj1, pnt1, "选择图元:"<BR>&nbsp;&nbsp;&nbsp; Dim det1 As String<BR>&nbsp;&nbsp;&nbsp; entObj1 = myblock<BR>&nbsp;&nbsp;&nbsp; det1 = axEnt2lspEnt(entObj1)</P>
<P>&nbsp;&nbsp;&nbsp; Dim Pnt2 As Variant<BR>&nbsp;&nbsp;&nbsp; Dim entObj2 As AcadEntity<BR>&nbsp;&nbsp; ' ThisDrawing.Utility.GetEntity entObj2, Pnt2, "选择被剪图元:"<BR>&nbsp;&nbsp;&nbsp; Dim det2 As String<BR>&nbsp;&nbsp;&nbsp; det2 = GetDoubleEntTable(entObj2, InsertPoint)<BR>&nbsp;&nbsp;&nbsp; ThisDrawing.SendCommand "_trim" &amp; vbCr &amp; det1 &amp; vbCr &amp; vbCr &amp; det2 &amp; vbCr &amp; vbCr<BR>&nbsp; ' End If<BR>&nbsp;&nbsp; 'ThisDrawing.Utility.Prompt "插入外部块&gt;&gt;" + strFilePath<BR>&nbsp;&nbsp; '-------------------------------------<BR>&nbsp;&nbsp; '重复插入<BR>&nbsp;&nbsp; '-------------------------------------<BR>&nbsp;&nbsp; If UserForm1.CheckBox1.Value &lt;&gt; 0 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rstr = ""<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rstr = ThisDrawing.Utility.GetString(2, NL &amp; "是否重复插入{" &amp; strFilePath &amp; "}?:")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If rstr = "" Then GoTo fun<BR>&nbsp;&nbsp; End If<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp; UserForm1.Show</P>
<P>&nbsp;End Sub</P>
<P>======================================================</P>
<P>插入外部块后。。。直接利用。。trim来删除中间的那部分的线。。点几下的事。。哈哈。。其它的方法目前还没有想到。。</P>
<P>&nbsp;</P>

lijinjie 发表于 2006-1-24 21:45:00

<P></P>
<P>二次开发专门用于。。电气原理图。。自己感觉和其它专业版本。。有的一比。。哈哈。</P>
页: [1]
查看完整版本: 问一个关于VBA处理...线与块的问题.