andy_lee 发表于 2022-7-5 22:39:34

lisp需要一些修改。

嗨,朋友们。
这个例程需要一些修改,希望你能帮助我。谢谢
 
只能画A型,我还需要一个选项,B型
 
而且,我还需要手动输入长度,而不仅仅是选择两个点。
不需要画中心线,在例行程序中删除它。
 
(defun c:ttt (/ os bo olay lay col lt e d ctk_Z aa r pt pta ang di ptb pt1 pt2 pt3 pt4 ptt b bl)
(defun *Error* (msg);
    (if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,*EXIT*,")))
      (progn (setvar "blipmode" 0)(princ)))
);defun *Error*
(setvar "cmdecho" 0)
(setq os (getvar "osmode"))
(setq bo (getvar "blipmode"))
(setq olay (getvar "clayer"))
(setvar "osmode" 1023)
(princ "Long hole")
(setq lay "centerline")
(setq col "6")
(setq lt "CENTER")
(setq e (getvar 'ltscale))
(setq d (/ 6 e))
(if (tblsearch "layer" lay) ""
   (progn
       (command "-layer" "m" lay "color" col "" "l" lt "" "")
       (command "clayer" olay)
   )
)
(if *ctk_Z*
    (setq ctk_Z (getdist (strcat "\nPlease enter the diameter <" (rtos *ctk_Z* 2 4) ">:")))
    (setq ctk_Z (getdist "\nPlease enter the diameter <13>:" ))
)
(if (not ctk_Z)
    (setq ctk_Z *ctk_Z*)
    (setq *ctk_Z* ctk_Z)
)
(setq aa ctk_Z)
(if (= aa nil) (setq aa (* 6.5 2)))
(setq r (/ aa 2))
(while
   (setvar "blipmode" 0)
   (setvar "osmode" 1023)
   (and
      (setq pt (getpoint "\nSpecifies the insertion point:"))
      (setq pta(getpoint pt "\nSpecifies the other point:"))
    );and
   (setq ang(angle pt pta)
      di(distance pt pta)
      ptb (polar pt ang r)
      pt1 (polar ptb (+ ang (/ pi 2)) r)
      pt2 (polar pt1 ang (- di (* r 2)))
      pt3 (polar ptb (+ ang (/ pi -2)) r)
      pt4 (polar pt3 ang (- di (* r 2)))
      ptt (mapcar '(lambda(x)(/ x 2))(mapcar '+ pt pta))
    );set
   (setvar "osmode" 0)
   (command "_.PLINE" "non" pt1 "non" pt2 "A" "non" pt4 "L" "non" pt3 "A" "CL")
   (setq b (* 0.4 r))
   (if (<= di 50)
(setq bl d)
       (setq bl (+ d (* (/ 2 e) (fix (/ di 50)))))
   )
   (command "line" (polar pt (+ ang pi) b) (polar pta ang b) "")
   (command "change" (entlast) "" "P" "la" lay ""
            "change" (entlast) "" "P" "s" bl "")
   (command "line" (polar ptt (+ ang (/ pi 2)) (+ r b)) (polar ptt (- ang (/ pi 2)) (+ r b)) "")
   (command "change" (entlast) "" "P" "la" lay ""
            "change" (entlast) "" "P" "s" bl "")
   (command "redrawall")
   (princ "\n**Continue...**")
   (setvar "osmode" os)
   (setvar "blipmode" bo)
);while
(princ)
);defun


 
如果你不再需要抽绳,那么
将分号放在代码的最左边

(setq
ang (angle pt pta)   --> ang (getangle "\nAngle: ")
di (distance pt pta)--> di (getdist "\nLength: ")

ptb (polar pt ang r)   --> ptb pt

我道歉d.i.y
 
对于B型

;;;    (setq pta(getpoint pt "\nSpecifies the other point:"))

;;;    ptt (mapcar '(lambda(x)(/ x 2))(mapcar '+ pt pta))

;;;    (command "line" (polar pt (+ ang pi) b) (polar pta ang b) "")
;;;    ... from
;;;    ...
;;;    ... to
;;;    (command "redrawall")

hanhphuc 发表于 2022-7-5 22:43:26

 
你好韩,这是最终版本? 我会努力的!

andy_lee 发表于 2022-7-5 22:46:31

你好韩,现在好了!非常感谢你!

hanhphuc 发表于 2022-7-5 22:52:02

 
韩,你好,
使用一段时间,不是很方便。输入--“O”选择“A”和“B”,很容易出错。
可以使用DCL吗? 这样地:

 
我已经制作了SLD文件:
SLD。拉链

andy_lee 发表于 2022-7-5 22:53:27

 
 
实际上,您不需要每次为“A或B”输入“选项”,您输入的“选项”值将被设置为下一个典型会话的默认值,因此您只需选择不带“选项”的点。。

(setq
ang(getangle "\nAngle: ")<---- modified
di (getdist "\nLength: ") <---- modified
di ( - di r)   <------------- add this
...
...

红色为默认值
和dcl一样,您只在需要更改其设置时调用它,而不是每次运行时它都会弹出,这样对用户不友好

BIGAL 发表于 2022-7-5 22:56:28

 
是的,并不是每次运行它都会弹出,这样对用户来说不友好,但Dcl更直观。

andy_lee 发表于 2022-7-5 23:01:37

 
 
http://www.cadtutor.net/forum/showthread.php?87818-A-lisp-need-some-modify/第2页(if(null*fb\U user*)(setq*fb\U user*(mapcar‘itoa’(1 0 1 0)));_if(defun fbdia(/radio dcl\u id path dcl)(setq radio’(“radio1”“radio2”“radioA”“radioB”)路径(getenv“temp”)(((f lst/)(setq f(open f“w”))(mapcar’($)(write line$f))lst)(close f)(setq f nil))(setq dcl(strcat path“\\tmp.dcl”)(“icon\u fbox\u img:image{”color=0“宽度=40;”“纵横比=0.75;”“allow\u accept=true;”“fixed_height=true;”“fixed_width=true;”“}”“”“fbox:对话框{”“\t标签=\”圆角框设置\“;”“键=\”dcl\U标题\“;”“”:段落{”“:text\u部分{”“\t标签=\“选择选项\”;”“\t//对齐=居中;”“}”“}”“:列{”“:行{”“:列{”“:icon\u fbox\u img{key=\”SH-center\“;}”“}”“:列{”“:icon\u fbox\u img{key=\”SH-EDGE\“;}”“}”“}”“}”“:列{fixed\u width=true;//对齐=居中;”“:box\u radio\u行{label=\“Draw method\”;”“\t:单选按钮{label=\”Pick center“;key=\”radio1\“;}//值=“0”;“”:单选按钮{label=\“Pick side\”键=\“radio2\”;}//值=\“1\”“}”“}”“:列{”“:行{”“:列{”“:icon\u fbox\u img{key=\“SH-P2P\”;}“}”“:列{”“:icon\u fbox\u img{key=\“SH-C2C\”;}“}”“}”“}”“”“间隔垫圈1;“”:列{fixed\u width=true;//对齐=居中;“”:装箱单选行{label=\“Mode\”;“”:单选按钮{label=\“A:边到边\”;键=\“radio[”color“\”;}//值=\“0\”:单选按钮{label=\“B:radi to Radii\”;键=\“radioB\”;}//值=“1”;“}”“}”“:列{fixed\u width=true;对齐=居中;”“:段落{”“:text\u part{”“\tlabel=\“圆角框:hanhphuc 2014\”;“\talignment=centered;”“}”“}”“:行{”“\t spacer\u 0;”“ok\u cancel;”“}”“)(setq dcl\u id(load\u dialog dcl))(new\u dialog”fbox“dcl\U id”(mapcar“”((a)((i sld)(setq x(dimx\U tile i))(setq y(dimy\U tile i))(start\U image i)(fill\U image 0 0 x y-2)(slide\U image 0 x y sld)(end\U image))a(strcatpath“\\”a);

hanhphuc 发表于 2022-7-5 23:04:15

radio是键名,而不是sld名称。你只需要改变道路!永远不要更改幻灯片名称!!

hanhphuc 发表于 2022-7-5 23:06:08

幻灯片必须放在support文件夹中,或者创建它。或者尝试输入短名称路径,即:“C:\\LISP\”

hanhphuc 发表于 2022-7-5 23:10:41

 
谢谢你,我的朋友,
 
我把sld文件和lisp放在support文件夹中,同一个文件夹,如何修改路径?
页: [1] 2
查看完整版本: lisp需要一些修改。