本帖最后由 OooCcc 于 2024-4-28 14:23 编辑
思路:
1. 将DCL文档内容转换为带\t制表符及换行符\n的文本文件(这个可以使用我另一个帖子中的程序,直接在生成DCL文件的同时生成对应的文本文件),且每行内容为一个字符串"..."段落。这样就可以使用lisp把该文本当做list表来进行处理。
2. 在程序内首先用该文本段生成一个临时的DCL文件,这样就可以正常使用lisp程序像处理正常DCL文件一样对其进行进行处理了。
主要源码如下:
首先定义list变量,用于保存对话框文本段,并调用变量创建临时DCL文件,接下去就可以对该DCL文件进行正常操作了。
- ;DCL对话框定义文本段
- (setq dclList (list "dlgRevLayers:dialog{" "\tlabel = \"Reversion Layer Manager .: O.C. :: 2024/04/23 :.\";"
- "\t\t:row{" "\t\t\theight = 30;" "\t\t\t:boxed_column{" "\t\t\t\tlabel = \"\";"
- "\t\t\t\tchildren_alignment = TOP;" "\t\t\t\talignment = top;" "\t\t\t\t:column{"
- "\t\t\t\t\tfixed_height = true;" "\t\t\t\t\t:boxed_column{" "\t\t\t\t\t\tlabel = \"Model Selection:\";"
- "\t\t\t\t\t:radio_button{" "\t\t\t\t\t\tkey = \"optSelectObject\";"
- "\t\t\t\t\t\tlabel = \"Select Layers By &Object\";" "\t\t\t\t\t}" "\t\t\t\t\t:radio_button{"
- "\t\t\t\t\t\tkey = \"optKeyLayer\";" "\t\t\t\t\t\tlabel = \"Select Layers By &Key\";"
- "\t\t\t\t\t\tvalue = \"1\";" "\t\t\t\t\t}" "\t\t\t\t\t}" "\t\t\t\t\t:boxed_column{"
- "\t\t\t\t\t\tlabel = \"By Key:\";" "\t\t\t\t\t:edit_box{" "\t\t\t\t\t\tkey = \"edbKeyLayer\";"
- "\t\t\t\t\t\tlabel = \"\";" "\t\t\t\t\t}" "\t\t\t\t\t:button{" "\t\t\t\t\t\tkey = \"btnStartSearch\";"
- "\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{"
- "\t\t\t\t\t\tlabel = \"By Object:\";" "\t\t\t\t\t:button{" "\t\t\t\t\t\tkey = \"btnSelectObject\";"
- "\t\t\t\t\t\tlabel = \"< &Pick An Object\";" "\t\t\t\t\t\tis_enabled = false;" "\t\t\t\t\t}"
- "\t\t\t\t\t}" "\t\t\t\t}" "\t\t\t:toggle{" "\t\t\t\tkey = \"chkXREFLayers\";"
- "\t\t\t\tlabel = \"Include &XREF Layers\";" "\t\t\t\tvalue = \"1\";" "\t\t\t\talignment = bottom;"
- "\t\t\t\tfixed_height = true;" "\t\t\t}" "\t\t\t}" "\t\t\t:column{" "\t\t\t\t:boxed_column{"
- "\t\t\t\t\tlabel = \"\";" "\t\t\t\t:list_box{" "\t\t\t\t\tkey = \"lstLayers\";"
- "\t\t\t\t\tlabel = \"Layers For Setting:\";" "\t\t\t\t\twidth = 50;" "\t\t\t\t}" "\t\t\t\t:button{"
- "\t\t\t\t\tkey = \"btnLoadLayers\";" "\t\t\t\t\tlabel = \"&Reload All Layers\";" "\t\t\t\t}" "\t\t\t\t}"
- "\t\t\t\t:boxed_column{" "\t\t\t\t\tlabel = \"Setting For Layers:\";" "\t\t\t\t\talignment = bottom;"
- "\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\";"
- "\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{"
- "\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{"
- "\t\t\t\t\t\tkey = \"chkPrint\";" "\t\t\t\t\t\tlabel = \"Prin&t\";" "\t\t\t\t\t\tvalue = \"1\";"
- "\t\t\t\t\t}" "\t\t\t\t\t}" "\t\t\t\t\t:row{" "\t\t\t\t\t:button{"
- "\t\t\t\t\t\tkey = \"btnStartSetting\";" "\t\t\t\t\t\tlabel = \"&Do It !!!\";" "\t\t\t\t\t}"
- "\t\t\t\t\t:button{" "\t\t\t\t\t\tkey = \"accept\";" "\t\t\t\t\t\tlabel = \"&Quit\";"
- "\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}" "}"
- )
- )
- (setq dia_name "dlgRevLayers" ;;对话框名称
- dcl_file (OC-DLG-create-DCLfile dclList)
- )
自定义函数 OC-DLG-create-DCLfile,用于创建临时DCL文件以供程序使用,该函数返回临时文件的完整路径及名称
- (defun OC-DLG-create-DCLfile (dclFileList / _tempFileName _fopen ; 文件操作相关变量
- )
- (setq _tempFileName (strcat (vl-filename-mktemp) ".dcl") ;获取临时文件名及路径
- )
- (OC-FILE-WriteListToFile "" _tempFileName dclFileList) ;创建临时dcl文件
- _tempFileName
- )
源码文件:
|