明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 163|回复: 9

[提问] 求大佬帮忙弄个小插件

[复制链接]
发表于 7 小时前 | 显示全部楼层 |阅读模式
我绘制图纸经常要用到偏移功能   有时候需要删除原线段 有时候不需要删除  来回设置太麻烦了

想让大佬们帮忙弄个偏移然后删除原图的小插件    不需要删除我就用自带的偏移    需要删除我就用插件中的偏移  不需要来回设置 需不需要删除了
回复

使用道具 举报

发表于 7 小时前 | 显示全部楼层
move就行了啊。
回复 支持 反对

使用道具 举报

发表于 7 小时前 | 显示全部楼层
这么简单的,别找人,找AI就行了
回复 支持 反对

使用道具 举报

发表于 7 小时前 | 显示全部楼层
(defun C:Off ()
  (setq e (car(entsel)))
  (vl-cmdf "_offset" "T" e pause "")
  (entdel e)
  (princ)
)
回复 支持 反对

使用道具 举报

发表于 5 小时前 | 显示全部楼层
自贡黄明儒 发表于 2025-5-21 16:50
(defun C:Off ()
  (setq e (car(entsel)))
  (vl-cmdf "_offset" "T" e pause "")

好用,但是不能精确offset。在大神基础上发挥一下。
  1. (defun c:oe ()
  2. (vl-cmdf "_offset" "e" "y" "" "e")
  3. (vl-cmdf "_offset")
  4. )
  5. (defun c:oo ()
  6. (vl-cmdf "_offset" "e" "n" "" "e")
  7. (vl-cmdf "_offset")
  8. )
回复 支持 反对

使用道具 举报

发表于 5 小时前 | 显示全部楼层


代码如下:启动命令tt(对话框是猫老师dcl工具自动生成)
  1. (defun c:tt();此部分是测试代码用
  2.   (Form1_load)
  3. )

  4. (defun Form1_load( / dcl_id Dialog_Return key keys Dcl_File)
  5.   (vl-load-com)
  6.   (setq dcl_id (load_dialog (setq Dcl_File (Write_Dcl_Form1))));对话框加载
  7.   (vl-file-delete Dcl_File);加载后删除DCL文件
  8.   (setq Dialog_Return 2)
  9.   (while (> Dialog_Return 1) ;循环控制对话框是否结束
  10.     (new_dialog "Form1" dcl_id);建立窗体
  11. ;-->-->-对话框初始化->-->--
  12.     (setq keys '("Text1" "Command1" "Command2" "Command3" "Command4" "accept" "cancel"));列表全部控件名称
  13.     (foreach key keys;全部控件的初始化
  14.       (if (eval (read (strcat key "_bak"))) (set_tile key (eval (read (strcat key "_bak")))));控件内容
  15.       (action_tile key "(Action_Form1_Keys $key $value)");点击动作
  16.     )
  17. ;--<--<-对话框初始化完成-<--<--
  18.     (setq Dialog_Return (start_dialog));开启对话框(用户可见)
  19.                 (setq d (read Text1_bak))
  20.                 (if (= Dialog_Return -2)(ngcoo1))
  21.                 (if (= Dialog_Return -3)(ngcoo2))
  22.                 (if (= Dialog_Return -4)(ngcoo3))
  23.                 (if (= Dialog_Return -5)(ngcoo4))
  24.   )
  25.   (unload_dialog dcl_id);退出时卸载对话框
  26.   (princ);防止函数回显
  27. )

  28. (defun Action_Form1_Keys (key value) ;全部控件的点击动作触发
  29.   (cond
  30.     ((= key "accept") ;{确认按钮}
  31.       
  32.       (Get_Form1_Data)
  33.       (done_dialog 1);对话框退出返回主函数 传递给Dialog_Return值为1
  34.     )
  35.     ((= key "cancel") ;{取消按钮}
  36.       
  37.       (done_dialog 0);对话框退出返回主函数 传递给Dialog_Return值为0
  38.     )
  39.     ((= key "Command1") ; {"删除原线"} (按钮)
  40.                                   (Get_Form1_Data)
  41.       (done_dialog -2)
  42.     )
  43.     ((= key "Command2") ; {"保留原线"} (按钮)
  44.                                   (Get_Form1_Data)
  45.       (done_dialog -3)
  46.     )
  47.     ((= key "Command3") ; {"删除原线"} (按钮)
  48.                                   (Get_Form1_Data)
  49.       (done_dialog -4)
  50.     )
  51.     ((= key "Command4") ; {"保留原线"} (按钮)
  52.                                   (Get_Form1_Data)
  53.       (done_dialog -5)
  54.     )
  55.   )
  56. )
  57. (defun Get_Form1_Data( / key);临时生成Dcl文件 返回文件名
  58.   (foreach key keys
  59.     (set (read (strcat key "_bak")) (get_tile key));每个控件都赋给一个变量 用于下次开启初始化
  60.   )
  61. )
  62. (defun Write_Dcl_Form1( / Dcl_File file str)
  63.   (setq Dcl_File (vl-filename-mktemp nil nil ".Dcl"))
  64.   (setq file (open Dcl_File "w"))
  65.   (foreach str '(
  66.     "Form1:dialog"
  67.     "{"
  68.     " label = \"偏移工具\";"
  69.     "    :boxed_column"
  70.     "    {"
  71.     "     label = \"数据和功能\" ;"
  72.     "        :edit_box"
  73.     "        {"
  74.     "            key = \"Text1\" ;"
  75.     "            label = \"偏移间距\" ;"
  76.     "            width = 15.75 ;"
  77.     "            height = 0.9375 ;"
  78.     "        }"
  79.     "        :button"
  80.     "        {"
  81.     "            key = \"Command1\" ;"
  82.     "            label = \"删除原线带距离\" ;"
  83.     "            width = 15.75 ;"
  84.     "            height = 1.875 ;"
  85.     "        }"
  86.     "        :button"
  87.     "        {"
  88.     "            key = \"Command2\" ;"
  89.     "            label = \"保留原线带距离\" ;"
  90.     "            width = 15.75 ;"
  91.     "            height = 1.875 ;"
  92.     "        }"
  93.     "        :button"
  94.     "        {"
  95.     "            key = \"Command3\" ;"
  96.     "            label = \"删除原线无距离\" ;"
  97.     "            width = 15.75 ;"
  98.     "            height = 1.875 ;"
  99.     "        }"
  100.     "        :button"
  101.     "        {"
  102.     "            key = \"Command4\" ;"
  103.     "            label = \"保留原线无距离\" ;"
  104.     "            width = 15.75 ;"
  105.     "            height = 1.875 ;"
  106.     "        }"
  107.     "    }"
  108.     "ok_cancel ;"
  109.     "}"
  110.     )
  111.     (write-line str file)
  112.   )
  113.   (close file)
  114.   Dcl_File
  115. )
  116. (defun ngcoo1  ()
  117. (setq e (car(entsel)))
  118.   (vl-cmdf "_offset" d e pause "")
  119.   (entdel e)
  120.   (princ)
  121.   )
  122. (defun ngcoo2  ()
  123. (setq e (car(entsel)))
  124.   (vl-cmdf "_offset" d e pause "")
  125.   (princ)
  126.   )
  127. (defun ngcoo3  ()
  128. (setq e (car(entsel)))
  129.   (vl-cmdf "_offset" "T" e pause "")
  130.   (entdel e)
  131.   (princ)
  132.   )
  133. (defun ngcoo4  ()
  134. (setq e (car(entsel)))
  135.   (vl-cmdf "_offset" "T" e pause "")
  136.   (princ)
  137.   )


直接下载和上面的一样:

本帖子中包含更多资源

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

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 4 小时前 | 显示全部楼层
ludaweb 发表于 2025-5-21 18:29
好用,但是不能精确offset。在大神基础上发挥一下。

你这个有个小BUG  oe删除  但是o也带删除了   oe不删除  o也不删除了  没区别啊。。。
回复 支持 反对

使用道具 举报

发表于 3 小时前 | 显示全部楼层
本帖最后由 uualice2020 于 2025-5-21 21:00 编辑






本帖子中包含更多资源

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

x
回复 支持 反对

使用道具 举报

发表于 2 小时前 | 显示全部楼层

已增加删除原图代码
回复 支持 反对

使用道具 举报

发表于 2 小时前 | 显示全部楼层
本帖最后由 ludaweb 于 2025-5-21 21:39 编辑
amook147 发表于 2025-5-21 19:14
你这个有个小BUG  oe删除  但是o也带删除了   oe不删除  o也不删除了  没区别啊。。。

oe删除
oo不删除

如果你想一劳永逸,就用这个把系统的o替换掉。
  1. (defun c:oe ()
  2. (vl-cmdf "_offset" "e" "y" "" "e")
  3. (vl-cmdf "_offset")
  4. )
  5. (defun c:o ()
  6. (vl-cmdf "_offset" "e" "n" "" "e")
  7. (vl-cmdf "_offset")
  8. )


回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-5-21 23:56 , Processed in 0.197470 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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