坐标高程里程点号标记源码
<p>Sub bj()<br/>'xlSheet.Range(xlSheet.Cells(1, 1), xlSheet.Cells(1, 6)).Merge<br/> 'excel.Cells.HorizontalAlignment = excel.xlHAlignCenter<br/>Dim returnObj As Acad3DPolyline<br/>Dim basepnt As Variant<br/>Dim diannum As Double<br/>Dim x1() As Double<br/>Dim y1() As Double<br/>Dim h1() As Double<br/>Dim lc() As Double<br/>On Error Resume Next<br/> ' The following example waits for a selection from the user<br/> ThisDrawing.Utility.GetEntity returnObj, basepnt, "选择多段线"<br/> ' Create a lightweight Polyline object in model space<br/> n = UBound(returnObj.Coordinates)<br/> diannum = n + 1 / 3<br/> xyz = returnObj.Coordinates<br/> Dim zb(0 To 2) As Double<br/> Dim zb1(0 To 2) As Double<br/> s = 0<br/> p = 0<br/>ReDim x1((n + 1) / 3)<br/>ReDim y1((n + 1) / 3)<br/>ReDim h1((n + 1) / 3)<br/>ReDim lc(n + 1)<br/>For w = 0 To n Step 3<br/>zb(0) = xyz(w)<br/>zb(1) = xyz(w + 1)<br/>zb(2) = xyz(w + 2)<br/>zb1(0) = xyz(w + 3)<br/>zb1(1) = xyz(w + 4)<br/>zb1(2) = xyz(w + 5)<br/>Dim s1 As Double<br/>s1 = Sqr((zb(0) - zb1(0)) ^ 2 + (zb(1) - zb1(1)) ^ 2)<br/>x1(p) = zb(0)<br/>y1(p) = zb(1)<br/>h1(p) = zb(2)<br/>lc(p) = s<br/>s = s + s1<br/>p = p + 1<br/>Next w<br/>ee = x1(0)<br/>Dim a As Double<br/>Dim zf1 As String<br/>Dim zf2 As String<br/>Dim zf3 As String<br/>Dim newlayer As AcadLayer<br/>Set newlayer = ThisDrawing.Layers.Add("C_坐标")<br/>ThisDrawing.ActiveLayer = newlayer<br/>newlayer.Lineweight = acLnWt013<br/>newlayer.Linetype = "Continuous"<br/>a = ThisDrawing.activetextstyle.height<br/>If a = 0 Then<br/>mystring = MsgBox("请输入文本高度,", vbYesNo + vbCritical + vbDefaultButton2, "提示框")<br/>GoTo error<br/>End If<br/>pt = ThisDrawing.Utility.GetPoint(, "拾取注记点")<br/>ee = x1(0)<br/>For w1 = 0 To diannum<br/>aaa = x1(w1)<br/>bbb = y1(w1)<br/>q = x1(1): q1 = x1(2): q2 = x1(3): q3 = x1(4)<br/>If Abs(pt(0) - aaa) < 0.1 And Abs(pt(1) - bbb) < 0.1 Then dianhao = w1: GoTo 10<br/>11<br/>Next w1<br/>10<br/>pt1 = ThisDrawing.Utility.GetPoint(, "拾取标识点")<br/>Dim ptcen<br/>Dim ptcen1<br/>ptcen = ThisDrawing.Utility.TranslateCoordinates(pt, acWorld, acUCS, False)<br/>Dim x As String '注意一定要是文本类型<br/>Dim y As String '注意一定要是文本类型<br/>Dim h As String '注意一定要是文本类型<br/>zf1 = "X=": zf2 = "Y=": zf3 = "H="<br/>y = zf2 & Format(x1(dianhao), "###0.000") '定义小数点位数<br/>x = zf1 & Format(y1(dianhao), "###0.000") '定义小数点位数<br/>h = zf3 & Format(h1(dianhao), "###0.000") '定义小数点位数<br/>KK = "K" & Format(lc(dianhao), "##0+##0.000")<br/>dianhao1 = dianhao + 1<br/>If dianhao1 <= 9 And dianhao >= 0 Then dh = "QZ00" & dianhao1<br/>If dianhao1 >= 10 And dianhao <= 99 Then dh = "QZ0" & dianhao1<br/>If dianhao1 >= 100 And dianhao <= 999 Then dh = "QZ" & dianhao1<br/>Dim k(0 To 2) As Double<br/>Dim k1(0 To 2) As Double<br/>Dim k6(0 To 2) As Double<br/>Dim k7(0 To 2) As Double<br/>Dim k8(0 To 2) As Double<br/>k(0) = pt1(0)<br/>k(1) = pt1(1) - a - 0.4 * a<br/>k(2) = 0</p><p>k1(0) = pt1(0)<br/>k1(1) = pt1(1) + 0.4 * a<br/>k1(2) = 0</p><p>k6(0) = pt1(0)<br/>k6(1) = pt1(1) + a + 0.8 * a<br/>k6(2) = 0</p><p>k7(0) = pt1(0)<br/>k7(1) = pt1(1) + 2 * a + 1.2 * a<br/>k7(2) = 0</p><p>k8(0) = pt1(0)<br/>k8(1) = pt1(1) + 3 * a + 1.6 * a<br/>k8(2) = 0</p><p>Dim txtobj As AcadText<br/>Dim txtobj1 As AcadText<br/>Dim txtobj2 As AcadText<br/>Dim txtobj3 As AcadText<br/>Dim txtobj4 As AcadText<br/>Set txtobj = ThisDrawing.ModelSpace.AddText(dh, k, a)<br/>Set txtobj1 = ThisDrawing.ModelSpace.AddText(KK, k1, a)<br/>Set txtobj2 = ThisDrawing.ModelSpace.AddText(h, k6, a)<br/>Set txtobj3 = ThisDrawing.ModelSpace.AddText(y, k7, a)<br/>Set txtobj4 = ThisDrawing.ModelSpace.AddText(x, k8, a)<br/>Dim m1, n1 As Variant<br/>txtobj.GetBoundingBox m1, n1<br/>Dim dist As Double<br/>dist = n1(0) - m1(0)<br/>Dim m2, n2 As Variant<br/>txtobj1.GetBoundingBox m2, n2<br/>Dim dist1 As Double<br/>dist1 = n2(0) - m2(0)<br/>If dist <= dist1 Then dist2 = dist1 Else dist2 = dist<br/>Dim m3, n3 As Variant<br/>txtobj2.GetBoundingBox m3, n3<br/>Dim dist3 As Double<br/>dist3 = n3(0) - m3(0)<br/>If dist2 <= dist3 Then dist4 = dist3 Else dist4 = dist2<br/>Dim k2(0 To 2) As Double<br/>If pt1(0) > pt(0) Then GoTo 50 Else GoTo 60<br/>50<br/>k2(0) = pt1(0) + dist4<br/>k2(1) = pt1(1)<br/>k2(2) = 0<br/>GoTo 100<br/>60<br/>k2(0) = pt1(0) - dist4<br/>k2(1) = pt1(1)<br/>k2(2) = 0<br/>Dim k3(0 To 2) As Double<br/>Dim k4(0 To 2) As Double<br/>Dim k5(0 To 2) As Double<br/>Dim k9(0 To 2) As Double<br/>Dim k10(0 To 2) As Double<br/>k3(0) = k2(0)<br/>k3(1) = k2(1) - a - 0.4 * a<br/>k3(2) = 0</p><p>k4(0) = k2(0)<br/>k4(1) = k2(1) + 0.4 * a<br/>k4(2) = 0</p><p>k5(0) = k2(0)<br/>k5(1) = k2(1) + a + 0.8 * a<br/>k5(2) = 0</p><p>k9(0) = k2(0)<br/>k9(1) = k2(1) + 2 * a + 1.2 * a<br/>k9(2) = 0</p><p>k10(0) = k2(0)<br/>k10(1) = k2(1) + 3 * a + 1.6 * a<br/>k10(2) = 0</p><p>txtobj.Move k, k3<br/>txtobj1.Move k1, k4<br/>txtobj2.Move k6, k5<br/>txtobj3.Move k7, k9<br/>txtobj4.Move k8, k10<br/>GoTo 100<br/>100<br/>Set pliobj = ThisDrawing.ModelSpace.AddLine(pt, pt1)<br/>Set pliobj = ThisDrawing.ModelSpace.AddLine(pt1, k2)<br/>error:<br/>Exit Sub<br/>End Sub</p> 本人对LISP函数不熟悉,那位高人能将一楼的vba源码转换成LISP源码,发份至<a href="mailto:gzxl90@126.com">gzxl90@126.com</a>,万分感谢! 楼上说的是!谢谢
页:
[1]