lameduck 发表于 2015-5-19 12:42:51

求助,用opendcl做扩展属性对话框的问题

本帖最后由 lameduck 于 2015-5-26 16:59 编辑

新手,opendcl不是很熟悉,附件中程序准备实现扩展属性输入的功能,就像特性一样!
但是控件触发都不能实现我想要的结果!步骤是拾取对象->有属性就显示->更改对话框->更新属性。
更新属性不能触发
麻烦哪位高手帮忙指点一下!(defun C:pro()
(vl-load-com)
(setq cmdecho (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(command "_OPENDCL")
(setvar "CMDECHO" cmdecho)
(Setq Lxd (Dcl_Project_Load "F:/pro.odcl"))
(dcl_Form_Show "pro" "form1")
(princ)
)
(defun c:pro_Form1_OnDocActivated (/)
(c:pro_Form1_OnInitialize)
)
(defun c:pro_Form1_OnEnteringNoDocState (/)
(dcl_Form_Close pro_Form1)
)

;;初始化
(defun c:pro_Form1_OnInitialize(/)
    (dcl_ComboBox_SetCurSel pro_Form1_ComboBox1 -1)
    (dcl_Control_SetText pro_Form1_TextBox2 "")
    (dcl_Control_SetText pro_Form1_TextBox3 "")
    (dcl_Control_SetText pro_Form1_TextBox4 "")
    (dcl_OptionList_SetCurSel pro_Form1_OptionList1 -1)
    (dcl_OptionList_SetCurSel pro_Form1_OptionList2 -1)
    (dcl_OptionList_SetCurSel pro_Form1_OptionList3 -1))

;;拾取对象若有扩展属性在相应的位置显示
(defun c:pro_Form1_TextButton1_OnClicked()
(c:pro_Form1_OnInitialize)
(setq ss(car(entsel)))
(redraw ss 3)
(if (getxdata ss "obname") (dcl_Control_setText pro_Form1_ComboBox1 (getxdata ss "obname")))
(if(getxdata ss "floorno") (dcl_Control_SetText pro_Form1_TextBox2 (getxdata ss "floorno")))
(if(getxdata ss "topfloor") (dcl_Control_SetText pro_Form1_TextBox3 (getxdata ss "topfloor")))
(if(getxdata ss "buildno") (dcl_Control_SetText pro_Form1_TextBox4 (getxdata ss "buildno")))
(if(getxdata ss "areacal") (dcl_Control_SetCurrentSelection pro_Form1_OptionList1 (areacal_m (getxdata ss "areacal"))))
(if(getxdata ss "arearatio") (dcl_Control_SetCurrentSelection pro_Form1_OptionList2 (arearatio_m (getxdata ss "arearatio"))))
(if(getxdata ss "buildfunction") (dcl_Control_SetCurrentSelection pro_Form1_OptionList3 (buildfunction_m (getxdata ss "buildfunction"))))
(dcl_Control_SetEnabled pro_Form1_TextButton1 T)
)

;;;获取实体扩展对象
(defun getxdata(ob xpro / proxdata a)
(setq proxdata(entget ob (list xpro)))
(setqa(cdr(cadr(cadr(assoc -3 proxdata)))))
)
;;;改变实体扩展对象
(defun changexdata(ob xpro input / proxdata e else_xdata)
(setq proxdata(entget ob))
(setq else_xdata(cdr(assoc -3 (entget ob '("*")))))
(setq else_xdata(vl-remove-if '(lambda(x) (= (car x) xpro)) else_xdata))
(if (not else_xdata)
    (setq proxdata(cons(list -3 (list xpro(cons 1000 input))) proxdata))
    (setq proxdata(cons (cons -3 (cons (list xpro(cons 1000 input)) else_xdata)) proxdata)))
(regapp xpro)
(entmod proxdata)
)

;;;加入实体扩展对象         
(defun putxdata(ob xpro input / proxdata else_xdata)
(setq proxdata(entget ob))
(setq else_xdata(cdr(assoc -3 (entget ob '("*")))))
(if (not else_xdata)
    (setq proxdata(cons(list -3 (list xpro(cons 1000 input))) proxdata))
    (setq proxdata(cons (cons -3 (cons (list xpro(cons 1000 input)) else_xdata)) proxdata)))
(regapp xpro)
(entmod proxdata)
)

(defun obname_m(str)
(cond ((= str "建筑物") (setq a 0))
((= str "建筑物附属") (setq a 1))
((= str "夹层") (setq a 1)))
a)
(defun areacal_m(str)
(cond ((= str "2") (setq a 0))
      ((= str "1") (setq a 1))
((= str "0.5") (setq a 2))
((= str "0") (setq a 3))
((= str "-1") (setq a 4)))
a)

(defun arearatio_m(str)
(cond ((= str "不计容") (setq a 0))
((= str "计容") (setq a 1))
((= str "计容") (setq a 2)))
a)

(defun buildfunction_m(str)
(cond ((= str "住宅") (setq a 0))
((= str "商业") (setq a 1))
((= str "办公") (setq a 2))
((= str "其他") (setq a 3)))
a)


(defun isint(s) ;;判断是否为整数是为T否为nil
(cond ((not (=(type s) 'str)) nil)
((= (type(read s)) 'int) T)
(T nil)
))
;;更改属性
(defun c:pro_Form1_TextButton2_OnClicked (/)
(setq Value(dcl_Control_getText pro_Form1_ComboBox1)
f_NewValue(dcl_Control_getText pro_Form1_TextBox2)
t_NewValue(dcl_Control_getText pro_Form1_TextBox3)
bn_NewValue(dcl_Control_getText pro_Form1_TextBox4)
ac_Value(dcl_OptionList_GetButtonCaption pro_Form1_OptionList1 (dcl_OptionList_GetCurSel pro_Form1_OptionList1))
ar_Value(dcl_OptionList_GetButtonCaption pro_Form1_OptionList2 (dcl_OptionList_GetCurSel pro_Form1_OptionList2))
bf_Value(dcl_OptionList_GetButtonCaption pro_Form1_OptionList3 (dcl_OptionList_GetCurSel pro_Form1_OptionList3)))
(if (or (not(isint t_NewValue)) (equal t_NewValue "w"))
    (progn (alert "顶层请输入整数或W") (exit)))
(if (not(isint f_NewValue))
    (progn (alert "层数请输入整数")(exit)))
(if Value
    (if (getxdata ss "obname")
    (changexdata ss "obname" Value)
    (putxdata ss "obname" Value)))
(if f_NewValue
    (if (getxdata ss "floorno")
    (changexdata ss "floorno" f_NewValue)
    (putxdata ss "floorno" f_NewValue)))
(if t_NewValue
    (if (getxdata ss "topfloor")
      (changexdata ss "topfloor" t_NewValue)
      (putxdata ss "topfloor" t_NewValue)))
(if bn_NewValue
    (if (getxdata ss "buildno")
    (changexdata ss "buildno" bn_NewValue)
    (putxdata ss "buildno" bn_NewValue)))
(if ac_Value
    (if (getxdata ss "areacal")
    (changexdata ss "areacal" ac_Value)
    (putxdata ss "areacal" ac_Value)))
(if ar_Value
    (if (getxdata ss "arearatio")
    (changexdata ss "arearatio" ar_Value)
    (putxdata ss "arearatio" ar_Value)))
(if bf_Value
    (if (getxdata ss "buildfunction")
    (changexdata ss "buildfunction" bf_Value)
    (putxdata ss "buildfunction" bf_Value)))
(dcl_Control_SetEnabled pro_Form1_TextButton2 T)
)

lameduck 发表于 2015-6-25 17:06:59

引发事件设置成1,哎!
页: [1]
查看完整版本: 求助,用opendcl做扩展属性对话框的问题