JohnM 发表于 2022-7-6 15:46:56

没问题。学习时允许脚尖踩踏
 
基本输入/输出文件:
 
希望你有足够的组织能力,将lisp、dcl和输入/输出文件保存在自己的文件夹中。如果不做一个。在测试阶段,确保在auto cads support file search path中映射了该文件夹的路径。
稍后,我们将在lisp环境中创建一个项目,然后制作一个vlx文件,以便于使用和分发。
 
输入/输出文件只是另一个lisp文件。最好将其分开以便于纠正,并为其他项目窃取。
 
首先,让我们看看我的输入/输出文件,看看它是如何工作的。只显示输入/输出文件以进行解剖。
它被另一个文件调用,它调用dcl文件,然后将值返回给调用它的原始文件。
 
文件名为qdx\u io
定义为qdx:DialogInput
dcl文件称为qdx。dcl
对话框名称为qdx\u maindlg
 
调用此文件的程序是这样做的
(setq retval(qdx:DialogInput))调用打开dcl并将值返回给retval的文件。
 
在文件的顶部,有许多错误检查正在进行,以最大限度地减少崩溃
当您查看文件时,您可以看到what_next循环从何处开始,如果用户单击某个按钮,则可以看到末尾的cond。
 
在cond函数中,我们将调用picket lisp并传递3个值
 
并设置一些if语句来重新填充瓷砖
 
还请注意,您可以设置一个保存文件,以便在用户单击“确定”按钮时将值写入其中
当程序启动时,它会查找此文件并将值加载到dcl中的适当磁贴中
如果找不到文件,则会设置一些默认值。
 
复制此文件并将其保存到文件夹中,以便您可以将其窃取并使其在以后的其他项目中工作。
 
有什么问题吗?
你能看到稍作改动后这对你有什么作用吗?
 
当然,defun必须从qdx:DialogInput重命名为picket:DialogInput
只是为了让事情简单易懂。
 
接下来需要做的是编写一个主lsp文件,该文件将调用输入/输出文件。
只有蒲

JohnM 发表于 2022-7-6 15:50:23

Not sure if the correct variable are being passed back but you can correct them
Also I’m not sure about the format of the return answers. Are they all real numbers?
 
I also discovered that I was wrong in the return list. You don’t need to pass the 3 question values back if you use my solution in this post.
 
Here are all 3 files to play with:
 

;;;;; main calling program(defun c:pkt ()(picket:DialogInput)(princ));_defun(defun picket (dst1 pip1 bar1 / ret aa ab ac ad ae af ag ds1 dst2 num1 d num2 spa1 y y1 y2 y3 y4 spa2 dst3 endb endr1 endr2) (setq dst2 (+ (- dst1 pip1) bar1));dst2 is the spacing of pickets less the pipe post (setq num1 (/ dst2 4))   ;num1 is the number of picket spaces @ exactly 4" (setq d (fix (+ num1 0.99)))      ;d is the number of spaces needed to round up (setq num2 (- d 2))    ;num2 is the number of spacing for the middle of the rail (setq spa1 (/ dst2 d)) (setq y (+ spa1 0.03125)) (setq y1 (* y 32)) (setq y2 (- y1 (rem y1 1))) (setq y3 (/ y2 2)) (setq y4 (- y3 (rem y3 1))) (setq spa2 (/ y4 16))    ;spa2 is the picket space in the middle in 16ths. (setq dst3 (* spa2 num2))   ;dst3 is the middle dimension.                                       ;This is the number of spaces times the picket   ;spacing for the middle section. (setq endb (- dst1 dst3)) (setq endr1 (/ (* endb 16) 2)) (setq endr2 (- endr1 (rem endr1 1))) (setq endr (/ endr2 16)) (setq endl (- endb endr))   ;endl is the left end dimension minus   ;the right end dimension. (setq ret (list endr1 num2 spa1 endr1));_send back answers);_defun 
in/out file
 

(defun picket:DialogInput (/ dcl_id dialogloaded dialogshow userclick what_next rtvls dstx       pipx barx      )(setq dialogLoaded TdialogShow T) (if (= -1 (setq dcl_id (load_dialog "pickets.DCL")));_looks for and loads the dcl file(progn(princ "\nERROR: Cannot load pickets.DCL");_error trapping(setq dialogLoaded nil)) ;_ end of progn) ;_ end of if(setq what_next 2);_this is a variable for the loop(while (>= what_next 2);_this is the loop(if (and (not (new_dialog "PICKETS" dcl_id));_if everything is found let the program proceeddialogLoaded) ;_ end of and(progn(princ "\nERROR: Cannot show dialog PICKETS");_error trap if there is a problem(setq dialogShow nil)) ;_ end of progn) ;_ end of if(if (and dialogLoaded dialogShow)(progn;;; below is where you assign values to tiles and other stuff(if rtvls(progn(set_tile "end1" (rtos(nth 0 rtvls)2 3))(set_tile "sp" (rtos(nth 1 rtvls)2 3))(set_tile "sp2" (rtos(nth 2 rtvls)2 3))(set_tile "end2" (rtos(nth 3 rtvls)2 3)));_progn(progn(set_tile "end1" "")(set_tile "sp" "")(set_tile "sp2" "")(set_tile "end2" ""));_progn);_if       (if dstx (set_tile "x" dstx)(set_tile "x" ""))(if pipx (set_tile "y" pipx)(set_tile "y" ""))(if barx (set_tile "z" barx)(set_tile "z" ""))(action_tile "cancel" "(done_dialog)(setq UserClick nil) ");_if user click the cancle button make dlg go bye-bye;;; if user clicks okbutton assign tile values to variables (action_tile "accept" (strcat"(progn""(setq dstx (get_tile \"x\"))""(setq pipx (get_tile \"y\"))""(setq barx (get_tile \"z\"))""(if (not (member \"\" (list dstx pipx barx)))""(progn""(done_dialog 4)"")" ;_progn"(alert \"Please enter values\")"")" ;_if")" ;_progn) ;_end strcat) ;_ end of action_tile(setq what_next (start_dialog))) ;_ end of progn) ;_ end of if(cond((= what_next 4)(setq rtvls (picket (atof dstx)(atof pipx)(atof barx))));_do this if user clicks the button named qdx_wld);_end cond);_end while(unload_dialog dcl_id) ) ;_ end of defun
 
 
dcl file:
 

PICKETS :dialog {label = "The Picket Spacing Machine!" ;: row {:boxed_column {label = "ENTER DIMENSIONS EXACTLY";:edit_box {key="x";label="What is your Dimension from Center to Center of Post?" ;//value=dst1;edit_width=14;alignment=centered;}:edit_box {key="y" ;label = "What is your Post Diameter";//value=pip1;edit_width=14;}                  :edit_box {key="z" ;label = "What is your Picket size";//value=bar1;edit_width=14;}:row {:column {width=10;alignment=centered;label="End Space 1";:edit_box {edit_width=6;key="end1" ;//value=endr1;}}:column {width=3;}:column {width=10;label="# of Spaces";:edit_box {edit_width=6;key="sp";//value=num2;}}:row {:column{width=15;:text {key="tt" ; value="SPACES @";alignment=centered;}}}:column {width=10;label="Space Size";:edit_box {edit_width=6;key="sp2";//value=spa2;}}:column {width=3;}:column {width=10;alignment=centered;label="End Space 2";:edit_box {key="end2" ;edit_width=6;//value=endr1;}}}:row {:boxed_column {label="Written by Joe Barrett and Brandon DeLoach   " ;}}}}: row {          // defines the OK/Cancel button row : spacer { width = 20; } : button {    // defines the OK or calculate button   label = "Calculate";   is_default = true;   key = "accept";   width = 8;   fixed_width = true; } : button {    // defines the Cancel button   label = "Cancel";   is_cancel = true;   key = "cancel";   width = 8;   fixed_width = true; } : spacer { width = 20;}}}
 

BLOACH85 发表于 2022-7-6 15:53:40

what is the in/out file saved as? is it a lisp?

BLOACH85 发表于 2022-7-6 15:56:33

do you make this into a application

BLOACH85 发表于 2022-7-6 16:01:20

Hey johnM I really appreciate everything that you did and i was going to post the routine i did this weekend. It worked almost just like yours everything was the same except i would not show the result in feet and inches and after seeing this morning what you did i quickly studied it and saw the
(set_tile "xxxx" (rtos(nth 0 rtvls)2 3))
I was like thats it!
Unfortunately i saved as over it with another routine i did but i will post it shortly.
so you helped alot with your guiding info.
im sure will talk again thanks bud.
 
"JeSuS fReAk":D

JohnM 发表于 2022-7-6 16:07:51

great to hear you figured it out.
so when it is finished and working like planed you should turn it into a vlx file so it will be easy to share and no one cane change it.
页: 1 [2]
查看完整版本: 帮助DCL?