请教!!在展的时候怎么判断代码插入块
<p>Sub zgcd()<br/>Dim zb12 As String</p><p>Dim NN As Double<br/>Dim pn As Variant<br/>Dim pnt(0 To 2) As Double<br/>Dim blockRefObj As AcadBlockReference<br/>Dim blockRefObj1 As AcadBlockReference<br/>Dim textObj As AcadText<br/>Dim dh As String<br/>Dim x As Double<br/>Dim y As Double<br/>Dim z As Double<br/>Dim pcode As String<br/>Dim ly As AcadLayer<br/>'UserForm4.Show<br/>Dim ZG, BL As String<br/>Dim XA, XB As String<br/>Dim SBD As String<br/>''''''''''''''''''''''''''''''''''''''字高<br/>NN = 10 ^ E<br/>''''''''''''''''''''''''''''''''''''''''''''''''''<br/>If TextBox3.text <> "500" And TextBox3.text <> "1000" And TextBox3.text <> "2000" Then<br/>MsgBox "您输入比例尺有误,请重新输入比例尺!!!"<br/>Exit Sub<br/>End If<br/> If TextBox3.text = "500" Then<br/> ZG = "1.25"<br/> End If<br/> If TextBox3.text = "1000" Then<br/> ZG = "2.5"<br/> End If<br/> If TextBox3.text = "2000" Then<br/> ZG = "5"<br/> End If</p><p><br/>''''''''''''''''''''''''''''''''''''''比例<br/>If TextBox3.text = "500" Then<br/> BL = "0.5"<br/>End If<br/>If TextBox3.text = "1000" Then<br/> BL = "1"<br/>End If<br/>If TextBox3.text = "2000" Then<br/> BL = "2"<br/>End If</p><p></p><p>Set ly = ThisDrawing.Layers.Add("点")<br/>ly.Color = acRed<br/>Set ly = ThisDrawing.Layers.Add("代码")<br/>ly.Color = acRed<br/>Set ly = ThisDrawing.Layers.Add("高程")<br/>ly.Color = acGreen<br/>Set ly = ThisDrawing.Layers.Add("点号")<br/>ly.Color = acMagenta<br/>Set ly = ThisDrawing.Layers.Add("GCD")<br/>ly.Color = acGreen</p><p>Set ly = ThisDrawing.Layers.Add("yfh09")<br/>ly.Color = acGreen</p><p>UserForm1.CommonDialog1.Filter = "All Files|*.*|*.dat|*.dat|"<br/>UserForm1.CommonDialog1.FilterIndex = 2<br/>UserForm1.CommonDialog1.DefaultExt = ".dat"<br/>UserForm1.CommonDialog1.Action = 1<br/>fl1 = UserForm1.CommonDialog1.FileName<br/>If fl1 = "" Then Exit Sub<br/>Open fl1 For Input As #1<br/>Line Input #1, dh<br/>I = InStr(1, dh, ",")<br/>If I > 0 Then<br/>Close #1<br/>Open fl1 For Input As #1<br/>End If<br/>I = 0<br/>Do While Not EOF(1)<br/>On Error GoTo ex1<br/>Input #1, dh, pcode, x, y, z<br/>z = Fix((z * NN) + Sgn(z) * 0.00000000001) / NN<br/>pnt(0) = x<br/>pnt(1) = y<br/>pnt(2) = z<br/>SBD = "C:\YFH-MAP\SYM\SBD.dwg"<br/>If pnt(0) * pnt(1) * pnt(2) <> 0 Then<br/>Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(pnt, SBD, BL, BL, 1#, 0)<br/>blockRefObj.Layer = "GCD"<br/>blockRefObj.Color = acByLayer</p><p>''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''在此处判断pcode的名称</p><p>如果pcode="st"</p><p>就在此处插入一个块"zb12"</p><p>'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''以下代码不好使'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''</p><p>If pcode = "st" Then<br/>zb12 = "C:\YFH-MAP\SYM\zb12.dwg"<br/>Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(pnt, zb12, BL, BL, 1#, 0)<br/>blockRefObj.Layer = "yfh09"<br/>blockRefObj.Color = acByLayer<br/>End If</p><p>'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''以上代码不好使'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''</p><p>pnt(0) = pnt(0) + 1<br/>Set textObj = ThisDrawing.ModelSpace.AddText(pnt(2), pnt, ZG)<br/>textObj.Layer = "高程"<br/>textObj.Color = acByLayer</p><p>pnt(0) = pnt(0) - 3.5<br/>pnt(1) = pnt(1) + 0.5<br/>Set textObj = ThisDrawing.ModelSpace.AddText(dh, pnt, 2.5)<br/>textObj.Layer = "点号"<br/>textObj.Color = acByLayer</p><p>'pnt(0) = pnt(0) - 1<br/>pnt(1) = pnt(1) - 3.5<br/>Set textObj = ThisDrawing.ModelSpace.AddText(pcode, pnt, 2.5)<br/>textObj.Layer = "代码"<br/>textObj.Color = acByLayer</p><p>'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br/>I = I + 1<br/>End If<br/>Loop<br/>Close #1<br/>ex1:<br/>ThisDrawing.Application.ZoomExtents<br/>End Sub</p> 帮帮忙!!!拜托了!!! <strong>"在展的时候怎么判断代码插入块?"甚么意思?先把你想实现的功能和现在遇到的问题大概说一下,别人才容易明白你碰到甚么问题啊!</strong> <p>不好意思!!没有表达好!!</p><p>展点文件及格式如下:</p><p>点号,代码,Y横坐标,X纵坐标,高程 </p><p>1,ST,500000.000,300000.00,15.000</p><p>2,Z,500300.000,300500.00,15.000</p><p>3,ST,500800.000,300800.00,15.000</p><p>4,Z,501000.000,301000.00,15.000</p><p>我想在展点的时候,如果代码 = ST 就在这个坐标点上插入一个块</p> <div>展点的代码多的是,搜一下一大把,看了你的代码好繁琐哟,如</div><div> If TextBox3.text = "500" Then<br/> ZG = "1.25"<br/> End If<br/> If TextBox3.text = "1000" Then<br/> ZG = "2.5"<br/> End If<br/> If TextBox3.text = "2000" Then<br/> ZG = "5"<br/> End If<p> ......</p><p>其实:ZG=val(TextBox3.text)/4.0,结果写了一大堆<br/></p></div> <p>不知道你所谓的“不好使”是什么意思?</p><p>不过其中一条语句最好改成</p><p>Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(pnt, zb12, BL, BL, BL, 0)</p><p></p><p>就是图块的XYZ比例最好设置成一样的。</p>
页:
[1]