liusong0517 发表于 2008-4-1 19:53:00

<p>非常不错哦</p>

kh0773 发表于 2008-4-2 12:28:00

<p>哪位大哥能告诉偶怎么用呀?</p><p>&nbsp;&nbsp; 是以什么格式保存啊?</p>

chtd 发表于 2008-4-8 20:24:00

<p>几个线等分的例子:</p><p>Dim mysel As AcadSelectionSet<br/>Dim lay As AcadLayer<br/>Dim zb3(0 To 2) As Double<br/>Dim zb2(0 To 2) As Double<br/>Dim zbb(0 To 5) As Double<br/>Dim zb As Variant<br/>Dim jl As Double<br/>Dim jl1 As Double<br/>Dim jl2 As Double<br/>Dim jl4 As Double<br/>Dim zb1(0 To 2) As Double<br/>Dim jd As Double<br/>If ThisDrawing.SelectionSets.count = 0 Then<br/>Set mysel = ThisDrawing.SelectionSets.Add("mysel")<br/>AppActivate ThisDrawing.Application.Caption<br/>mysel.SelectOnScreen<br/>Else<br/>ThisDrawing.SelectionSets.Item(0).Delete<br/>Set mysel = ThisDrawing.SelectionSets.Add("mysel")<br/>AppActivate ThisDrawing.Application.Caption<br/>mysel.SelectOnScreen<br/>End If<br/>Dim sz As Long<br/>Dim cd As Double<br/>On Error GoTo dd<br/>jl1 = ThisDrawing.Utility.GetString(0, "请输入离散点间距:")<br/>dd = ThisDrawing.Utility.GetString(0, "请输入等分线长度:")<br/>For Each selentity In mysel<br/>&nbsp;&nbsp; If selentity.EntityType = 2 Then<br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zb = selentity.Coordinates<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jl = 0: sz = 2<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ReDim zuob(0 To sz) As Double<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For i = 0 To UBound(zb) - 3 Step 3<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'ReDim Preserve zuob(0 To sz) As Double<br/>&nbsp;&nbsp;&nbsp;&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sp;&nbsp; zbb(3) = zb1(0) - cd * Cos(jd): zbb(4) = zb1(1) + cd * Sin(jd): zbb(5) = zb1(2)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ThisDrawing.ModelSpace.Add3DPoly zbb</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sz = sz + 3<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jl = jl - jl1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jl4 = jl4 + jl1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Loop<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next<br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp; End If<br/>Next<br/>mysel.Delete<br/>dd:</p><p></p>

chtd 发表于 2008-4-8 20:25:00

<p>Dim mysel As AcadSelectionSet<br/>Dim lay As AcadLayer<br/>Dim zb(0 To 2) As Double</p><p>If ThisDrawing.SelectionSets.count = 0 Then<br/>Set mysel = ThisDrawing.SelectionSets.Add("mysel")<br/>AppActivate ThisDrawing.Application.Caption<br/>mysel.SelectOnScreen<br/>Else<br/>ThisDrawing.SelectionSets.Item(0).Delete<br/>Set mysel = ThisDrawing.SelectionSets.Add("mysel")<br/>AppActivate ThisDrawing.Application.Caption<br/>mysel.SelectOnScreen<br/>End If<br/>On Error GoTo dd<br/>cv = ThisDrawing.Utility.GetString(0, "请输入离散点间距:")<br/>If Val(cv) &gt; 0 Then<br/>Set lay = ThisDrawing.Layers.Add("离散点")<br/>ThisDrawing.ActiveLayer = lay<br/>For Each selentity In mysel<br/>If selentity.EntityType = 2 Then<br/>&nbsp;&nbsp; zuob = selentity.Coordinates<br/>&nbsp;&nbsp; zb(0) = zuob(3): zb(1) = zuob(4): zb(2) = zuob(5)<br/>&nbsp;&nbsp; ThisDrawing.Application.ZoomCenter zb, 1<br/>&nbsp;&nbsp; ThisDrawing.SendCommand "_measure" &amp; vbCr &amp; zb(0) &amp; "," &amp; zb(1) &amp; "," &amp; zb(2) &amp; vbCr &amp; cv &amp; vbCr<br/>selentity.Delete<br/>End If<br/>Next<br/>ThisDrawing.Application.ZoomExtents<br/>End If<br/>mysel.Delete<br/>dd:</p><p></p><p></p><p>Dim mysel As AcadSelectionSet<br/>Dim lay As AcadLayer<br/>Dim zb(0 To 2) As Double</p><p>If ThisDrawing.SelectionSets.count = 0 Then<br/>Set mysel = ThisDrawing.SelectionSets.Add("mysel")<br/>AppActivate ThisDrawing.Application.Caption<br/>mysel.SelectOnScreen<br/>Else<br/>ThisDrawing.SelectionSets.Item(0).Delete<br/>Set mysel = ThisDrawing.SelectionSets.Add("mysel")<br/>AppActivate ThisDrawing.Application.Caption<br/>mysel.SelectOnScreen<br/>End If<br/>On Error GoTo dd<br/>cv = ThisDrawing.Utility.GetString(0, "请输入离散点间距:")<br/>If Val(cv) &gt; 0 Then<br/>Set lay = ThisDrawing.Layers.Add("离散点")<br/>ThisDrawing.ActiveLayer = lay<br/>For Each selentity In mysel<br/>If selentity.EntityType = 2 Then<br/>&nbsp;&nbsp; zuob = selentity.Coordinates<br/>&nbsp;&nbsp; zb(0) = zuob(3): zb(1) = zuob(4): zb(2) = zuob(5)<br/>&nbsp;&nbsp; ThisDrawing.Application.ZoomCenter zb, 1<br/>&nbsp;&nbsp; ThisDrawing.SendCommand "_divide" &amp; vbCr &amp; zb(0) &amp; "," &amp; zb(1) &amp; "," &amp; zb(2) &amp; vbCr &amp; cv &amp; vbCr<br/>selentity.Delete<br/>End If<br/>Next<br/>ThisDrawing.Application.ZoomExtents<br/>End If<br/>mysel.Delete<br/>dd:</p>

AMTONNY 发表于 2008-4-30 20:32:00

找到大哥的感觉,----以后有人帮忙了

董堃 发表于 2008-4-30 20:48:00

<p>顶,虽然我不懂是什么代码</p>

yjc 发表于 2008-5-2 17:05:00

非常好,谢谢你了

chtd 发表于 2008-5-3 20:34:00

<p>批处理改高程值</p><p>Dim fpoint As Variant<br/>Dim tpoint(0 To 2) As Double<br/>If ThisDrawing.SelectionSets.count = 0 Then<br/>Set mysel = ThisDrawing.SelectionSets.Add("mysel")<br/>AppActivate ThisDrawing.Application.Caption<br/>mysel.SelectOnScreen<br/>Else<br/>ThisDrawing.SelectionSets.Item(0).Delete<br/>Set mysel = ThisDrawing.SelectionSets.Add("mysel")<br/>AppActivate ThisDrawing.Application.Caption<br/>mysel.SelectOnScreen<br/>End If</p><p>dd = ThisDrawing.Utility.GetString(0, "请输入要加的数值:")<br/>dd1 = ThisDrawing.Utility.GetString(0, "请输入要保留小数位数:")<br/>Dim dws As String<br/>dws = "#######."<br/>For i = 1 To dd1<br/>&nbsp;&nbsp;&nbsp; dws = dws + "0"<br/>Next<br/>For Each sel In mysel<br/>&nbsp;&nbsp;&nbsp; If sel.EntityType = 32 Or sel.EntityType = 21 Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sel.TextString = Format(Val(sel.TextString) + Val(dd), dws)<br/>&nbsp;&nbsp;&nbsp; ElseIf sel.EntityType = 7 Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fpoint = sel.InsertionPoint<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tpoint(0) = fpoint(0): tpoint(1) = fpoint(1)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tpoint(2) = Val(Format(fpoint(2) + Val(dd), dws))<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sel.Move fpoint, tpoint<br/>&nbsp;&nbsp;&nbsp; ElseIf sel.EntityType = 22 Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fpoint = sel.Coordinates<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tpoint(0) = fpoint(0): tpoint(1) = fpoint(1)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tpoint(2) = Val(Format(fpoint(2) + Val(dd), dws))<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sel.Move fpoint, tpoint<br/>&nbsp;&nbsp;&nbsp; End If<br/>Next</p><p>If mysel.count &lt;&gt; 0 Then<br/>&nbsp;&nbsp; mysel.Delete<br/>End If</p>

chtd 发表于 2008-5-3 20:39:00

<p>三维线注标高</p><p>Dim zuobiao As Variant<br/>Dim zuob As Variant<br/>Dim zuobb(0 To 2) As Double<br/>On Error GoTo we<br/>For i = 0 To 10000<br/>ThisDrawing.SetVariable "OSMODE", 512<br/>aat = ThisDrawing.Utility.GetInput()<br/>Dim mysel As AcadSelectionSet<br/>If ThisDrawing.SelectionSets.count = 0 Then<br/>Set mysel = ThisDrawing.SelectionSets.Add("mysel")<br/>AppActivate ThisDrawing.Application.Caption<br/>zuobiao = ThisDrawing.Utility.GetPoint(, "请选择:")<br/>mysel.SelectAtPoint zuobiao<br/>Else<br/>ThisDrawing.SelectionSets.Item(0).Delete<br/>AppActivate ThisDrawing.Application.Caption<br/>Set mysel = ThisDrawing.SelectionSets.Add("mysel")<br/>zuobiao = ThisDrawing.Utility.GetPoint(, "请选择:")<br/>mysel.SelectAtPoint zuobiao<br/>End If<br/>ThisDrawing.SetVariable "OSMODE", 0<br/>If mysel.count = 1 Then<br/>&nbsp; If mysel(0).EntityType = 2 Then<br/>&nbsp; zuob = mysel(0).Coordinates<br/>&nbsp; zuobb(0) = zuobiao(0): zuobb(1) = zuobiao(1): zuobb(2) = zuob(2)<br/>&nbsp;&nbsp; retAngle = ThisDrawing.Utility.GetAngle(, "Enter an angle: ")<br/>&nbsp;&nbsp; Set zj2 = ThisDrawing.ModelSpace.addtext(Int(zuob(2)), zuobb, 3.75)<br/>&nbsp;&nbsp; zj2.Alignment = acAlignmentMiddle<br/>&nbsp;&nbsp; zj2.TextAlignmentPoint = zuobb<br/>&nbsp;&nbsp; zj2.ScaleFactor = 1<br/>&nbsp;&nbsp; zj2.Rotation = retAngle - 80<br/>&nbsp;&nbsp; zj2.Update<br/>End If<br/>&nbsp; End If<br/>If mysel.count &lt;&gt; 0 Then<br/>&nbsp;&nbsp; mysel.Delete<br/>End If<br/>Next<br/>we:<br/>ThisDrawing.SetVariable "OSMODE", 0</p>

chtd 发表于 2008-5-3 20:42:00

拿出一些程序原码与大家交流,希望与大家探讨,共同进步!
页: 1 [2] 3 4 5 6
查看完整版本: 作了几个程序