2andygs 发表于 2022-7-5 15:31:54

具有用户输入的多行

大家好。。。谁能帮我发展一个Lisp程序。。。
我需要用用户输入绘制多条线
 
例如长度、行数、偏移大小
 
还需要画垂直线两端1/16英寸内。。。
 
我附上图片作为例子
 
提前感谢。。。。

SLW210 发表于 2022-7-5 15:38:34

我已经将你的帖子转移到AutoLISP、Visual LISP和DCL论坛,请在最相关的论坛上发布。

ronjonp 发表于 2022-7-5 15:40:57

这听起来像是动态块的任务。

Grrr 发表于 2022-7-5 15:46:51

基点应位于何处?

BIGAL 发表于 2022-7-5 15:48:13

我将尝试查找,以前使用50,4,-25的简单输入做过类似的事情
50=长度
4是必需的数字
-25右/左偏移为+/-
 
我会继续寻找,找到同样的想法。

; copy multiple objects along x or y axis
; use 2x40 etc

BIGAL 发表于 2022-7-5 15:53:17

看看我在这里的帖子http://www.cadtutor.net/forum/showthread.php?84919-绘制双多段线/第3页
 
也许从头开始写会更容易。

2andygs 发表于 2022-7-5 15:57:42

0,0或任何不重要的地方

2andygs 发表于 2022-7-5 15:59:29

 
0,0或任何不重要的地方

Grrr 发表于 2022-7-5 16:05:02

干得好:
 

(defun C:test ( / p1 p2 off n a d f p )
(and
   (cond
   ( (and *MtpLines* (setq p1 (getpoint "\nSpecify base point <new line>: ")))
       (mapcar '(lambda (x) (set x (cdr (assoc x *MtpLines*)))) '(d a))
       (setq p2 (polar p1 (- a (* 0.5 PI)) d))
   )
   (
       (and
         (setq p1 (getpoint "\nSpecify line's length: "))
         (setq p2 (getpoint "\nSpecify line's length: " p1))
       )
   )
   ); cond
   (not (grdraw p1 p2 1 1))
   
   (setq off (cond ( (progn (initget 6) (getdist (strcat "\nSpecify offset " (if (setq off (cdr (assoc 'off *MtpLines*))) (strcat "<" (rtos off 2 15) ">") "") ": "))) ) ( off )))
   (setq n (cond ( (progn (initget 6) (getint (strcat "\nSpecify number of lines " (if (setq n (cdr (assoc 'n *MtpLines*))) (strcat "<" (itoa n) ">") "") ": "))) ) ( n )))
   
   (or a (setq a (+ (angle p1 p2) (* 0.5 PI))))
   (or d (setq d (distance p1 p2)))
   (setq f '((p a d) (entmakex (list '(0 . "LINE") (cons 10 p) (cons 11 (polar p a d))))))
   (setq p p1)
   (progn
   (redraw)
   (repeat n
       (f p (angle p1 p2) d)
       (setq p (polar p a off))
   )
   (
       '(( / ed pt1 pt2 dst )
         (setq ed 6.)
         (setq pt1 (polar p1 a (- ed)))
         (setq pt2 (polar p2 a (- ed)))
         (setq dst (+ (- (distance p1 p) off) (* 2. ed)))
         (f (polar pt1 (angle p1 p2) ed) a dst )
         (f (polar pt2 (angle p1 p2) (- ed)) a dst )
       )
   )
   (setq *MtpLines* (mapcar '(lambda (x) (cons x (eval x))) '(d a off n)))
   ); progn
); and
(princ)
); defun

2andygs 发表于 2022-7-5 16:07:28

谢谢你的代码。。。它工作了一些什么,但它有点混乱,并没有像我预期的那样工作。。您能按如下方式更改用户输入,并将起点定义为自动@0,0和水平长度吗
 
1.输入板条的总长度(ex 100”)
2.输入垂直偏移长度(两端的两条垂直线)(例如0.25”)
3.输入水平偏移距离(例如5”)
4.输入要偏移的行数(例如10)
 
我已附上上述值的示例草图。。。希望这个信息足够好
 
再次感谢
页: [1] 2
查看完整版本: 具有用户输入的多行