明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 603|回复: 10

[源码] 将DCL源文件嵌入LISP

[复制链接]
发表于 2024-4-28 14:14 | 显示全部楼层 |阅读模式
本帖最后由 OooCcc 于 2024-4-28 14:23 编辑

思路:


1. 将DCL文档内容转换为带\t制表符及换行符\n的文本文件(这个可以使用我另一个帖子中的程序,直接在生成DCL文件的同时生成对应的文本文件),且每行内容为一个字符串"..."段落。这样就可以使用lisp把该文本当做list表来进行处理。
2. 在程序内首先用该文本段生成一个临时的DCL文件,这样就可以正常使用lisp程序像处理正常DCL文件一样对其进行进行处理了。

主要源码如下:

首先定义list变量,用于保存对话框文本段,并调用变量创建临时DCL文件,接下去就可以对该DCL文件进行正常操作了。
  1. ;DCL对话框定义文本段
  2.   (setq dclList (list "dlgRevLayers:dialog{" "\tlabel = \"Reversion Layer Manager .: O.C. :: 2024/04/23 :.\";"
  3.                       "\t\t:row{" "\t\t\theight = 30;" "\t\t\t:boxed_column{" "\t\t\t\tlabel = \"\";"
  4.                       "\t\t\t\tchildren_alignment = TOP;" "\t\t\t\talignment = top;" "\t\t\t\t:column{"
  5.                       "\t\t\t\t\tfixed_height = true;" "\t\t\t\t\t:boxed_column{" "\t\t\t\t\t\tlabel = \"Model Selection:\";"
  6.                       "\t\t\t\t\t:radio_button{" "\t\t\t\t\t\tkey = \"optSelectObject\";"
  7.                       "\t\t\t\t\t\tlabel = \"Select Layers By &Object\";" "\t\t\t\t\t}" "\t\t\t\t\t:radio_button{"
  8.                       "\t\t\t\t\t\tkey = \"optKeyLayer\";" "\t\t\t\t\t\tlabel = \"Select Layers By &Key\";"
  9.                       "\t\t\t\t\t\tvalue = \"1\";" "\t\t\t\t\t}" "\t\t\t\t\t}" "\t\t\t\t\t:boxed_column{"
  10.                       "\t\t\t\t\t\tlabel = \"By Key:\";" "\t\t\t\t\t:edit_box{" "\t\t\t\t\t\tkey = \"edbKeyLayer\";"
  11.                       "\t\t\t\t\t\tlabel = \"\";" "\t\t\t\t\t}" "\t\t\t\t\t:button{" "\t\t\t\t\t\tkey = \"btnStartSearch\";"
  12.                       "\t\t\t\t\t\tlabel = \"&Start Search\";" "\t\t\t\t\t}" "\t\t\t\t\t}" "\t\t\t\t\t:boxed_row{"
  13.                       "\t\t\t\t\t\tlabel = \"By Object:\";" "\t\t\t\t\t:button{" "\t\t\t\t\t\tkey = \"btnSelectObject\";"
  14.                       "\t\t\t\t\t\tlabel = \"< &Pick An Object\";" "\t\t\t\t\t\tis_enabled = false;" "\t\t\t\t\t}"
  15.                       "\t\t\t\t\t}" "\t\t\t\t}" "\t\t\t:toggle{" "\t\t\t\tkey = \"chkXREFLayers\";"
  16.                       "\t\t\t\tlabel = \"Include &XREF Layers\";" "\t\t\t\tvalue = \"1\";" "\t\t\t\talignment = bottom;"
  17.                       "\t\t\t\tfixed_height = true;" "\t\t\t}" "\t\t\t}" "\t\t\t:column{" "\t\t\t\t:boxed_column{"
  18.                       "\t\t\t\t\tlabel = \"\";" "\t\t\t\t:list_box{" "\t\t\t\t\tkey = \"lstLayers\";"
  19.                       "\t\t\t\t\tlabel = \"Layers For Setting:\";" "\t\t\t\t\twidth = 50;" "\t\t\t\t}" "\t\t\t\t:button{"
  20.                       "\t\t\t\t\tkey = \"btnLoadLayers\";" "\t\t\t\t\tlabel = \"&Reload All Layers\";" "\t\t\t\t}" "\t\t\t\t}"
  21.                       "\t\t\t\t:boxed_column{" "\t\t\t\t\tlabel = \"Setting For Layers:\";" "\t\t\t\t\talignment = bottom;"
  22.                       "\t\t\t\t\tfixed_height = true;" "\t\t\t\t\t:row{" "\t\t\t\t\t:toggle{" "\t\t\t\t\t\tkey = \"chkLock\";"
  23.                       "\t\t\t\t\t\tlabel = \"&Lock\";" "\t\t\t\t\t\tvalue = \"1\";" "\t\t\t\t\t}" "\t\t\t\t\t:toggle{"
  24.                       "\t\t\t\t\t\tkey = \"chkFreeze\";" "\t\t\t\t\t\tlabel = \"&Freeze\";" "\t\t\t\t\t}" "\t\t\t\t\t:toggle{"
  25.                       "\t\t\t\t\t\tkey = \"chkPrint\";" "\t\t\t\t\t\tlabel = \"Prin&t\";" "\t\t\t\t\t\tvalue = \"1\";"
  26.                       "\t\t\t\t\t}" "\t\t\t\t\t}" "\t\t\t\t\t:row{" "\t\t\t\t\t:button{"
  27.                       "\t\t\t\t\t\tkey = \"btnStartSetting\";" "\t\t\t\t\t\tlabel = \"&Do It !!!\";" "\t\t\t\t\t}"
  28.                       "\t\t\t\t\t:button{" "\t\t\t\t\t\tkey = \"accept\";" "\t\t\t\t\t\tlabel = \"&Quit\";"
  29.                       "\t\t\t\t\t\tis_cancel = true;" "\t\t\t\t\t}" "\t\t\t\t\t}" "\t\t\t\t}" "\t\t\t}" "\t\t}" "}"
  30.                 )
  31.   )
  32.   (setq dia_name "dlgRevLayers" ;;对话框名称
  33.         dcl_file (OC-DLG-create-DCLfile dclList)
  34.   )


自定义函数 OC-DLG-create-DCLfile,用于创建临时DCL文件以供程序使用,该函数返回临时文件的完整路径及名称


  1. (defun OC-DLG-create-DCLfile (dclFileList / _tempFileName _fopen ; 文件操作相关变量
  2.                              )
  3.   (setq _tempFileName (strcat (vl-filename-mktemp) ".dcl") ;获取临时文件名及路径
  4.   )
  5.   (OC-FILE-WriteListToFile "" _tempFileName dclFileList) ;创建临时dcl文件
  6.   _tempFileName
  7. )



源码文件:

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2024-4-28 14:18 | 显示全部楼层
 楼主| 发表于 2024-4-28 14:26 | 显示全部楼层
自贡黄明儒 发表于 2024-4-28 14:18
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=185632&highlight=dcl&_dsign=7e173f72

谢谢,学习了~~
发表于 2024-4-28 15:23 | 显示全部楼层
http://bbs.mjtd.com/forum.php?mo ... amp;_dsign=f8585f72

DCL也不要手写,直接拉框框
发表于 2024-4-28 16:57 | 显示全部楼层
之前有一个 DCL2"DCL"
 楼主| 发表于 2024-4-28 20:31 | 显示全部楼层
liuhe 发表于 2024-4-28 15:23
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=84254&highlight=%B7%C9%CA%AB&_dsign=f8585f72

DCL ...

这个用着不喜欢,感觉还不如手写方便。
所以我自己搞了个cad画对话框,然后转dcl~
发表于 2024-4-29 08:22 | 显示全部楼层
OooCcc 发表于 2024-4-28 20:31
这个用着不喜欢,感觉还不如手写方便。
所以我自己搞了个cad画对话框,然后转dcl~

不如手写方便,只能说明你对排版的要求低。没有严格的对齐之类的,手写对于排版的美观性非常不友好
 楼主| 发表于 2024-4-29 09:35 | 显示全部楼层
liuhe 发表于 2024-4-29 08:22
不如手写方便,只能说明你对排版的要求低。没有严格的对齐之类的,手写对于排版的美观性非常不友好

所以我才整了个cad画对话框,然后转dcl哈
发表于 2024-4-29 11:13 | 显示全部楼层
建议用飞诗编辑器

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2024-4-29 11:35 来自手机 | 显示全部楼层
感谢各位大师分享
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-13 19:10 , Processed in 0.173144 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表