samshs 发表于 2008-12-23 13:56:00

可以给源码吗

meteorrite 发表于 2009-5-10 18:25:00

密码是多少啊!

subtlation 发表于 2009-6-6 22:46:00

<p>密码记不得了,下面是源码,可能和前面发的不完全一致。<br/><br/>'<br/>'&nbsp;&nbsp; 本软件免费可供进行任何用途需求的拷贝、修改及发行, 但请遵循下述原则:<br/>'<br/>'&nbsp;&nbsp; 1)&nbsp; 上列的版权通告必须出现在每一份拷贝里。<br/>'&nbsp;&nbsp; 2)&nbsp; 相关的说明文档也必须载有版权通告及本项许可通告。<br/>'<br/>'&nbsp;&nbsp; 本软件仅提供作为应用上的参考, 而未声明或隐含任何保证; 对于任何特殊<br/>'&nbsp;&nbsp; 用途之适应性, 以及商业销售所隐含作出的保证, 在此一概予以否认。</p><p>Sub copyAndChangeH()<br/>&nbsp; ThisDrawing.Utility.Prompt "欢迎使用《复制并改变标高》启动命令:CopyAndChangeH"<br/>&nbsp; '选择文字<br/>&nbsp; Dim ssetobjEx() As AcadObject<br/>&nbsp; On Error Resume Next<br/>&nbsp; <br/>&nbsp; Dim ssetobj As AcadSelectionSet<br/>&nbsp; ThisDrawing.SelectionSets("copyText").Delete<br/>&nbsp; Set ssetobj = ThisDrawing.SelectionSets.Add("copyText")<br/>&nbsp; <br/>&nbsp; ssetobj.SelectOnScreen<br/>&nbsp; If ssetobj.Count = 0 Then GoTo Finish '如果没有选择物体,结束程序<br/>&nbsp; <br/>&nbsp; Dim pickedObjs As AcadEntity<br/>&nbsp; ReDim ssetobjEx(0 To ssetobj.Count - 1) '数组,把复制后的物体成为ssetobj集合的中间步骤<br/>&nbsp; Dim k As Integer 'K为ssetobjex的下标<br/>&nbsp; Dim Att1 As Variant<br/>&nbsp; Dim n As Double<br/>&nbsp; n = getDrawScale / getPrintScale<br/>&nbsp; <br/>&nbsp; Dim pnt1, pnt2 As Variant<br/>&nbsp; pnt1 = ThisDrawing.Utility.GetPoint(, vbCrLf &amp; "选择复制起始点:")<br/>&nbsp; If Err Then GoTo Finish<br/>&nbsp; <br/>100&nbsp;&nbsp; pnt2 = ThisDrawing.Utility.GetPoint(pnt1, vbCrLf &amp; "选择复制终点:")<br/>&nbsp; If Err Then GoTo Finish<br/>&nbsp; k = 0<br/>&nbsp; For Each pickedObjs In ssetobj<br/>&nbsp;&nbsp;&nbsp; Set pickedObjsCopy = pickedObjs.Copy<br/>&nbsp;&nbsp;&nbsp; pickedObjsCopy.Move pnt1, pnt2<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; If pickedObjsCopy.ObjectName = "AcDbText" Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; weishu = Len(pickedObjsCopy.TextString) - InStr(pickedObjsCopy.TextString, ".")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; formatstring1 = "0." &amp; String(weishu, "0")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If InStr(UCase(pickedObjsCopy.TextString), "%%P") &lt;&gt; 0 Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pickedObjsCopy.TextString = Right(pickedObjsCopy.TextString, Len(pickedObjsCopy.TextString) - 3)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '如果有正负号,则先去除<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pickedObjsCopy.TextString = _<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Format(pickedObjsCopy.TextString + (pnt2(1) - pnt1(1)) * n / 1000, formatstring1)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '如果数字等于0,则加正负号<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Val(pickedObjsCopy.TextString) = 0 Then pickedObjsCopy.TextString = "%%p0.000"<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ElseIf pickedObjs.ObjectName = "AcDbBlockReference" Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Att1 = pickedObjsCopy.GetAttributes()<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; weishu = Len(Att1(0).TextString) - InStr(Att1(0).TextString, ".")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '如果有正负号,则先去除<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If InStr(UCase(Att1(0).TextString), "%%P") &lt;&gt; 0 Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Att1(0).TextString = Right(Att1(0).TextString, Len(Att1(0).TextString) - 3)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; formatstring1 = "0." &amp; String(weishu, "0")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Att1(0).TextString = _<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Format(Att1(0).TextString + (pnt2(1) - pnt1(1)) * n / 1000, formatstring1)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '如果数字等于0,则加正负号<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Val(Att1(0).TextString) = 0 Then Att1(0).TextString = "%%p0.000"<br/>&nbsp; End If<br/>&nbsp;&nbsp;&nbsp; Set ssetobjEx(k) = pickedObjsCopy<br/>&nbsp;&nbsp;&nbsp; k = k + 1<br/>&nbsp; Next<br/>&nbsp; pnt1 = pnt2<br/>&nbsp; ssetobj.Clear<br/>&nbsp; ssetobj.AddItems ssetobjEx<br/>&nbsp; Err.Clear<br/>&nbsp; GoTo 100<br/>Finish:<br/>&nbsp; ssetobj.Delete<br/>End Sub<br/>Public Function getDrawScale() As Double<br/>&nbsp; On Error Resume Next<br/>&nbsp; Dim res As Integer<br/>&nbsp; Dim def As Integer<br/>&nbsp; def = ThisDrawing.GetVariable("USERI4")<br/>&nbsp; Do<br/>&nbsp;&nbsp;&nbsp; res = ThisDrawing.Utility.GetInteger("请输入图形比例,例1:100应该输入100&lt;" &amp; def &amp; "&gt;:")<br/>&nbsp;&nbsp;&nbsp; If Err Then Err.Clear: res = def<br/>&nbsp;&nbsp;&nbsp; If res &lt;&gt; 0 Then Exit Do<br/>&nbsp; Loop<br/>&nbsp; ThisDrawing.SetVariable "USERI4", res<br/>&nbsp; getDrawScale = res<br/>End Function<br/>Public Function getPrintScale() As Double<br/>&nbsp; On Error Resume Next<br/>&nbsp; Dim res As Integer<br/>&nbsp; res = ThisDrawing.GetVariable("USERI5")<br/>&nbsp; If res = 0 Then<br/>&nbsp;&nbsp;&nbsp; res = ThisDrawing.Utility.GetInteger("请输入图形打印输出比例,例100:1应该输入100&lt;1&gt;:")<br/>&nbsp;&nbsp;&nbsp; If Err Then Err.Clear: res = 1<br/>&nbsp;&nbsp;&nbsp; ThisDrawing.SetVariable "USERI5", res<br/>&nbsp; End If<br/>&nbsp; getPrintScale = res<br/>End Function<br/></p>

461045462 发表于 2010-6-9 14:44:00

<p>可以复制,不会自动计算修改标高.</p>
<p>不过还是谢谢楼主。</p>

zhouxiuxin 发表于 2011-2-25 18:34:45

谢谢,受益非浅

oo191522416 发表于 2012-4-27 17:55:54

怎么用的呵!下了!什么都不变!感觉和COG一样

注册 发表于 2012-4-27 22:46:37

能用的示范一下撒,好像数字不会变的

3xxx 发表于 2012-5-11 19:12:20

这个我怎么没想过呢,至少思路就很好啊
页: 1 2 [3]
查看完整版本: [VBA]一个复制标高后同时改变标高数字的dvb文件