V-SAM 发表于 2022-7-6 06:25:46

用Lisp语言绘制多边形

救命!!
我正在寻找一种快速的方法,关键在3维,然后有一个矩形多段线绘制和关闭。它可以在0,0,0自动开始绘图
 
三个用户条目将是A、B、C,其中A和C将不同,程序将关闭对象。
 
有关更好的解释,请参阅附件。
 
我很感谢大家对这方面的意见。。我不太擅长写Lisp程序,但我有很好的视野,谢谢你们,你们是最好的。
文档1.pdf

ReMark 发表于 2022-7-6 06:35:47

为什么需要lisp例程来绘制该形状?这一切都可以在命令行中快速完成。
 
命令:\u pline
指定起点:
当前线宽为0.0000
指定下一点或[弧(Arc)/半宽(Halfwidth)/长度(Length)/撤消(Undo)/宽度(Width)]:10
 
指定下一点或[弧(Arc)/闭合(Close)/半宽(Halfwidth)/长度(Length)/撤消(Undo)/宽度(Width)]:4
 
指定下一点或[弧(Arc)/闭合(Close)/半宽(Halfwidth)/长度(Length)/撤消(Undo)/宽度(Width)]:14
 
指定下一点或[弧(Arc)/闭合(Close)/半宽(Halfwidth)/长度(Length)/撤消(Undo)/宽度(Width)]:c

V-SAM 发表于 2022-7-6 06:35:59

我知道这很简单。。。然而,我有一个工程师,他只想输入三维而不想输入其他内容,并为他完成。。。

V-SAM 发表于 2022-7-6 06:44:43

如果能帮上忙,我们将不胜感激。。再次感谢你。

ReMark 发表于 2022-7-6 06:48:45

我懂了。我想在我说我会后悔的话之前,我现在就停下来。
 
我相信这里的一位Lisp程序专家可以很快为您的工程师解决这个难题。
 
祝你好运,编码愉快。

Tharwat 发表于 2022-7-6 06:55:12

这个?
 

(defun c:Test (/ i x p pt l)
(setq i 0
       x '("First" "Second" "Third" "Fourth")
)
(while (and
          (not (eq (length l) 4))
          (if pt
            (setq p (getpoint (strcat "\n" (nth i x) " point :") pt))
            (setq p (getpoint (strcat "\n" (nth i x) " point :")))
          )
          (setq pt p)
      )
   (setq l (cons p l)
         i (1+ i)
   )
)
(if (eq (length l) 4)
   (command "_.pline"
            "_non"
            (car l)
            "_non"
            (cadr l)
            "_non"
            (caddr l)
            "_non"
            (nth 3 l)
            "c"
   )
)
(princ)
)

ReMark 发表于 2022-7-6 06:59:31

从此,他们都过着幸福的生活。结束。

alanjt 发表于 2022-7-6 07:03:30

感觉很慷慨。。。
 
(defun c:Test (/ a b c p1 p2)
(if (and (progn (initget 6) (setq a (getdist "\nSpecify length of side A: ")))
          (progn (initget 6) (setq b (getdist "\nSpecify length of side B: ")))
          (progn (initget 6) (setq c (getdist "\nSpecify length of side C: ")))
          (setq p1 (getpoint "\nSpecify intersection of sides A and C: "))
   )
   (command "_.pline"
            "_non"
            (mapcar '+ p1 (list 0. a 0.))
            "_non"
            p1
            "_non"
            (setq p2 (mapcar '+ p1 (list c 0. 0.)))
            "_non"
            (mapcar '+ p2 (list 0. b 0.))
            "_close"
   )
)
(princ)
)

V-SAM 发表于 2022-7-6 07:08:33

你太棒了,效果很好。。我知道这很简单,真的不需要,但我还是很感激。

V-SAM 发表于 2022-7-6 07:11:02

一件小事。。。。我要做什么改变才能使这个开始绘制0,0,0处的多段线??
页: [1] 2
查看完整版本: 用Lisp语言绘制多边形