动态块参数修改工具箱
动态块参数修改工具箱第一版。欢迎下载。
谢谢。
守仁格竹GM 发表于 2015-1-9 08:08
使用eval 哪种方法,应该可以节省很多代码,楼主可以研究下
好东西要分享{:1_1:} 很强大,很强大,画这个梁剖面用这个工具最好了,改几个数字就行。 可以X Y两个方向 分别缩放吗 缩放系数还不一样 下面是Lsp源码:
;;;;;程序目录+++++++++
(setq location_dyn_1
"D:/ShanYongLiang/AutoLISP/.V20150106/SylDynDcl.DCL"
)
;;;;请修改上面的DCL对话框路径
;;;---------主程序:---------
(vl-load-com)
(defun c:wd ()
;;调用对话框驱动
(dyn_dcl_load)
(prin1)
)
;;;;###################通用函数#######################
;;;;###################通用函数#######################
;;;---------通用函数1:设置动态块[特定]属性(Lee-Mac提供)---------
(defun lm-setdynpropvalue (blk prp val)
(setq prp (strcase prp))
(vl-some
'(lambda (x)
(if (= prp (strcase (vla-get-propertyname x)))
(progn
(vla-put-value
x
(vlax-make-variant
val
(vlax-variant-type (vla-get-value x))
)
)
(cond (val)
(t)
)
)
)
)
(vlax-invoke blk 'getdynamicblockproperties)
)
)
;;;---------通用函数2:设置的动态块[特定]属性---------
(defun xyl-setentdynpropvalue (par_prp par_val)
(lm-setdynpropvalue
data_dynblk
par_prp
par_val
)
)
;;;---------通用函数3:设置dcl控件值,若无则设默认值---------
(defun xyl-dcl-default-value (par_dcl_key par_default_value par_value)
(if (= par_value nil)
(setq par_value par_default_value)
)
(set_tile par_dcl_key par_value)
)
;;;;###################应用程序#######################
;;;;###################应用程序#######################
;;;---------应用程序999:设置[最近生成]的动态块[特定]属性---------
(defun xyls-dynbox-1 ()
(setvar "cmdecho" 0)
;;取得动态块object
(setq data_dynblk (vlax-ename->vla-object (car (entsel))))
;;下面设置动态块参数
(xyl-setentdynpropvalue
data_dynbox1_selector_1
(atof data_dynbox1_data_1)
)
(xyl-setentdynpropvalue
data_dynbox1_selector_2
(atof data_dynbox1_data_2)
)
(xyl-setentdynpropvalue
data_dynbox1_selector_3
(atof data_dynbox1_data_3)
)
(xyl-setentdynpropvalue
data_dynbox1_selector_4
(atof data_dynbox1_data_4)
)
(xyl-setentdynpropvalue
data_dynbox1_selector_5
(atof data_dynbox1_data_5)
)
(xyl-setentdynpropvalue
data_dynbox1_selector_6
(atof data_dynbox1_data_6)
)
(xyl-setentdynpropvalue
data_dynbox1_selector_7
(atof data_dynbox1_data_7)
)
(xyl-setentdynpropvalue
data_dynbox1_selector_8
(atof data_dynbox1_data_8)
)
(xyl-setentdynpropvalue
data_dynbox1_selector_9
(atof data_dynbox1_data_9)
)
)
;;;---------应用程序1:更新参数话框中edit_box的输入值---------
(defun syls-savedistance (par_dynbox_int)
(setvar "cmdecho" 0)
;;在屏幕上选择两点
(setq point_1 (getpoint "\nPoint 1 :"))
(setq point_2 (getpoint point_1 "\nPoint 2 :"))
(grdraw point_1 point_2 1 1)
;;计算两点间的距离
(setq par_dist_1 (distance point_1 point_2))
;;以下更新对话框中edit_box的输入值
(cond ((= par_dynbox_int 1)
(setq data_dynbox1_data_1 (rtos par_dist_1))
)
((= par_dynbox_int 2)
(setq data_dynbox1_data_2 (rtos par_dist_1))
)
((= par_dynbox_int 3)
(setq data_dynbox1_data_3 (rtos par_dist_1))
)
((= par_dynbox_int 4)
(setq data_dynbox1_data_4 (rtos par_dist_1))
)
((= par_dynbox_int 5)
(setq data_dynbox1_data_5 (rtos par_dist_1))
)
((= par_dynbox_int 6)
(setq data_dynbox1_data_6 (rtos par_dist_1))
)
((= par_dynbox_int 7)
(setq data_dynbox1_data_7 (rtos par_dist_1))
)
((= par_dynbox_int 8)
(setq data_dynbox1_data_8 (rtos par_dist_1))
)
((= par_dynbox_int 9)
(setq data_dynbox1_data_9 (rtos par_dist_1))
)
(t (print "No par_dynbox_int"))
)
)
;;;;###################DCL对话框驱动程序#######################
;;;;###################DCL对话框驱动程序#######################
;;;---------DCL对话框驱动1:加载对话框---------
(defun dyn_dcl_load ()
;;加载对话框,location_dyn_1为文件目录
(setq syldata_dcl_id
(load_dialog location_dyn_1)
)
;;启动对画框
(new_dialog "syl_dyn_dia" syldata_dcl_id)
;;对画框载入值
(syls-setdclvalue)
;;向button按钮添加动作
(action_tile
"dcl_dynbox1_button_1"
"(done_dialog 1)"
)
(action_tile
"dcl_dynbox1_button_2"
"(done_dialog 2)"
)
(action_tile
"dcl_dynbox1_button_3"
"(done_dialog 3)"
)
(action_tile
"dcl_dynbox1_button_4"
"(done_dialog 4)"
)
(action_tile
"dcl_dynbox1_button_5"
"(done_dialog 5)"
)
(action_tile
"dcl_dynbox1_button_6"
"(done_dialog 6)"
)
(action_tile
"dcl_dynbox1_button_7"
"(done_dialog 7)"
)
(action_tile
"dcl_dynbox1_button_8"
"(done_dialog 8)"
)
(action_tile
"dcl_dynbox1_button_9"
"(done_dialog 9)"
)
;;button draw1动作
(action_tile
"dcl_dynbox1_button_draw"
"(syls-savedclvalue)(done_dialog 999)"
)
;;调用程序
(setq dd (start_dialog))
;;根据按钮调用各种子程序
(cond ((= dd 999) (xyls-dynbox-1))
((= dd 1) (syls-savedistance 1))
((= dd 2) (syls-savedistance 2))
((= dd 3) (syls-savedistance 3))
((= dd 4) (syls-savedistance 4))
((= dd 5) (syls-savedistance 5))
((= dd 6) (syls-savedistance 6))
((= dd 7) (syls-savedistance 7))
((= dd 8) (syls-savedistance 8))
((= dd 9) (syls-savedistance 9))
(t (print "未选择操作"))
)
)
;;;---------DCL对话框驱动2:设置对话框中的值---------
(defun syls-setdclvalue ()
;;edit_box selector值
(xyl-dcl-default-value
"dcl_dynbox1_selector_1"
"NoDefault"
data_dynbox1_selector_1
)
(xyl-dcl-default-value
"dcl_dynbox1_selector_2"
"NoDefault"
data_dynbox1_selector_2
)
(xyl-dcl-default-value
"dcl_dynbox1_selector_3"
"NoDefault"
data_dynbox1_selector_3
)
(xyl-dcl-default-value
"dcl_dynbox1_selector_4"
"NoDefault"
data_dynbox1_selector_4
)
(xyl-dcl-default-value
"dcl_dynbox1_selector_5"
"NoDefault"
data_dynbox1_selector_5
)
(xyl-dcl-default-value
"dcl_dynbox1_selector_6"
"NoDefault"
data_dynbox1_selector_6
)
(xyl-dcl-default-value
"dcl_dynbox1_selector_7"
"NoDefault"
data_dynbox1_selector_7
)
(xyl-dcl-default-value
"dcl_dynbox1_selector_8"
"NoDefault"
data_dynbox1_selector_8
)
(xyl-dcl-default-value
"dcl_dynbox1_selector_9"
"NoDefault"
data_dynbox1_selector_9
)
;;edit_box data值
(xyl-dcl-default-value
"dcl_dynbox1_data_1"
"NoDefault"
data_dynbox1_data_1
)
(xyl-dcl-default-value
"dcl_dynbox1_data_2"
"NoDefault"
data_dynbox1_data_2
)
(xyl-dcl-default-value
"dcl_dynbox1_data_3"
"NoDefault"
data_dynbox1_data_3
)
(xyl-dcl-default-value
"dcl_dynbox1_data_4"
"NoDefault"
data_dynbox1_data_4
)
(xyl-dcl-default-value
"dcl_dynbox1_data_5"
"NoDefault"
data_dynbox1_data_5
)
(xyl-dcl-default-value
"dcl_dynbox1_data_6"
"NoDefault"
data_dynbox1_data_6
)
(xyl-dcl-default-value
"dcl_dynbox1_data_7"
"NoDefault"
data_dynbox1_data_7
)
(xyl-dcl-default-value
"dcl_dynbox1_data_8"
"NoDefault"
data_dynbox1_data_8
)
(xyl-dcl-default-value
"dcl_dynbox1_data_9"
"NoDefault"
data_dynbox1_data_9
)
)
;;;---------DCL对话框驱动3:保存对话框中的值---------
(defun syls-savedclvalue ()
(setq data_dynbox1_selector_1 (get_tile "dcl_dynbox1_selector_1"))
(setq data_dynbox1_selector_2 (get_tile "dcl_dynbox1_selector_2"))
(setq data_dynbox1_selector_3 (get_tile "dcl_dynbox1_selector_3"))
(setq data_dynbox1_selector_4 (get_tile "dcl_dynbox1_selector_4"))
(setq data_dynbox1_selector_5 (get_tile "dcl_dynbox1_selector_5"))
(setq data_dynbox1_selector_6 (get_tile "dcl_dynbox1_selector_6"))
(setq data_dynbox1_selector_7 (get_tile "dcl_dynbox1_selector_7"))
(setq data_dynbox1_selector_8 (get_tile "dcl_dynbox1_selector_8"))
(setq data_dynbox1_selector_9 (get_tile "dcl_dynbox1_selector_9"))
(setq data_dynbox1_data_1 (get_tile "dcl_dynbox1_data_1"))
(setq data_dynbox1_data_2 (get_tile "dcl_dynbox1_data_2"))
(setq data_dynbox1_data_3 (get_tile "dcl_dynbox1_data_3"))
(setq data_dynbox1_data_4 (get_tile "dcl_dynbox1_data_4"))
(setq data_dynbox1_data_5 (get_tile "dcl_dynbox1_data_5"))
(setq data_dynbox1_data_6 (get_tile "dcl_dynbox1_data_6"))
(setq data_dynbox1_data_7 (get_tile "dcl_dynbox1_data_7"))
(setq data_dynbox1_data_8 (get_tile "dcl_dynbox1_data_8"))
(setq data_dynbox1_data_9 (get_tile "dcl_dynbox1_data_9"))
) 然后这里是相应的DCL对话框文件:
syl_dyn_dia:dialog{
label="WD动态块工具箱Version:V20140106";
:boxed_row{
:boxed_column{
label="Selector";
:edit_box{label="Selector 1" ;key="dcl_dynbox1_selector_1";}
:edit_box{label="Selector 2" ;key="dcl_dynbox1_selector_2";}
:edit_box{label="Selector 3" ;key="dcl_dynbox1_selector_3";}
:edit_box{label="Selector 4" ;key="dcl_dynbox1_selector_4";}
:edit_box{label="Selector 5" ;key="dcl_dynbox1_selector_5";}
:edit_box{label="Selector 6" ;key="dcl_dynbox1_selector_6";}
:edit_box{label="Selector 7" ;key="dcl_dynbox1_selector_7";}
:edit_box{label="Selector 8" ;key="dcl_dynbox1_selector_8";}
:edit_box{label="Selector 9" ;key="dcl_dynbox1_selector_9";}
}
:boxed_column{
label="Data";
:edit_box{label="Data 1" ;key="dcl_dynbox1_data_1";}
:edit_box{label="Data 2" ;key="dcl_dynbox1_data_2";}
:edit_box{label="Data 3" ;key="dcl_dynbox1_data_3";}
:edit_box{label="Data 4" ;key="dcl_dynbox1_data_4";}
:edit_box{label="Data 5" ;key="dcl_dynbox1_data_5";}
:edit_box{label="Data 6" ;key="dcl_dynbox1_data_6";}
:edit_box{label="Data 7" ;key="dcl_dynbox1_data_7";}
:edit_box{label="Data 8" ;key="dcl_dynbox1_data_8";}
:edit_box{label="Data 9" ;key="dcl_dynbox1_data_9";}
}
:boxed_column{
label="Get";
:button{label="Get 1";key="dcl_dynbox1_button_1";}
:button{label="Get 2";key="dcl_dynbox1_button_2";}
:button{label="Get 3";key="dcl_dynbox1_button_3";}
:button{label="Get 4";key="dcl_dynbox1_button_4";}
:button{label="Get 5";key="dcl_dynbox1_button_5";}
:button{label="Get 6";key="dcl_dynbox1_button_6";}
:button{label="Get 7";key="dcl_dynbox1_button_7";}
:button{label="Get 8";key="dcl_dynbox1_button_8";}
:button{label="Get 9";key="dcl_dynbox1_button_9";}
}
}
:boxed_row{
label="Action";
cancel_button;
:button{label="Draw";key="dcl_dynbox1_button_draw";}
}
} 竟然是动态块的程序,好难得见到啊,顶一下 很多论坛里求助的人都没你的水平. 谢谢分享,先试一下 必须支持一下,难得见好东西,非常感谢,明天电脑下下来看看,先占个位置混个脸熟 很少见的程序! 感谢楼主分享! 我想楼主是不是应该把演示的DWG文档也传上来? 使用eval 哪种方法,应该可以节省很多代码,楼主可以研究下