trmg 发表于 2022-7-6 08:57:03

好的,我完全理解。我真的很想理解你的Lisp程序,但这对我来说很难。如果你不在乎45个角度,你能在各个方向做同样的工作吗?只是直线?

trmg 发表于 2022-7-6 08:59:17

(defun c:vv15 (/ pt)

   (command "TEXT" "S" "ISO" "0,25,0" "125" "0" "KV5-15")
   (command "TEXT" "S" "ISO" "0,-150,0" "125" "0" "VV5-15")
       (command "LINE" "0,0,0" "540,0,0" "")
   (command "-BLOCK" "v15" "270,0" "BOX" "700,700,0" "-700,-700,0" "")
(princ)
)

(defun c:vv18 (/ pt)


   (command "TEXT" "S" "ISO" "0,25,0" "125" "0" "KV5-15")
   (command "TEXT" "S" "ISO" "0,-150,0" "125" "0" "VV5-15")
       (command "LINE" "0,0,0" "540,0,0" "")
   (command "-BLOCK" "v18" "270,0" "BOX" "700,700,0" "-700,-700,0" "")
(princ)

)


(defun c:ss50 (/ pt)

   (command "TEXT" "S" "ISO" "0,25" "125" "0" "S1-50")
   
       (command "LINE" "0,0,0" "540,0" "")
   (command "-BLOCK" "ss50" "270,0" "BOX" "700,700,0" "-700,-700,0" "")
(princ)
)

(defun c:ss75 (/ pt)

   (command "TEXT" "S" "ISO" "0,25" "125" "0" "S1-75")
   
       (command "LINE" "0,0,0" "540,0" "")
   (command "-BLOCK" "ss50" "270,0" "BOX" "700,700,0" "-700,-700,0" "")
(princ)
)

(defun c:ss110 (/ pt)

   (command "TEXT" "S" "ISO" "0,25" "125" "0" "S1-110")
   
       (command "LINE" "0,0,0" "540,0" "")
   (command "-BLOCK" "ss50" "270,0" "BOX" "700,700,0" "-700,-700,0" "")
(princ)
)


(defun c:dd110 (/ pt)

   (command "TEXT" "S" "ISO" "0,25" "125" "0" "D2-110")
   
       (command "LINE" "0,0,0" "540,0" "")
   (command "-BLOCK" "ss50" "270,0" "BOX" "700,700,0" "-700,-700,0" "")
(princ)
)

(defun c:skapablock (/ pt)

   (command "vv15" "vv18" "ss50" "ss75" "ss110" "dd110")
   
      
(princ)
)

 
劫持我自己的线程以获取其他信息:
 
除了最后一个应该调用所有其他函数的函数外,所有函数都工作。我该怎么做?它只是说他们都有未知的命令。

BIGAL 发表于 2022-7-6 09:02:54

(VV15)(VV1)等

trmg 发表于 2022-7-6 09:06:27

非常感谢。有人可以发布垂直而不是水平的线条脚本吗?我不知道怎么做。如果有人这么做,我会非常感激。
 
再次感谢您的帮助。意味着很多

BIGAL 发表于 2022-7-6 09:10:11

只需将使用0.0角度的代码更改为(/pi 2.0)

trmg 发表于 2022-7-6 09:14:27

 
原始代码:
; lisp to draw hor lines plus 45's between 2 points
; By BIGAL Jan 2012
(defun c:horbend ()
(setq pt1 (getpoint "\npick 1st point on terminal bar"))
(setq pt2 (getpoint "\npick 2nd point "))
; ang2 is horiz lines ang3 is 45 lines
(setq ang1 (angle pt1 pt2))
(cond
((> ang1 4.412388)(setq ang2 0.0)(setq ang3 (* 0.75 pi)))
((> ang1 pi)(setq ang2 pi)(setq ang3 (* 0.25 pi)))
((> ang1 (/ pi 2.0))(setq ang2 PI)(setq ang3 (* 0.75 pi)))
((> ang1 0.0)(setq ang2 0.0)(setq ang3 (* 0.25 pi)))
)
(setq pt3 (polar pt1 ang2 20.0))
(setq pt4 (polar pt2 ang3 20.0))
(setq pt5 (inters pt1 pt3 pt2 pt4 nil))
(command "line" pt1 pt5 pt2 "")
)
(princ)
 
 
我的编辑:
 
; lisp to draw hor lines plus 45's between 2 points
; By BIGAL Jan 2012
(defun c:hg ()
(setq pt1 (getpoint "\npick 1st point on terminal bar"))
(setq pt2 (getpoint "\npick 2nd point "))
; ang2 is horiz lines ang3 is 45 lines
(setq ang1 (angle pt1 pt2))
(cond
((> ang1 4.412388)(setq ang2 (/ pi 2.0))(setq ang3 (* 0.75 pi)))
((> ang1 pi)(setq ang2 pi)(setq ang3 (* 0.25 pi)))
((> ang1 (/ pi 2.0))(setq ang2 PI)(setq ang3 (* 0.75 pi)))
((> ang1 (/ pi 2.0))(setq ang2 (/ pi 2.0))(setq ang3 (* 0.25 pi)))
)
(setq pt3 (polar pt1 ang2 20.0))
(setq pt4 (polar pt2 ang3 20.0))
(setq pt5 (inters pt1 pt3 pt2 pt4 nil))
(command "line" pt1 pt5 pt2 "")
)
(princ)
 
 
我一定很愚蠢,但我做不到。
 
 
只能在一个方向上工作,并且向下和向右。
 
截图:
 
 
http://dl.dropbox.com/u/45010560/AutoCAD%20MEP%202010%20-%20%5图纸11。图纸%5D\u 2012-01-25\u 07-30-28。jpg

BIGAL 发表于 2022-7-6 09:18:19

(setq ang2(/pi 2.0))我建议您阅读一下LISP编程,这样您就可以理解代码行在做什么,而不仅仅是让人们编写代码。

maksolino 发表于 2022-7-6 09:19:25

你好
我喜欢第二个代码,但我想有可能
以度为单位输入角度
谢谢
页: 1 [2]
查看完整版本: 绘制线条的Lisp