根据三角网计算开挖边坡顶线,高程要够密度准确些PDPJ
本帖最后由 树櫴希德 于 2023-6-2 12:40 编辑根据三角网计算开挖边坡顶线,高程要够密度准确些
(defun mkgcd (inspt heightscale/ ptpt1 blkdef obj)
(setvar "CMDECHO" 0)
(command "layer" "m" "检查高程点" "c" "1" "" "L" "CONTINUOUS" """")
(if height
(setq height (rtos height 2 3))
(setq height "")
)
(regapp "SOUTH")
;;;检查字体 "HZ" 是否存在
(if (not (tblobjname "style" "HZ"))
(command "style" "HZ" "rs.shx,hztxt.shx" 0 1 0 "" "" "")
)
;;;检查是否存在高程点图块定义
(if (not (tblobjname "block" "GC2000"))
(progn
;13、entmake生成普通块
(defun emkblk ( pt name /)
(entmake (list '(0 . "block") (cons 2 name) '(70 . 0) (cons 10 pt)))
(entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 4) (cons 10 (list (+ (car pt) 0.75)(+ (cadr pt) 1) ))(cons 10 pt) (cons 10 (list (- (car pt) 0.75)(+ (cadr pt) 1) ))
(cons 10 (list (+ (car pt) 4.25)(+ (cadr pt) 1) ))
))
(entmake '((0 . "ENDBLK")))
;(entmake (list '(0 . "INSERT") (cons 2 name) (cons 10 pt)))
)
(emkblk '(0 0) "GC2000")
)
)
;;;插入块
(entmake (list
'(0 . "INSERT")
'(100 . "AcDbEntity")
'(100 . "AcDbBlockReference")
'(66 . 1);;;属性跟随标志,1跟随,0不跟随
(cons 2 "GC2000")
(cons 10 inspt)
(cons 41 scale)
(cons 42 scale)
(cons 43 scale)
'(-3 ("SOUTH" (1000 . "202101")))
)
)
;;;插入属性
(entmake (list
'(0 . "ATTRIB")
'(100 . "AcDbEntity")
'(100 . "AcDbText")
(cons 10 (setq pt (polar inspt (* 0.5 PI) (* 2.25 scale))))
(cons 40 (* 2.0 scale))
(cons 50 0)
(cons 62 3)
(cons 41 0.8)
(cons 51 0)
(cons 1 height)
(cons 7 "HZ")
(cons 72 0)
(cons 11 pt)
'(100 . "AcDbAttribute")
(cons 2 "height")
(cons 700)
(cons 74 2)
)
)
;;;;;;;;;;;;;;;;;;;;;;;
;;;插入属性
;;;结束标志
(entmake '((0 . "SEQEND")))
(princ)
)
;;;;;;;;===========================================
;; 测量选定曲线上两点之间的距离
(defun apkl (ENOBJ p1 p2 / DIST DIST1 DIST2 EN ENOBJ OSM P1 P2)
;;;来源:QQ群友:GreenWood(181976640)。属QQ群:SP编程,e派<a href="http://bbs.mjtd.com/forum-6-1.html" target="_blank" class="relatedlink">工具</a>箱,摄影24942984
;(setq ENOBJ (CAR (ENTSEL)))
;(setq p1 (getpoint "\n选择曲线上的一点:"))
;(setq p2 (getpoint "\n选择曲线上的另一点:"))
(setq dist1 (vlax-curve-getDistAtPoint enobj p1))
(setq dist2 (vlax-curve-getDistAtPoint enobj p2))
;(print "\n测量段曲线长度:")
(setq dist (abs (- dist1 dist2)))
dist
)
(defun c:bg11 (/ ENOBJ p1 p2 s1 s2 p3dist gcc bz dist1 xgc p33)
(setq ENOBJ (CAR (ENTSEL "\n请选择线段")))
(setq p1 (getpoint "\n选择曲线上的一点:"))
(setq s1 (getreal "\n请输入该点标高:"))
(setq p2 (getpoint "\n选择曲线上的另一点:"))
(setq s2 (getreal "\n请输入该点标高:"))
(setq dist (apkl ENOBJ p1 p2 ))
(setq gcc (- s1 s2))
(setq bz (/ gcc dist))
(while (setq p33 (getpoint "\n选择曲线上要查询的一点:")
p3 (vlax-curve-getClosestPointTo ENOBJ p33 T)
)
(setq dist1 (apkl ENOBJ p3 p2 ) )
(setq xgc (+ s2 (* dist1 bz )))
(mkgcd p3 xgc1)
(command "rotate" (entlast) "" p3 (* (- (angle p3 p33) (/ pi 2) ) (/ 180 pi) ))
;(entmake (list '(0 . "TEXT") '(8 . "fgbj")(cons 1 (rtos xgc 2 3)) (cons 10 p3 ) (cons 40 1.0)))
)
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;by Gu_xl
(defun gxl-cs:gcd (inspt height scale / pt blkdef obj);展高程点函数(inspt:插入点,heitht:高程值,scale:缩放比例,xsws:高程注记位数)
(vl-load-com) ;将 Visual LISP 扩展功能加载到 AutoLISP
(regapp "SOUTH")
(setvar "CMDECHO" 0)
(command "layer" "m" "GCD" "c" "1" "" "L" "CONTINUOUS" """")
(if height
(setq height (rtos height 2 3));3为高程注记位数
(setq height "")
)
(regapp "SOUTH")
;;;检查字体 "HZ" 是否存在
(if (not (tblobjname "style" "宋体"))
;(command "style" "HZ" "rs.shx,hztxt.shx" 0 1 0 "" "" "")
(command "style" "宋体" "" 0 1 0 "" "" "")
)
;;;检查是否存在高程点图块定义
(if (not (tblobjname "block" "GC200"))
(progn
(setq blkdef (vla-Add (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))) (vlax-3D-point '(0 0 0)) "GC200"))
(setq obj
(vla-AddPolyline
blkdef
(vlax-make-variant
(vlax-safearray-fill
(vlax-make-safearray vlax-vbdouble (cons 0 5))
'(-0.2 0 0 0.2 0 0)
)
)
)
)
(vla-SetBulge obj 0 1) (vla-SetBulge obj 1 1)
(vla-put-Closed obj :vlax-true)
(vla-put-ConstantWidth obj 0.4)
)
)
;;;插入块
(entmake (list
'(0 . "INSERT")
'(100 . "AcDbEntity")
'(100 . "AcDbBlockReference")
'(66 . 1);;;属性跟随标志,1跟随,0不跟随
(cons 2 "GC200")
(cons 10 inspt)
(cons 41 scale)
(cons 42 scale)
(cons 43 scale)
(list -3 '("SOUTH" (1000 . "202101")))
)
)
;;;插入属性
(entmake (list
'(0 . "ATTRIB")
'(100 . "AcDbEntity")
'(100 . "AcDbText")
(cons 10 (setq pt (polar inspt 0 (* 1.2 scale))))
(cons 40 (* 2.0 scale))
(cons 50 0)
(cons 41 0.8)
(cons 51 0)
(cons 1 height)
(cons 7 "宋体")
(cons 62 3)
(cons 72 0)
(cons 11 pt)
'(100 . "AcDbAttribute")
(cons 2 "height")
(cons 700)
(cons 74 2)
)
)
;;;结束标志
(entmake '((0 . "SEQEND")))
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun PoInPl(pt p / n i va ang);;该过程由 StEf44604813提供,本人只是把输出由原来的t,nil改为了-1,0,1
(setq n(length pt)
pt(append pt(list(car pt)))i 0 ang 0)
(while(< i n)
(setq va(-(angle p(nth i pt))(angle p(nth(1+ i)pt))))
(if (<(abs(-(abs va)pi))0.000001)(setq ang 2 i n)
(progn(cond((> va pi)(setq va (- va pi)))
((< va (* -1 pi))(setq va (+ va pi))))
(setq ang(+ ang va)i(1+ i)))))
(if(= ang 2)0
(if(<(abs(-(abs ang) pi))0.000001)1 -1))
)
;defun
(defun plinexy(e / a q m p);;;LWPolyline,POLYLINE顶点,去掉完全重合点
(setq a(vlax-ename->vla-object e)
q(vlax-safearray->list(vlax-variant-value(vla-get-Coordinates a)))
m(vla-get-objectname a)a 0
m(if(= m"AcDb3dPolyline")3 2))
(repeat(/(length q)m)
(cond((= m 2)(setq p1(list(nth a q)(nth(+ a 1)q))))
((= m 3)(setq p1(list(nth a q)(nth(+ a 1)q)(nth(+ a 2)q)))))
(setq p(if (member p1 p)p (append p(list p1)))
a(+ a m)))
p)
(defun xyp-Pline (lst / lst pt)
(entmake (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (length lst))'(70 . 129))
(mapcar '(lambda (pt)(cons 10 pt)) lst ))
) (vl-cmdf "_.region" (entlast) "") (entlast)
)
;;改改更贱康
(defun temp (pa pb p0 p1 p2 / MAT:vxv {vp} {v} a b)
(defun MAT:vxv (u v)
(list
(- (* (cadr u) (caddr v)) (* (cadr v) (caddr u)))
(- (* (car v) (caddr u)) (* (car u) (caddr v)))
(- (* (car u) (cadr v)) (* (car v) (cadr u)))
)
)
(setq {vp} (MAT:vxv (mapcar '- p1 p0) (mapcar '- p2 p0)))
(setq {v} (mapcar '- pa pb))
(setqa (apply '+
(mapcar '(lambda (n m vp) (* (- n m) vp)) p0 pa {vp})
)
)
(setq b (apply '+ (mapcar '* {vp} {v})))
(if (equal b 0.0 1e-6)
nil
(mapcar '(lambda (m v) (+ m (* v (/ a b)))) pa {v})
)
)
(defun insertgc ( e / e)
(cdr(assoc 10(entget e))))
(defun c:pdpj ( /ENOBJ p1 p2 s1 s2 p3 p33 dist gcc bz dist1 xgc p33 podu blcp11 ang p22 pts1 pts ssa ii en ptb pzx pzx1 no)
(setq blc (getint "\n请输入比例尺1:<500>"))
(if (= blc nil)(setq blc 500))
(setvar 'userr1 blc);设置比例尺
(setq scale (* 0.001 blc));缩放比例
(setq podu (getreal "\n请输入坡度1:(挖+填-)?"))
;;;;;
(setq ENOBJ (CAR (ENTSEL "\n请选择线段")))
(setq p1 (getpoint "\n选择曲线上的一点:"))
(setq s1 (getreal "\n请输入该点标高:"))
(setq p2 (getpoint "\n选择曲线上的另一点:"))
(setq s2 (getreal "\n请输入该点标高:"))
(setq dist (apkl ENOBJ p1 p2 ))
(setq gcc (- s1 s2))
(setq bz (/ gcc dist))
(while (setq p33 (getpoint "\n选择曲线上要查询的一点:")
)
(setqp3 (vlax-curve-getClosestPointTo ENOBJ p33 T))
(setq dist1 (apkl ENOBJ p3 p2 ) )
(setq xgc (+ s2 (* dist1 bz )))
;(mkgcd p3 xgc1)
(gxl-cs:gcd p3 xgc scale)
;(setq p1 (insertgc(car(entsel "\n请选择坡顶或者坡脚:"))))
(setq p11 (list (car p3 ) (cadr p3) xgc))
;(setq ang (getangle p1 "\n请指定顶或者坡脚哪个方向? "))
(setq ang(angle p11 p33))
(setq p22 (polar p11 ang 100))
(setq pts1 (list p11 (append (vl-remove (last p22)p22) (list(+ (last p11 )(/ 100podu ))))))
;(print pts1)
(setq pts (list (vl-remove (last p11)p11) p22))
(vl-cmdf "zoom" "e")
(setq ssa (ssget "f" pts'((0 . "POLYLINE") (8 . "sjw"))))
;(sssetfirst nil ssa)
(setq ii 0
no0)
(repeat (sslength ssa)
(setq en (ssname ssa ii)
ptb (plinexy en)
;demj (vlax-curve-getArea(vlax-ename->vla-object en))
pzx (append pzx (list ptb))
ii(1+ ii))
)
;(setvar "osmode"16384)
(foreach x pzx
(setq pzx1 (temp (car pts1) (cadr pts1) (car x) (cadr x)(caddr x) ))
(if (and (/= pzx1 nil)
(>= (poinpl (mapcar '(lambda (b)(vl-remove (last b)b))x) (vl-remove (last pzx1)pzx1))0))
(progn (print pzx1)(gxl-cs:gcd pzx1 (last pzx1) scale))
)
)
(vl-cmdf "zoom" "p")
;(command "rotate" (entlast) "" p3 (* (- (angle p3 p33) (/ pi 2) ) (/ 180 pi) ))
;(entmake (list '(0 . "TEXT") '(8 . "fgbj")(cons 1 (rtos xgc 2 3)) (cons 10 p3 ) (cons 40 1.0)))
)
(princ)
)
厉害!!!!!! (vlax-curve-getClosestPointToProjection (vlax-ename->vla-object (car(entsel)))(getpoint) '(0.0 0.0 1.0) t)在将曲线投影到平面上之后,返回曲线上的最近点(在 WCS 上)
(vlax-curve-getClosestPointToProjection curve-objgivenPnt normal )
说明1)参数 curve-obj 为要测量的 VLA 对象。2)参数 givenPnt 为WCS 中的点,在曲线上寻找该点的最近点。3)参数 normal 为WCS 中的法线矢量,指定投影平面。4)参数 extend 若指定该参数且其值不为 nil,vlax-curve-getClosestPointToProjection 在搜索最近点时扩展曲线。5)vlax-curve-getClosestPointToProjection 先将曲线投影到由 givenPnt 和 normal 定义的平面上,后在该平面上计算距 givenPnt 最近的点。最后,vlax-curve-getClosestPointToProjection 将结果点重新投影到原来的曲线上,并返回投影后的点。返回值:若成功,则返回表示曲线上一点的三维点表,否则返回 nil
(entmake (list '(0 . "CIRCLE") (cons 10 (vlax-curve-getClosestPointToProjection (vlax-ename->vla-object (car(entsel)))(getpoint) '(0.0 0.0 1.0) t)) (cons 40 5)))
如果坡顶坡脚是三维多段线还好用一些
(defun mkgcd (inspt heightscale/ ptpt1 blkdef obj)
(setvar "CMDECHO" 0)
(command "layer" "m" "检查高程点" "c" "1" "" "L" "CONTINUOUS" """")
(if height
(setq height (rtos height 2 3))
(setq height "")
)
(regapp "SOUTH")
;;;检查字体 "HZ" 是否存在
(if (not (tblobjname "style" "HZ"))
(command "style" "HZ" "rs.shx,hztxt.shx" 0 1 0 "" "" "")
)
;;;检查是否存在高程点图块定义
(if (not (tblobjname "block" "GC2000"))
(progn
;13、entmake生成普通块
(defun emkblk ( pt name /)
(entmake (list '(0 . "block") (cons 2 name) '(70 . 0) (cons 10 pt)))
(entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 4) (cons 10 (list (+ (car pt) 0.75)(+ (cadr pt) 1) ))(cons 10 pt) (cons 10 (list (- (car pt) 0.75)(+ (cadr pt) 1) ))
(cons 10 (list (+ (car pt) 4.25)(+ (cadr pt) 1) ))
))
(entmake '((0 . "ENDBLK")))
;(entmake (list '(0 . "INSERT") (cons 2 name) (cons 10 pt)))
)
(emkblk '(0 0) "GC2000")
)
)
;;;插入块
(entmake (list
'(0 . "INSERT")
'(100 . "AcDbEntity")
'(100 . "AcDbBlockReference")
'(66 . 1);;;属性跟随标志,1跟随,0不跟随
(cons 2 "GC2000")
(cons 10 inspt)
(cons 41 scale)
(cons 42 scale)
(cons 43 scale)
'(-3 ("SOUTH" (1000 . "202101")))
)
)
;;;插入属性
(entmake (list
'(0 . "ATTRIB")
'(100 . "AcDbEntity")
'(100 . "AcDbText")
(cons 10 (setq pt (polar inspt (* 0.5 PI) (* 2.25 scale))))
(cons 40 (* 2.0 scale))
(cons 50 0)
(cons 62 3)
(cons 41 0.8)
(cons 51 0)
(cons 1 height)
(cons 7 "HZ")
(cons 72 0)
(cons 11 pt)
'(100 . "AcDbAttribute")
(cons 2 "height")
(cons 700)
(cons 74 2)
)
)
;;;;;;;;;;;;;;;;;;;;;;;
;;;插入属性
;;;结束标志
(entmake '((0 . "SEQEND")))
(princ)
)
;;;;;;;;===========================================
;; 测量选定曲线上两点之间的距离
(defun apkl (ENOBJ p1 p2 / DIST DIST1 DIST2 EN ENOBJ OSM P1 P2)
;;;来源:QQ群友:GreenWood(181976640)。属QQ群:SP编程,e派<a href="http://bbs.mjtd.com/forum-6-1.html" target="_blank" class="relatedlink">工具</a>箱,摄影24942984
;(setq ENOBJ (CAR (ENTSEL)))
;(setq p1 (getpoint "\n选择曲线上的一点:"))
;(setq p2 (getpoint "\n选择曲线上的另一点:"))
(setq dist1 (vlax-curve-getDistAtPoint enobj p1))
(setq dist2 (vlax-curve-getDistAtPoint enobj p2))
;(print "\n测量段曲线长度:")
(setq dist (abs (- dist1 dist2)))
dist
)
(defun c:bg11 (/ ENOBJ p1 p2 s1 s2 p3dist gcc bz dist1 xgc p33)
(setq ENOBJ (CAR (ENTSEL "\n请选择线段")))
(setq p1 (getpoint "\n选择曲线上的一点:"))
(setq s1 (getreal "\n请输入该点标高:"))
(setq p2 (getpoint "\n选择曲线上的另一点:"))
(setq s2 (getreal "\n请输入该点标高:"))
(setq dist (apkl ENOBJ p1 p2 ))
(setq gcc (- s1 s2))
(setq bz (/ gcc dist))
(while (setq p33 (getpoint "\n选择曲线上要查询的一点:")
p3 (vlax-curve-getClosestPointTo ENOBJ p33 T)
)
(setq dist1 (apkl ENOBJ p3 p2 ) )
(setq xgc (+ s2 (* dist1 bz )))
(mkgcd p3 xgc1)
(command "rotate" (entlast) "" p3 (* (- (angle p3 p33) (/ pi 2) ) (/ 180 pi) ))
;(entmake (list '(0 . "TEXT") '(8 . "fgbj")(cons 1 (rtos xgc 2 3)) (cons 10 p3 ) (cons 40 1.0)))
)
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;by Gu_xl
(defun gxl-cs:gcd (inspt height scale / pt blkdef obj);展高程点函数(inspt:插入点,heitht:高程值,scale:缩放比例,xsws:高程注记位数)
(vl-load-com) ;将 Visual LISP 扩展功能加载到 AutoLISP
(regapp "SOUTH")
(setvar "CMDECHO" 0)
(command "layer" "m" "GCD" "c" "1" "" "L" "CONTINUOUS" """")
(if height
(setq height (rtos height 2 3));3为高程注记位数
(setq height "")
)
(regapp "SOUTH")
;;;检查字体 "HZ" 是否存在
(if (not (tblobjname "style" "宋体"))
;(command "style" "HZ" "rs.shx,hztxt.shx" 0 1 0 "" "" "")
(command "style" "宋体" "" 0 1 0 "" "" "")
)
;;;检查是否存在高程点图块定义
(if (not (tblobjname "block" "GC200"))
(progn
(setq blkdef (vla-Add (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))) (vlax-3D-point '(0 0 0)) "GC200"))
(setq obj
(vla-AddPolyline
blkdef
(vlax-make-variant
(vlax-safearray-fill
(vlax-make-safearray vlax-vbdouble (cons 0 5))
'(-0.2 0 0 0.2 0 0)
)
)
)
)
(vla-SetBulge obj 0 1) (vla-SetBulge obj 1 1)
(vla-put-Closed obj :vlax-true)
(vla-put-ConstantWidth obj 0.4)
)
)
;;;插入块
(entmake (list
'(0 . "INSERT")
'(100 . "AcDbEntity")
'(100 . "AcDbBlockReference")
'(66 . 1);;;属性跟随标志,1跟随,0不跟随
(cons 2 "GC200")
(cons 10 inspt)
(cons 41 scale)
(cons 42 scale)
(cons 43 scale)
(list -3 '("SOUTH" (1000 . "202101")))
)
)
;;;插入属性
(entmake (list
'(0 . "ATTRIB")
'(100 . "AcDbEntity")
'(100 . "AcDbText")
(cons 10 (setq pt (polar inspt 0 (* 1.2 scale))))
(cons 40 (* 2.0 scale))
(cons 50 0)
(cons 41 0.8)
(cons 51 0)
(cons 1 height)
(cons 7 "宋体")
(cons 62 3)
(cons 72 0)
(cons 11 pt)
'(100 . "AcDbAttribute")
(cons 2 "height")
(cons 700)
(cons 74 2)
)
)
;;;结束标志
(entmake '((0 . "SEQEND")))
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun PoInPl(pt p / n i va ang);;该过程由 StEf44604813提供,本人只是把输出由原来的t,nil改为了-1,0,1
(setq n(length pt)
pt(append pt(list(car pt)))i 0 ang 0)
(while(< i n)
(setq va(-(angle p(nth i pt))(angle p(nth(1+ i)pt))))
(if (<(abs(-(abs va)pi))0.000001)(setq ang 2 i n)
(progn(cond((> va pi)(setq va (- va pi)))
((< va (* -1 pi))(setq va (+ va pi))))
(setq ang(+ ang va)i(1+ i)))))
(if(= ang 2)0
(if(<(abs(-(abs ang) pi))0.000001)1 -1))
)
;defun
(defun plinexy(e / a q m p);;;LWPolyline,POLYLINE顶点,去掉完全重合点
(setq a(vlax-ename->vla-object e)
q(vlax-safearray->list(vlax-variant-value(vla-get-Coordinates a)))
m(vla-get-objectname a)a 0
m(if(= m"AcDb3dPolyline")3 2))
(repeat(/(length q)m)
(cond((= m 2)(setq p1(list(nth a q)(nth(+ a 1)q))))
((= m 3)(setq p1(list(nth a q)(nth(+ a 1)q)(nth(+ a 2)q)))))
(setq p(if (member p1 p)p (append p(list p1)))
a(+ a m)))
p)
(defun xyp-Pline (lst / lst pt)
(entmake (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (length lst))'(70 . 129))
(mapcar '(lambda (pt)(cons 10 pt)) lst ))
) (vl-cmdf "_.region" (entlast) "") (entlast)
)
;;改改更贱康
(defun temp (pa pb p0 p1 p2 / MAT:vxv {vp} {v} a b)
(defun MAT:vxv (u v)
(list
(- (* (cadr u) (caddr v)) (* (cadr v) (caddr u)))
(- (* (car v) (caddr u)) (* (car u) (caddr v)))
(- (* (car u) (cadr v)) (* (car v) (cadr u)))
)
)
(setq {vp} (MAT:vxv (mapcar '- p1 p0) (mapcar '- p2 p0)))
(setq {v} (mapcar '- pa pb))
(setqa (apply '+
(mapcar '(lambda (n m vp) (* (- n m) vp)) p0 pa {vp})
)
)
(setq b (apply '+ (mapcar '* {vp} {v})))
(if (equal b 0.0 1e-6)
nil
(mapcar '(lambda (m v) (+ m (* v (/ a b)))) pa {v})
)
)
(defun insertgc ( e / e)
(cdr(assoc 10(entget e))))
(defun c:pdpj3 ( /ENOBJ p1 p2 s1 s2 p3 p33 dist gcc bz dist1 xgc p33 podu blcp11 ang p22 pts1 pts ssa ii en ptb pzx pzx1 no)
(setq blc (getint "\n请输入比例尺1:<500>"))
(if (= blc nil)(setq blc 500))
(setvar 'userr1 blc);设置比例尺
(setq scale (* 0.001 blc));缩放比例
(setq podu (getreal "\n请输入坡度1:(挖+填-)?"))
;;;;;
(setq ENOBJ (CAR (ENTSEL "\n请选择坡顶或者坡脚三维多段线POLYLINE线段")))
;(setq p1 (getpoint "\n选择曲线上的一点:"))
;(setq s1 (getreal "\n请输入该点标高:"))
;(setq p2 (getpoint "\n选择曲线上的另一点:"))
;(setq s2 (getreal "\n请输入该点标高:"))
;(setq dist (apkl ENOBJ p1 p2 ))
;(setq gcc (- s1 s2))
;(setq bz (/ gcc dist))
(while (setq p33 (getpoint "\n选择曲线上要查询的一点:") )
;(setqp3 (vlax-curve-getClosestPointTo ENOBJ p33 T))
(setqp3 (vlax-curve-getClosestPointToProjection (vlax-ename->vla-object ENOBJ)p33 '(0.0 0.0 1.0) t))
;(setq dist1 (apkl ENOBJ p3 p2 ) )
;(setq xgc (+ s2 (* dist1 bz )))
;(mkgcd p3 xgc1)
(gxl-cs:gcd p3 (last p3) scale)
;(setq p1 (insertgc(car(entsel "\n请选择坡顶或者坡脚:"))))
(setq p11 (list (car p3 ) (cadr p3) (last p3) ))
;(setq ang (getangle p1 "\n请指定顶或者坡脚哪个方向? "))
(setq ang(angle p11 p33))
(setq p22 (polar p11 ang 100))
(setq pts1 (list p11 (append (vl-remove (last p22)p22) (list(+ (last p11 )(/ 100podu ))))))
;(print pts1)
(setq pts (list (vl-remove (last p11)p11) p22))
(vl-cmdf "zoom" "e")
(setq ssa (ssget "f" pts'((0 . "POLYLINE") (8 . "sjw"))))
;(sssetfirst nil ssa)
(setq ii 0
no0)
(repeat (sslength ssa)
(setq en (ssname ssa ii)
ptb (plinexy en)
;demj (vlax-curve-getArea(vlax-ename->vla-object en))
pzx (append pzx (list ptb))
ii(1+ ii))
)
;(setvar "osmode"16384)
(foreach x pzx
(setq pzx1 (temp (car pts1) (cadr pts1) (car x) (cadr x)(caddr x) ))
(if (and (/= pzx1 nil)
(>= (poinpl (mapcar '(lambda (b)(vl-remove (last b)b))x) (vl-remove (last pzx1)pzx1))0))
(progn (print pzx1)(gxl-cs:gcd pzx1 (last pzx1) scale))
)
)
(vl-cmdf "zoom" "p")
;(command "rotate" (entlast) "" p3 (* (- (angle p3 p33) (/ pi 2) ) (/ 180 pi) ))
;(entmake (list '(0 . "TEXT") '(8 . "fgbj")(cons 1 (rtos xgc 2 3)) (cons 10 p3 ) (cons 40 1.0)))
)
(princ)
)
老哥,这个厉害了,一直都在纠结这问题
页:
[1]