乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
楼主: BLOACH85

[编程交流] 帮助DCL?

[复制链接]

4

主题

327

帖子

324

银币

初来乍到

Rank: 1

铜币
19
发表于 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文件,该文件将调用输入/输出文件。
只有蒲
回复

使用道具 举报

4

主题

327

帖子

324

银币

初来乍到

Rank: 1

铜币
19
发表于 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:
 
  1. [font=Times New Roman][font=Times New Roman];;;;; main calling program[/font][font=Times New Roman](defun c:pkt ()[/font][font=Times New Roman](picket:DialogInput)[/font][font=Times New Roman]  (princ)[/font][font=Times New Roman]  );_defun[/font][font=Times New Roman](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)[/font][font=Times New Roman] (setq dst2 (+ (- dst1 pip1) bar1))  ;dst2 is the spacing of pickets less the pipe post[/font][font=Times New Roman] (setq num1 (/ dst2 4))   ;num1 is the number of picket spaces @ exactly 4"[/font][font=Times New Roman] (setq d (fix (+ num1 0.99)))      ;d is the number of spaces needed to round up[/font][font=Times New Roman] (setq num2 (- d 2))    ;num2 is the number of spacing for the middle of the rail[/font][font=Times New Roman] (setq spa1 (/ dst2 d))[/font][font=Times New Roman] (setq y (+ spa1 0.03125))[/font][font=Times New Roman] (setq y1 (* y 32))[/font][font=Times New Roman] (setq y2 (- y1 (rem y1 1)))[/font][font=Times New Roman] (setq y3 (/ y2 2))[/font][font=Times New Roman] (setq y4 (- y3 (rem y3 1)))[/font][font=Times New Roman] (setq spa2 (/ y4 16))    ;spa2 is the picket space in the middle in 16ths.[/font][font=Times New Roman] (setq dst3 (* spa2 num2))   ;dst3 is the middle dimension.[/font][font=Times New Roman]                                       ;This is the number of spaces times the picket[/font][font=Times New Roman]     ;spacing for the middle section.[/font][font=Times New Roman] (setq endb (- dst1 dst3)) [/font][font=Times New Roman] (setq endr1 (/ (* endb 16) 2))[/font][font=Times New Roman] (setq endr2 (- endr1 (rem endr1 1)))[/font][font=Times New Roman] (setq endr (/ endr2 16))[/font][font=Times New Roman] (setq endl (- endb endr))   ;endl is the left end dimension minus[/font][font=Times New Roman]     ;the right end dimension.[/font][font=Times New Roman] (setq ret (list endr1 num2 spa1 endr1));_send back answers[/font][font=Times New Roman]);_defun[/font][/font]
 
in/out file
 
  1. (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 ok  button 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:
 
  1. 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;}}}
 
回复

使用道具 举报

24

主题

111

帖子

87

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
120
发表于 2022-7-6 15:53:40 | 显示全部楼层
what is the in/out file saved as? is it a lisp?
回复

使用道具 举报

24

主题

111

帖子

87

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
120
发表于 2022-7-6 15:56:33 | 显示全部楼层
do you make this into a application
回复

使用道具 举报

24

主题

111

帖子

87

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
120
发表于 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
回复

使用道具 举报

4

主题

327

帖子

324

银币

初来乍到

Rank: 1

铜币
19
发表于 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.
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-4 21:01 , Processed in 0.559822 second(s), 73 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表