samsudeenmanoos 发表于 2022-7-5 15:10:16

亲爱的朋友们,请帮我联系ge

我试了很多次想得到海拔,但我做不到。有人能解决这个问题吗?
DSS。dwg
标记点。lsp

hanhphuc 发表于 2022-7-5 15:45:32


(defun C:ENZ (/ ov p pt e n z)
(setq ov (getvar 'cmdecho))
(setvar 'cmdecho 0)
(while (and (setq p (getpoint "\nPick Point : ")) (setq pt (getpoint p "\nInsert Text : ")))
   (progn (mapcar '(lambda(a b) (set a (strcat (vl-princ-to-string a) "= " (rtos b 2 3)))) '(E N Z) p)
   (eval (vl-list* vl-cmdf
                   "_leader"
                   "_non"
                   'p
                   "_non"
                   'pt
                   ""
                   (list E N Z "")
                   )
       )
   (princ (strcat "\r" E " " N " " Z))
   
   )
   )
(if ov (setvar 'cmdecho 0))
(princ "Done!\n")
(princ)
)

BIGAL 发表于 2022-7-5 15:56:39

这是一个拼写错误
 

(setq P1Z (cadr pnt1))   ; returns Y
(setq P1Z (caddr pnt1)) ; returns Z

also need ;
; Labeling N,E,Z Coordinates with Leader - David B. Stewart

 
如果需要,您可以压缩代码,并且不使用太多变量。
 

(defun C:LP(/ pnt1 COORDN COORDE PTXT)
   (setq PNT1 (getpoint"\nPick coordinate point: "))
   (setq COORDN (strcat "E " (rtos (car pnt1) 2 3)))
   (setq COORDE (strcat "N " (rtos (cadr pnt1) 2 3)))
   (setq ELEZ (strcat "EL " (rtos (caddr pnt1) 2 3)))
   (setq PTXT (getpoint    "\nPick text location: "))
   (command "LEADER" PNT1 PTXT "" COORDNCOORDEELEZ "")
   (princ)
)

 
; even less
(defun C:LP(/ )
   (command "LEADER" (getpoint"\nPick coordinate point: ")(getpoint    "\nPick text location: ") ""
   (strcat "E " (rtos (car pnt1) 2 3))
   (strcat "N " (rtos (cadr pnt1) 2 3))
   (strcat "EL " (rtos (caddr pnt1) 2 3)) "")
   (princ)
)

BIGAL 发表于 2022-7-5 16:21:17

返回到dwg及其三维柱脚线等,您是在垂直坐标系后还是沿着柱脚线的三维点后。ObjectName(RO)=“AcDb3dPolyline”
 
我之前发布的内容不适用于3dpoly。
 
试试这个,只需要添加一个更好的defun和错误检查

; pline co-ords example
; By Alan H
; write z of vertices added

(defun getcoords (ent)
(vlax-safearray->list
   (vlax-variant-value
   (vlax-get-property
   (setq obj (vlax-ename->vla-object ent))
   "Coordinates"
   )
   )
)
)

; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z
(defun co-ords2xy ()
(setq len (length co-ords))
(if (= (vla-get-ObjectName obj) "AcDb3dPolyline")
(progn
(setq numb (/ len 3))
(setq odd "yes")
)
(progn
(setq numb (/ len 2)) ; even and odd check required
(setq odd "no")
)
)
(setq I 0)
(setq co-ordsxy '())
(repeat numb
(cond
((= odd "yes") (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords)(nth (+ I 2) co-ords) ))(setq I (+ I 3)))
((= odd "no" ) (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) ))(setq I (+ I 2)))
)
(setq co-ordsxy (cons xy co-ordsxy))
)
)


; program starts here
(setq co-ords (getcoords (car (entsel "\nplease pick pline"))))
(co-ords2xy) ; list of 2d or 3d points making pline
; list is co-ordsxy

`
(repeat (setq i(length co-ordsxy))
(setq pt (nth(setq i (- i 1)) co-ordsxy))
(setq x (car pt) )
(setqy(cadr pt) )
(if (= odd "yes")
(setq z(caddr pt))
(setq z "-")
)
(command "-text" (list x y) "" "" (rtos z 2 3))
)
页: [1]
查看完整版本: 亲爱的朋友们,请帮我联系ge