求大佬帮忙弄个小插件
我绘制图纸经常要用到偏移功能 有时候需要删除原线段 有时候不需要删除来回设置太麻烦了想让大佬们帮忙弄个偏移然后删除原图的小插件 不需要删除我就用自带的偏移 需要删除我就用插件中的偏移不需要来回设置 需不需要删除了:'(
本帖最后由 uualice2020 于 2025-5-23 07:09 编辑
增加原图处理
代码如下:启动命令tt(对话框是猫老师dcl工具自动生成)
(defun c:tt();此部分是测试代码用
(Form1_load)
)
(defun Form1_load( / dcl_id Dialog_Return key keys Dcl_File)
(vl-load-com)
(setq dcl_id (load_dialog (setq Dcl_File (Write_Dcl_Form1))));对话框加载
(vl-file-delete Dcl_File);加载后删除DCL文件
(setq Dialog_Return 2)
(while (> Dialog_Return 1) ;循环控制对话框是否结束
(new_dialog "Form1" dcl_id);建立窗体
;-->-->-对话框初始化->-->--
(setq keys '("Text1" "Command1" "Command2" "Command3" "Command4" "accept" "cancel"));列表全部控件名称
(foreach key keys;全部控件的初始化
(if (eval (read (strcat key "_bak"))) (set_tile key (eval (read (strcat key "_bak")))));控件内容
(action_tile key "(Action_Form1_Keys $key $value)");点击动作
)
;--<--<-对话框初始化完成-<--<--
(setq Dialog_Return (start_dialog));开启对话框(用户可见)
(setq d (read Text1_bak))
(if (= Dialog_Return -2)(ngcoo1))
(if (= Dialog_Return -3)(ngcoo2))
(if (= Dialog_Return -4)(ngcoo3))
(if (= Dialog_Return -5)(ngcoo4))
)
(unload_dialog dcl_id);退出时卸载对话框
(princ);防止函数回显
)
(defun Action_Form1_Keys (key value) ;全部控件的点击动作触发
(cond
((= key "accept") ;{确认按钮}
(Get_Form1_Data)
(done_dialog 1);对话框退出返回主函数 传递给Dialog_Return值为1
)
((= key "cancel") ;{取消按钮}
(done_dialog 0);对话框退出返回主函数 传递给Dialog_Return值为0
)
((= key "Command1") ; {"删除原线"} (按钮)
(Get_Form1_Data)
(done_dialog -2)
)
((= key "Command2") ; {"保留原线"} (按钮)
(Get_Form1_Data)
(done_dialog -3)
)
((= key "Command3") ; {"删除原线"} (按钮)
(Get_Form1_Data)
(done_dialog -4)
)
((= key "Command4") ; {"保留原线"} (按钮)
(Get_Form1_Data)
(done_dialog -5)
)
)
)
(defun Get_Form1_Data( / key);临时生成Dcl文件 返回文件名
(foreach key keys
(set (read (strcat key "_bak")) (get_tile key));每个控件都赋给一个变量 用于下次开启初始化
)
)
(defun Write_Dcl_Form1( / Dcl_File file str)
(setq Dcl_File (vl-filename-mktemp nil nil ".Dcl"))
(setq file (open Dcl_File "w"))
(foreach str '(
"Form1:dialog"
"{"
" label = \"偏移工具\";"
" :boxed_column"
" {"
" label = \"数据和功能\" ;"
" :edit_box"
" {"
" key = \"Text1\" ;"
" label = \"偏移间距\" ;"
" width = 15.75 ;"
" height = 0.9375 ;"
" }"
" :button"
" {"
" key = \"Command1\" ;"
" label = \"删除原线带距离\" ;"
" width = 15.75 ;"
" height = 1.875 ;"
" }"
" :button"
" {"
" key = \"Command2\" ;"
" label = \"保留原线带距离\" ;"
" width = 15.75 ;"
" height = 1.875 ;"
" }"
" :button"
" {"
" key = \"Command3\" ;"
" label = \"删除原线无距离\" ;"
" width = 15.75 ;"
" height = 1.875 ;"
" }"
" :button"
" {"
" key = \"Command4\" ;"
" label = \"保留原线无距离\" ;"
" width = 15.75 ;"
" height = 1.875 ;"
" }"
" }"
"ok_cancel ;"
"}"
)
(write-line str file)
)
(close file)
Dcl_File
)
(defun ngcoo1()
(setq e (car(entsel)))
(vl-cmdf "_offset" d e pause "")
(entdel e)
(princ)
)
(defun ngcoo2()
(setq e (car(entsel)))
(vl-cmdf "_offset" d e pause "")
(princ)
)
(defun ngcoo3()
(setq e (car(entsel)))
(vl-cmdf "_offset" "T" e pause "")
(entdel e)
(princ)
)
(defun ngcoo4()
(setq e (car(entsel)))
(vl-cmdf "_offset" "T" e pause "")
(princ)
)
直接下载和上面的一样:
move就行了啊。 这么简单的,别找人,找AI就行了 (defun C:Off ()
(setq e (car(entsel)))
(vl-cmdf "_offset" "T" e pause "")
(entdel e)
(princ)
)
自贡黄明儒 发表于 2025-5-21 16:50
(defun C:Off ()
(setq e (car(entsel)))
(vl-cmdf "_offset" "T" e pause "")
好用,但是不能精确offset。在大神基础上发挥一下。
(defun c:oe ()
(vl-cmdf "_offset" "e" "y" "" "e")
(vl-cmdf "_offset")
)
(defun c:oo ()
(vl-cmdf "_offset" "e" "n" "" "e")
(vl-cmdf "_offset")
) ludaweb 发表于 2025-5-21 18:29
好用,但是不能精确offset。在大神基础上发挥一下。
{:1_1:}你这个有个小BUGoe删除但是o也带删除了 oe不删除o也不删除了没区别啊。。。 uualice2020 发表于 2025-5-21 20:55
已增加删除原图代码 本帖最后由 ludaweb 于 2025-5-21 21:39 编辑
amook147 发表于 2025-5-21 19:14
你这个有个小BUGoe删除但是o也带删除了 oe不删除o也不删除了没区别啊。。。
oe删除
oo不删除
如果你想一劳永逸,就用这个把系统的o替换掉。
(defun c:oe ()
(vl-cmdf "_offset" "e" "y" "" "e")
(vl-cmdf "_offset")
)
(defun c:o ()
(vl-cmdf "_offset" "e" "n" "" "e")
(vl-cmdf "_offset")
)
页:
[1]
2