stevesfr 发表于 2022-7-6 07:36:11

@bharthts01
这个Lisp程序可能会帮到你
 


;LBLCOORD - plain label point w/coords
(defun c:LBLCOORD
()
(setvar "CMDECHO" 0)
(setq pt 1)
(while (/= pt
nil)
   (setq pt (getpoint "\n PICK POINT TO LABEL
"))
   (if (/= pt nil)
   
(progn (setq n (strcat "N " (rtos (cadr
pt))))
            
(setq e (strcat "E " (rtos (car
pt))))
            
(setq tp (getpoint "\n PICK POINT FOR COORDINATES
"))
            
(command "TEXT" tp "0"
n)
            
(command "TEXT" "" e)
   )
   
)
)
)
(princ)

 
干杯,祝你好运,一定要阅读帖子#9

MSasu 发表于 2022-7-6 07:39:48

@bharthts01:我对您的代码做了一些更改,将两个标签打印在同一行上(顺序是您在第一篇文章中声明的顺序)。
(defun c:ne ()(setvar "osmode" 1)
(setq ne1 (getpoint"\nPick point..."))
(setvar "osmode" 0)
(if (/= ne1 nil)(go_ne)(princ"\nInvalid Location !"))
(princ)
)
(setq tx-ht 0.5)
(defun go_ne ()(setvar "luprec" 2)
(setq prmt (strcat "Enter TEXT HEIGHT<"(rtos tx-ht)">: "))
(princ prmt)
(setq x-ht (getreal))(if (= x-ht nil)(setq x-ht tx-ht))
(setq tx-ht x-ht)
(setq e-x (car ne1))(setq xx (rtos e-x))
(setq n-y (cadr ne1))(setq yy (rtos n-y))
(tx-f)
)
(defun tx-f ()
(setq vx (strcat " E " xx))
(setq vy (strcat " N " yy))
(command "_.TEXT" "_J" "_ML" "_non" ne1 x-ht 0.0 (strcat vx " / " vy))
)

bharthts01 发表于 2022-7-6 07:41:42

谢谢,伙计,最后一个问题。。。我已经将lisp加载到cad中,现在如何使用它?

MSasu 发表于 2022-7-6 07:44:50

您的代码定义了一个名为NE的新命令,您可以在类似提示器的内置命令中调用该命令。

bharthts01 发表于 2022-7-6 07:48:53

它现在工作得很好,只是我现在需要做一些小的调整。
 
http://s8.postimage.org/6cht767th/cad_xy.jpg
 
首先,我需要一个箭头,显示它指向的位置。
第二个,我想要它显示9位数字的地方
 
e、 g.(上图中)430315507和434191791
 
编辑-使用此lisp时,对象捕捉是否正常打开和关闭?

MSasu 发表于 2022-7-6 07:52:42

对于OSNAP,请尝试以下版本的代码:
(defun c:ne( / oldOsmode e-x n-y ne1 prmt tx-ht vx vy x-ht xx yy )
(defun go_ne()
(setvar "luprec" 2)
(setq prmt (strcat "Enter TEXT HEIGHT<" (rtos tx-ht) ">: "))
(princ prmt)
(setq x-ht (getreal))
(if (= x-ht nil)
(setq x-ht tx-ht)
)
(setq tx-ht x-ht)
(setq e-x (car ne1))
(setq xx (rtos e-x))
(setq n-y (cadr ne1))
(setq yy (rtos n-y))
(tx-f)
)

(defun tx-f()
(setq vx (strcat " E " xx))
(setq vy (strcat " N " yy))
(command "_.TEXT" "_J" "_ML" ne1 x-ht 0.0 (strcat vx " / " vy))
)

(setq tx-ht 0.5)
(setq oldOsmode (getvar "OSMODE"))
(setvar "osmode" 1)
(setq ne1 (getpoint "\nPick point..."))
(setvar "osmode" 0)
(if (/= ne1 nil)
(go_ne)
(princ "\nInvalid Location !")
)
(setvar "OSMODE" oldOsmode)
(princ)
)
当然,您的代码需要更多的调整。

bharthts01 发表于 2022-7-6 07:54:20

可以在对象捕捉模式下使用这些设置获取代码吗?
 
谢谢
 
http://s10.postimage.org/vy34nj7zt/cad_code.jpg
 
另外,如果我能让“箭头”指向坐标设置的点,那就太好了。

MSasu 发表于 2022-7-6 08:00:09

更改此行
(setvar "osmode" 1)

(setvar "osmode" 427)

bharthts01 发表于 2022-7-6 08:03:05

快到了,
 
http://s17.postimage.org/tq2lipi7j/lisp_new.jpg
 
如果可能的话,将其保留在9位(去掉小数点后的最后2位)

MSasu 发表于 2022-7-6 08:06:00

要获得不带小数的数字,请调整这些行:
;(setvar "luprec" 2)
...
(setq xx (rtos e-x 2 0))
...
(setq yy (rtos n-y 2 0))
页: 1 [2]
查看完整版本: 如何创建lisp程序d