自贡黄明儒 发表于 2013-10-10 10:20:45

输入对话框.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")
)

urings 发表于 2018-8-27 23:23:33

阿然 发表于 2013-10-10 11:02
黄兄这些天卖力为大家写了这么多好函数,我也来凑个热闹

感谢分享         

urings 发表于 2018-8-27 23:22:52

阿然 发表于 2013-10-10 11:02
黄兄这些天卖力为大家写了这么多好函数,我也来凑个热闹

感谢分享         

urings 发表于 2018-8-27 23:21:49

感谢分享      

阿然 发表于 2013-10-10 11:02:51

本帖最后由 阿然 于 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:09:42

阿然 发表于 2013-10-10 11:02 static/image/common/back.gif
黄兄这些天卖力为大家写了这么多好函数,我也来凑个热闹

你这个还真不错

阿然 发表于 2013-10-10 11:25:05

谢谢黄兄,同理还有消息对话框
;;;调用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")
)

soly2006 发表于 2013-10-10 13:43:30

同高手们学习,日有所长。。。
历史的荣誉榜有你们的伟名。

emk 发表于 2013-10-10 14:11:42

好像明总也写过

crtrccrt 发表于 2013-10-11 09:04:50

4楼程序运行出错

错误: Automation 错误。

自贡黄明儒 发表于 2013-10-11 10:08:11

本帖最后由 自贡黄明儒 于 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"
)

crtrccrt 发表于 2013-10-11 14:14:53

注册了
还是运行错误

浮世小半生 发表于 2013-10-13 10:53:10

简单的事情简单弄(princ “重量”) 就可以在cad命令栏拷贝 了
页: [1] 2
查看完整版本: 输入对话框.lsp