尝试使用COND
您好,我正在为我们办公室的服务编写程序。我已经编写了一个DCL文件,其中包含单选按钮和四个选项,这很好。现在,我想根据选择的4个单选按钮中的哪一个加载lisp。这就是我所拥有的,但我真的很感谢你的帮助。我尝试使用COND,但不确定是否正确调用了以下例程。当我运行lisp时,我没有得到函数定义:T。ESS1500、ESS1350、ESS1200、ESS1050是我要调用的函数。
(defun C:samp4();定义函数
(vl load com)
(setq dcl\U id(加载对话框“samp3.dcl”);“加载”对话框
(setq T TB2)?????不确定我是否需要这个
(如果(不是)(新建对话框“samp3”dcl\U id);对话框测试
);不
(退出);如果没有对话框,则退出
);如果
(action_tile“T1”“(setq hole“TB1”)*存储孔类型
(action_tile“T2”“(setq hole“TB2”)*存储孔类型
(action_tile“T3”“(setq hole“TB3”)*存储孔类型
(action_tile“T4”“(设置孔“TB4”)*存储孔类型
(action_tile)
“取消”;如果按下取消按钮
“(done_对话框)(setq userclick nil)”;关闭对话框,设置标志
);action\u互动程序
(action_tile)
“接受”;如果按下“OK”
“(done_dialog)(setq userclick T))”;???这是标准代码。
(条件(=(T“TB1”)ESS1500)
(=(T“TB2”)ESS1350)
(=(T“TB3”)ESS1200)
(=(T“TB4”)ESS1050)
('t)
(princ“\n未更改任何内容。”)
) ;_ 可选else条件结束
) ;_ 条件结束语句
);动作互动程序
(start_对话框);开始对话框
(unload\u对话框dcl\u id);卸载
(普林斯)
);定义C:samp
(普林斯) 伙计,如果你能提供dcl文件,这将使你更容易了解你在做什么,
我想你用的是单选按钮
问候flower 如果我犯了什么错误,请原谅,我是个盲人,
但是
(cond (=(T "TB1")ESS1500)
(=(T "TB2")ESS1350)
(=(T "TB3")ESS1200)
(=(T "TB4")ESS1050)
('t
(princ "\nNothing changed.")
) ;_ end of optional else condition
)
应该是
(cond (=(hole "TB1")ESS1500)
(=(hole "TB2")ESS1350)
(=(hole "TB3")ESS1200)
(=(hole "TB4")ESS1050)
('t
(princ "\nNothing changed.")
) ;_ end of optional else condition
) 嗨,弗劳尔,
这是DCL:
samp3:对话框{//对话框名称
label=“结构孔”//给它贴个标签
:boxed\u radio\u列{//*define radio列
label=“选择类型”//*给它贴个标签
:单选按钮{//*定义单选按钮
键=“T1”//*给它起个名字
label=“类型1”//*给它贴个标签
值=“1”//*打开它
}//*结束定义
:单选按钮{//*定义单选按钮
键=“T2”//*给它起个名字
label=“类型2”//*给它贴个标签
}//*结束定义
:单选按钮{//*定义单选按钮
键=“T3”//*给它起个名字
标签=“类型3”//*给它贴个标签
}//*结束定义
:单选按钮{//*定义单选按钮
键=“T4”//*给它起个名字
label=“类型4”//*给它贴上标签
}//*结束定义
}//*结束单选列
ok\u取消//预定义确定/取消
:行{//定义行
:段落{//定义段落
:text\u部分{//定义文本
label=“由BD设计”//给它一些文字
}//结束文本
:text\u部分{//定义更多文本
label=“用于CCC NNRDO”//更多文字
}//结束文本
}//结束段落
}//结束行
}//结束对话框 伙计,看了一眼,没跑,普林斯派尔应该没事
真的没有太多变化,如果你想让我解释为什么我改变了事情,我很乐意解释
只有一个音符
张贴代码时,请将#键和所有格式****放在回复框顶部的代码标签中。
它只是保持了格式和容易的眼睛
(defun C:samp4 () ;define function
(vl-load-com)
(setq dcl_id (load_dialog "samp3.dcl")) ;load dialog
; (setq T TB2); ?????Not sure if i need this
;not sure what you want from this, but i belive its not needed, but i do not know your varibles
(if (not (new_dialog "samp3" dcl_id) ;test for dialog
);not
(progn
(alert "Can not find you dcl file")
(exit) ;exit if no dialog
)
);if
(action_tile "T1" "(setq hole \"TB1\")") ;*store hole type
(action_tile "T2" "(setq hole \"TB2\")") ;*store hole type
(action_tile "T3" "(setq hole \"TB3\")") ;*store hole type
(action_tile "T4" "(setq hole \"TB4\")") ;*store hole type
(action_tile
"cancel" ;if cancel button pressed
"(done_dialog) (setq userclick nil)" ;close dialog, set flag
);action_tile
(action_tile
"accept" ;if O.K. pressed
"(done_dialog)(setq userclick T))" ;??? Is this standard code.
);action tile
(start_dialog) ;start dialog
(unload_dialog dcl_id) ;unload
(if userclick
(cond
(=(hole "TB1")ESS1500)
(=(hole "TB2")ESS1350)
(=(hole "TB3")ESS1200)
(=(hole "TB4")ESS1050)
(t (princ "\nNothing changed.")
) ;_ end of optional else condition
) ;_ end of cond statement
)
(princ)
);defun C:samp
(princ "\nThis loaded fine")
(princ)
和dcl,它是不变的
samp3 : dialog { //dialog name
label = "Structural Holes" ; //give it a label
:boxed_radio_column { //*define radio column
label = "Choose a Type" ; //*give it a label
: radio_button { //*define radion button
key = "T1" ; //*give it a name
label = "Type &1" ; //*give it a label
value = "1" ; //*switch it on
} //*end definition
: radio_button { //*define radio button
key = "T2" ; //*give it a name
label = "Type &2" ; //*give it a label
} //*end definition
: radio_button { //*define radio button
key = "T3" ; //*give it a name
label = "Type &3" ; //*give it a label
} //*end definition
: radio_button { //*define radio button
key = "T4" ; //*give it a name
label = "Type &4" ; //*give it a label
} //*end definition
} //*end radio column
ok_cancel ; //predifined OK/Cancel
: row { //define row
: paragraph { //define paragraph
: text_part { //define text
label = "Designed by BD"; //give it some text
} //end text
: text_part { //define more text
label = "for CCC NNRDO"; //some more text
} //end text
} //end paragraph
} //end row
} //end dialog
对不起,由于某种原因,我的粘贴格式相当****。 谢谢你的花,
它已经消除了错误,但仍然没有运行任何ESS例程。我有他们在同一个。lsp文件。我需要用不同的方式给他们打电话吗。
我从命令行运行了一个ESS例程,它运行得很好。
如果有任何想法,我将不胜感激。。 是否将它们设置为同一文件中的函数?
如果是这样,您可以这样做:
(cond (=(hole "TB1") (C:ESS1500))
(=(hole "TB2") (C:ESS1350))
(=(hole "TB3") (C:ESS1200))
(=(hole "TB4") (C:ESS1050))
('t
(princ "\nNothing changed.")
) ;_ end of optional else condition
)
既然您说过可以从命令行运行例程,那么您也可以简单地执行以下操作:
(cond (=(hole "TB1") (command "ESS1500"))
(=(hole "TB2") (command "ESS1350")
(=(hole "TB3") (command "ESS1200"))
(=(hole "TB4") (command "ESS1050"))
('t
(princ "\nNothing changed.")
) ;_ end of optional else condition
)
对不起,伙计,我昨晚错过了
(cond
(=(hole "TB1")(ESS1500))
(=(hole "TB2")(ESS1350))
(=(hole "TB3")(ESS1200))
(=(hole "TB4")(ESS1050))
(t (princ "\nNothing changed.")) ;_ end of optional else condition
)
以及
你总是从命令行调用routenes吗?
或者只是为了测试。就像我骑“c”部分一样。
那么上述方法应该有效
(defun ESS1350 ()
"the code here"
)
或者按照PHPGator做 谢谢大家,刚刚到办公室,尝试了你的解决方案,但没有乐趣。我犯了一个错误;错误:功能不好:“TB3”取决于我选择的单选按钮。任何想法,这是完整的代码。再次感谢。
(defun C:samp4 () ;define function
(vl-load-com)
(setq dcl_id (load_dialog "samp3.dcl")) ;load dialog
;not sure what you want from this, but i belive its not needed, but i do not know your varibles
(if (not (new_dialog "samp3" dcl_id) ;test for dialog
);not
(progn
(alert "Can not find you dcl file")
(exit) ;exit if no dialog
)
);if
(action_tile "T1" "(setq hole \"TB1\")") ;*store hole type
(action_tile "T2" "(setq hole \"TB2\")") ;*store hole type
(action_tile "T3" "(setq hole \"TB3\")") ;*store hole type
(action_tile "T4" "(setq hole \"TB4\")") ;*store hole type
(action_tile
"cancel" ;if cancel button pressed
"(done_dialog) (setq userclick nil)" ;close dialog, set flag
);action_tile
(action_tile
"accept" ;if O.K. pressed
"(done_dialog)(setq userclick T))" ;??? Is this standard code.
);action tile
(start_dialog) ;start dialog
(unload_dialog dcl_id) ;unload
(if userclick
(cond
(=(hole "TB1")(command "ESS1500"))
(=(hole "TB2")(command "ESS1350"))
(=(hole "TB3")(command "ESS1200"))
(=(hole "TB4")(command "ESS1050"))
(t (princ "\nNothing changed.")
) ;_ end of optional else condition
) ;_ end of cond statement
)
(princ)
);defun C:samp
(princ "\nThis loaded fine")
(princ)
(defun c:ESS1500()
(setq a "CCC_DR_1500")
(if (= (tblsearch "ltype" a) nil)
(command "-linetype" "l" a "acadiso.lin" "")
(princ))
(graphscr)
(command "._-layer" "N" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1500" "M" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1500" "L"
"CCC_DR_1500""CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1500" "C" "84" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1500" "LW"
"0.3" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1500" "" )
(command "pline" pause "width" "0.0" "0.0" pause "width" "0.0" "0.0")
(setvar "cmdecho" 1)
(princ)
)
;;;;;;;;;;Existing Storm_Sewer 1500mm;;;;;;;;;; End
;;;;;;;;;;Existing Storm_Sewer 1350mm;;;;;;;;;; Start
(defun c:ESS1350()
(setq a "CCC_DR_1350")
(if (= (tblsearch "ltype" a) nil)
(command "-linetype" "l" a "acadiso.lin" "")
(princ))
(graphscr)
(command "._-layer" "N" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1350" "M" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1350" "L"
"CCC_DR_1350""CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1350" "C" "84" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1350" "LW"
"0.3" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1350" "" )
(command "pline" pause "width" "0.0" "0.0" pause "width" "0.0" "0.0")
(setvar "cmdecho" 1)
(princ)
)
;;;;;;;;;;Existing Storm_Sewer 1350mm;;;;;;;;;; End
;;;;;;;;;;Existing Storm_Sewer 1200mm;;;;;;;;;; Start
(defun c:ESS1200()
(setq a "CCC_DR_1200")
(if (= (tblsearch "ltype" a) nil)
(command "-linetype" "l" a "acadiso.lin" "")
(princ))
(graphscr)
(command "._-layer" "N" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1200" "M" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1200" "L"
"CCC_DR_1200""CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1200" "C" "84" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1200" "LW"
"0.3" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1200" "" )
(command "pline" pause "width" "0.0" "0.0")
(setvar "cmdecho" 1)
(princ)
)
;;;;;;;;;;Existing Storm_Sewer 1200mm;;;;;;;;;; End
;;;;;;;;;;Existing Storm_Sewer 1050mm;;;;;;;;;; Start
(defun c:ESS1050()
(setq a "CCC_DR_1050")
(if (= (tblsearch "ltype" a) nil)
(command "-linetype" "l" a "acadiso.lin" "")
(princ))
(graphscr)
(command "._-layer" "N" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1050" "M" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1050" "L"
"CCC_DR_1050""CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1050" "C" "84" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1050" "LW"
"0.3" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1050" "" )
(command "pline" pause "width" "0.0" "0.0")
(setvar "cmdecho" 1)
(princ)
)
;;;;;;;;;;Existing Storm_Sewer 1050mm;;;;;;;;;; End
对不起,伙计,没接电话,喝醉了或挂了电话
尝试使用
(cond
(= hole "TB1")(command "ESS1500"))
(= hole "TB2")(command "ESS1350"))
(= hole "TB3")(command "ESS1200"))
(= hole "TB4")(command "ESS1050"))
(t (princ "\nNothing changed.")
) ;_ end of optional else condition
)
请注意,如果你不选择任何东西,它将不会返回任何更改。
但是,单选按钮的缺点是启用一个选项,或者使用切换按钮,并将额外选项设置为“none”或其他选项,或者不使用该选项
页:
[1]
2