请大家修改一下这个非常好用的对齐工具
这是一个比较好用的对齐工具,如果我想把这个工具,增加一个顶端对齐和下端对齐,如何修改?;; dq.LSP
;; 版权所有 (C) 2000-2002明经通道
;;
;; 明经通道网站http://www.mjtd.com
;; 作者:郑立楷mccad@mjtd.com
;;
;; 本软件免费可供进行任何用途需求的拷贝、修改及发行, 但请遵循下述原则:
;;
;; 1)上列的版权通告必须出现在每一份拷贝里。
;; 2)相关的说明文档也必须载有版权通告及本项许可通告。
;;
;; 本软件仅提供作为应用上的参考, 而未声明或隐含任何保证; 对于任何特殊
;; 用途之适应性, 以及商业销售所隐含作出的保证, 在此一概予以否认。
;;
;;程序名称:对象水平对齐程序
;;执行命令:dq
;;程序功能:将选定的对象左对齐、右对齐或对中。
;;
;;
(defun c:dq (/ selobjs oldcmdecho)
(setq oldcmdecho (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq selobjs (ssget))
(if (or (not selobjs) (= (sslength selobjs) 1))
(princ "\n你必须选定两个或两个以上的对象")
(process selobjs)
)
(setvar "cmdecho" oldcmdecho)
(princ)
)
(defun process (selobjs / amode apnt apnt_x
apnt_y count objname vlaxobj MinPoint
MaxPointminext maxext ext_l ext_r
ext_m tpnt
)
(initget "L M R")
(setq amode (getkword
"\n选择对齐方式[左对齐(L)/对中(M)/右对齐(R)]<左对齐>:"
)
)
(if (not amode)
(setq amode "L")
)
(initget 1)
(setq apnt (getpoint "\n选择水平对齐方向的对齐点:"))
(setq apnt_x (car apnt)
apnt_y (cadr apnt)
)
(vl-load-com)
(setq count 0)
(repeat (sslength selobjs)
(setq objname (ssname selobjs count))
(setq vlaxobj (vlax-ename->vla-object objname))
(setq MinPoint (vlax-make-variant))
(setq MaxPoint (vlax-make-variant))
(vla-GetBoundingBox vlaxobj 'MinPoint 'MaxPoint)
(setq minext (vlax-safearray->list MinPoint))
(setq maxext (vlax-safearray->list MaxPoint))
(setq ext_l (car minext))
(setq ext_r (car maxext))
(setq ext_m (+ (/ (abs (- ext_l ext_r)) 2) ext_l))
(cond
((= amode "L")
(setq tpnt (list ext_l apnt_y))
)
((= amode "M")
(setq tpnt (list ext_m apnt_y))
)
((= amode "R")
(setq tpnt (list ext_r apnt_y))
)
)
(if tpnt
(command "_move" objname "" "non" tpnt "non" apnt)
)
(setq count (1+ count))
)
)
(princ"\n对象对齐程序已加载,输入dq命令执行。----明经通道http://www.mjtd.com") alexmai 发表于 2019-11-5 10:47
修改一下变量名称就可以合并
用这个最实用了,什么对象都可以对齐
这代码是那个大师的我忘记了,我修改了一点点。
;;==============实体对齐=================
(defun process (amode / apnt apnt_x apnt_y count objname vlaxobj MinPoint MaxPoint
minext maxext ext_l ext_r ext_m ext_vt ext_vd ext_vm tpnt)
(setq oldcmdecho (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq selobjs (ssget))
(if (or (not selobjs) (= (sslength selobjs) 1))
(princ "\n你必须选定两个或两个以上的对象")
)
(initget 1)
(setq apnt (getpoint "\n选择对齐点:"))
(setq apnt_x (car apnt)
apnt_y (cadr apnt))
(vl-load-com)
(setq count 0)
(repeat (sslength selobjs)
(setq objname (ssname selobjs count))
(setq vlaxobj (vlax-ename->vla-object objname))
(setq MinPoint (vlax-make-variant))
(setq MaxPoint (vlax-make-variant))
(vla-GetBoundingBox vlaxobj 'MinPoint 'MaxPoint)
(setq minext (vlax-safearray->list MinPoint))
(setq maxext (vlax-safearray->list MaxPoint))
(setq ext_l (car minext))
(setq ext_r (car maxext))
(setq ext_m (+ (/ (abs (- ext_l ext_r)) 2) ext_l))
(setq ext_vd (cadr minext))
(setq ext_vt (cadr maxext))
(setq ext_vm (+ (/ (abs (- ext_vt ext_vd)) 2) ext_vd))
(cond
((= amode "HL") (setq tpnt (list ext_l apnt_y)))
((= amode "HM") (setq tpnt (list ext_m apnt_y)))
((= amode "HR") (setq tpnt (list ext_r apnt_y)))
((= amode "VT") (setq tpnt (list apnt_x ext_vt)))
((= amode "VM") (setq tpnt (list apnt_x ext_vm)))
((= amode "VD") (setq tpnt (list apnt_x ext_vd)))
)
(if tpnt (command "_move" objname "" "non" tpnt "non" apnt))
(setq count (1+ count))
)
(setvar "cmdecho" oldcmdecho)
)
(defun c:ad ()
(if (> (setq dcl_id (load_dialog (setq Dcl_File (Write_Dcl_dq)))) 0)
(progn
(vl-file-delete Dcl_File);加载后删除DCL文件
(if (new_dialog "dq" dcl_id "")
(progn
(action_tile "hl" "(done_dialog 1)")
(action_tile "hm" "(done_dialog 2)")
(action_tile "hr" "(done_dialog 3)")
(action_tile "vt" "(done_dialog 4)")
(action_tile "vm" "(done_dialog 5)")
(action_tile "vd" "(done_dialog 6)")
(action_tile "cancel" "(done_dialog 0)")
(setq re (start_dialog))
)
(princ "\n无法显示对话框!")
)
(unload_dialog dcl_id)
)
(princ "\n无法加载对话框!")
)
(cond
((= re 1) (process "HL"))
((= re 2) (process "HM"))
((= re 3) (process "HR"))
((= re 4) (process "VT"))
((= re 5) (process "VM"))
((= re 6) (process "VD"))
)
(princ)
)
(defun Write_Dcl_dq(/ Dcl_File file str)
(setq Dcl_File (vl-filename-mktemp nil nil ".Dcl"))
(setq file (open Dcl_File "w"))
(foreach str '(
"dq:dialog{"
" label=\"实体对齐\";"
" :row{"
":button{label=\" 左对齐x轴 \";key=\"hl\";width=13;height=2.5;allow_accept=true;}"
":button{label=\"水平居中x轴\";key=\"hm\";width=13;height=2.5;allow_accept=true;}"
":button{label=\" 右对齐x轴 \";key=\"hr\";width=13;height=2.5;allow_accept=true;}"
" }"
" :row{"
":button{label=\" 上对齐y轴 \";key=\"vt\";width=13;height=2.5;allow_accept=true;}"
":button{label=\"垂直居中y轴\";key=\"vm\";width=13;height=2.5;allow_accept=true;}"
":button{label=\" 下对齐y轴 \";key=\"vd\";width=13;height=2.5;allow_accept=true;}"
" }"
":button{label=\" 关闭 \";key=\"cancel\";width=13;height=2.2;is_cancel=true;fixed_width=true;alignment=centered;}"
"}"
)
(write-line str file)
)
(close file)
Dcl_File
)
(princ) 在原代码上单独修改了横向对齐,如果要合并就用if函数搞一下就行了
(defun c:tt5 (/ selobjs oldcmdecho)
(setq oldcmdecho (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq selobjs (ssget))
(if (or (not selobjs) (= (sslength selobjs) 1))
(princ "\n你必须选定两个或两个以上的对象")
(process selobjs)
)
(setvar "cmdecho" oldcmdecho)
(princ)
)
(defun process (selobjs / amode apnt apnt_x
apnt_y count objname vlaxobj MinPoint
MaxPointminext maxext ext_l ext_r
ext_m tpnt
)
(initget "D M S")
(setq amode (getkword
"\n选择对齐方式[底对齐(D)/对中(M)/顶对齐(S)]<底对齐>:"
)
)
(if (not amode)
(setq amode "D")
)
(initget 1)
(setq apnt (getpoint "\n选择对齐点:"))
(setq apnt_x (car apnt)
apnt_y (cadr apnt)
)
(vl-load-com)
(setq count 0)
(repeat (sslength selobjs)
(setq objname (ssname selobjs count))
(setq vlaxobj (vlax-ename->vla-object objname))
(setq MinPoint (vlax-make-variant))
(setq MaxPoint (vlax-make-variant))
(vla-GetBoundingBox vlaxobj 'MinPoint 'MaxPoint)
(setq minext (vlax-safearray->list MinPoint))
(setq maxext (vlax-safearray->list MaxPoint))
(setq ext_l (cadr minext))
(setq ext_r (cadr maxext))
(setq ext_m (+ (/ (abs (- ext_l ext_r)) 2) ext_l))
(cond
((= amode "D")
(setq tpnt (list apnt_x ext_l))
)
((= amode "M")
(setq tpnt (list apnt_x ext_m))
)
((= amode "S")
(setq tpnt (list apnt_x ext_r))
)
)
(if tpnt
(command "_move" objname "" "non" tpnt "non" apnt)
)
(setq count (1+ count))
)
) 完成的样子
模型空间里的图纸能对图框下对齐吗 start4444 发表于 2019-3-8 17:03
在原代码上单独修改了横向对齐,如果要合并就用if函数搞一下就行了
这个很好用,但有没有可能做成能将散的对象也对齐呢?这个困惑好久了? sdls 发表于 2019-3-8 21:16
这个很好用,但有没有可能做成能将散的对象也对齐呢?这个困惑好久了?
散的就是全部个体一起对齐,程序不知道那些是同一组的,这个判断条件很难实现 start4444 发表于 2019-3-9 13:58
散的就是全部个体一起对齐,程序不知道那些是同一组的,这个判断条件很难实现
原来是这样!但有没有可能,用框选对象来确定一组,再继续框选另一个对象。依次操作!确定好后再对齐?
我看到晓东工具有个万能排版有这功能,不过只能选两个对象。没能同时多个对象对齐!
以图框内对象为一组可以改下吗,图框下对齐 sdls 发表于 2019-3-9 21:09
原来是这样!但有没有可能,用框选对象来确定一组,再继续框选另一个对象。依次操作!确定好后再对齐?
...
自己选肯定可以实现,就不算批量了,操作慢 sunny_8848 发表于 2019-3-9 21:15
以图框内对象为一组可以改下吗,图框下对齐
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=178718
参考这里,如果图框是块就好办,求得外框线后用ssget框选然后移动对齐