输入对话框.lsp
;;我写了<钢板重量计算器>http://bbs.mjtd.com/thread-107027-1-1.html,为了显示重量,便于拷贝,写了;;一个对话框,newer版主曰,用OpenDcl,可惜我不会。用下面的代码也倒是一个简单办法
;;示例(HH:InputBox "5.3")
(defun HH:InputBox (weight / STR)
(setq str (VL-PRIN1-TO-STRING weight))
(setq str (strcat "dim ret \n ret=InputBox(\"显示重量,便于拷贝\",\"重量显示\"," str ") "))
(or *wscript*
(setq *wscript* (vlax-create-object "ScriptControl"))
)
(vlax-put *wscript* 'language "vbs")
(vlax-invoke-method *wscript* 'ExecuteStatement str)
(vlax-invoke-method *wscript* 'eval "ret")
) 阿然 发表于 2013-10-10 11:02
黄兄这些天卖力为大家写了这么多好函数,我也来凑个热闹
感谢分享 阿然 发表于 2013-10-10 11:02
黄兄这些天卖力为大家写了这么多好函数,我也来凑个热闹
感谢分享 感谢分享 本帖最后由 阿然 于 2013-10-10 11:05 编辑
黄兄这些天卖力为大家写了这么多好函数,我也来凑个热闹
;;;调用vb输入框 by Xran
;;;promptstr 提示信息
;;;title 窗体标题栏信息
;;;default 缺省值
(defun inputbox (promptstr title default)
(vla-eval (vlax-get-acad-object)
(strcat "ThisDrawing.setVariable \"USERS5\",inputBox (\""
promptstr
"\", \""
title
"\", \""
default
"\")"
)
)
(getvar "users5")
)
阿然 发表于 2013-10-10 11:02 static/image/common/back.gif
黄兄这些天卖力为大家写了这么多好函数,我也来凑个热闹
你这个还真不错 谢谢黄兄,同理还有消息对话框
;;;调用vb里的msgbox by Xran
;;;参数均为字符串
;;;buttons取值
;;;vbAbortRetryIgnore
;;;vbApplicationModal
;;;vbCritical
;;;vbDefaultButton1
;;;vbDefaultButton2
;;;vbDefaultButton3
;;;vbDefaultButton4
;;;vbExclamation
;;;vbInformation
;;;vbMsgBoxHelpButton
;;;vbMsgBoxRight
;;;vbMsgBoxRtlReading
;;;vbMsgBoxSetForeground
;;;vbOKCancel
;;;vbOKOnly
;;;vbQuestion
;;;vbRetryCancel
;;;vbSystemModal
;;;vbYesNo
;;;vbYesNoCancel
;;;可以使用类似vbokcancel+vbinformation的字符串作为buttons的值
(defun msgbox (promptstr buttons title)
(vla-eval (vlax-get-acad-object)
(strcat "ThisDrawing.setVariable \"USERI5\",MsgBox (\""
promptstr
"\", "
buttons
", \""
title
"\")"
)
)
(getvar "useri5")
)
同高手们学习,日有所长。。。
历史的荣誉榜有你们的伟名。 好像明总也写过 4楼程序运行出错
错误: Automation 错误。 本帖最后由 自贡黄明儒 于 2013-10-11 10:09 编辑
crtrccrt 发表于 2013-10-11 09:04 http://bbs.mjtd.com/static/image/common/back.gif
4楼程序运行出错
错误: Automation 错误。
应该没错,你要注册"MSComDlg.CommonDialog"才能用
(vl-registry-write
"HKEY_CLASSES_ROOT\\LICENSES\\4d553650-6abe-11cf-8adb-00aa00c00905"
""
"gfjmrfkfifkmkfffrlmmgmhmnlulkmfmqkqj"
) 注册了
还是运行错误 简单的事情简单弄(princ “重量”) 就可以在cad命令栏拷贝 了
页:
[1]
2