明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 12767|回复: 30

[【不死猫】] OpenDCL、打印设定、文件上传、oracle数据库、sql数据库、程序自动更新、MD5加密等

    [复制链接]
发表于 2014-6-13 13:04:16 | 显示全部楼层 |阅读模式
本帖最后由 不死猫 于 2014-6-13 18:01 编辑

因为服务器配置各不相同,因此代码在未配置好服务器的情况下不能运行完整。
代码供大家参考,每段函数都可以自己修改使用。
程序主要功能是实现用户登录后提取图纸信息加条码打印上传并写信息进数据库。
比较有特点的功能包括:程序自动更新,oracle数据库的读取、Sql数据库返回影响的行、文件自动上传和验证、MD5加密的借用方法等。
对话框放二楼了。

sygplot.lsp
  1. (vl-bb-set 'projectname "882+2117114+XM-211-33+西丽工程")
  2. (vl-bb-set 'sgyname "cat");使用黑板主要是为了多图纸切换时保持登录状态

  3. ;不死猫老师空间http://nonsmall.mjtd.com
  4. ;Lisp教程http://vlisp.taobao.com/
  5. (vl-load-com)

  6. (setq *Path "C:\\sgyplot\\打印\")
  7. (setq *IP "192.168.0.11")
  8. (setq *SQLIP "192.168.0.1")
  9. (setq objShell (vlax-create-object "wscript.shell"))
  10. (repeat 3
  11.   (vlax-invoke objShell "run" (strcat "cmd.exe /c net use \\\" *IP "\\ipc$ /user:administrator password") 0)
  12. )
  13. (setq fso (vlax-create-object "Scripting.FileSystemObject"))
  14. (setq file "c:\\sgyplot\\sgyplot.fas")
  15. ;程序自动更新 程序已经加入启动组的情况下
  16. (if (findfile file)
  17.   (progn
  18.     (setq file (Vlax-Invoke-Method fso 'GetFile file))
  19.     (setq myfilesize (Vlax-Get file 'Size ))
  20.     (setq myfileDateLastModified (Vlax-Get file 'DateLastModified ))
  21.     (setq myfileAttributes (Vlax-Get file 'Attributes ))
  22.     (setq newfile (Vlax-Invoke-Method fso 'GetFile (strcat "\\\" *IP "\\cad打印系统\\程序\\sgyplot\\sgyplot.fas")))
  23.     (if (not (and newfile
  24.         (equal (Vlax-Get newfile 'Size ) myfilesize)
  25.         (equal (Vlax-Get newfile 'DateLastModified ) myfileDateLastModified)
  26.         (equal (Vlax-Get newfile 'Attributes ) myfileAttributes)
  27.       ))
  28.       (progn
  29.         (alert "发现不死猫打印程序新版本,点击确认更新!")
  30.         (vlax-invoke-method newfile 'copy "c:\\sgyplot\" :vlax-true)
  31.         (alert "更新完成,请重新打开CAD完成升级.")
  32.       )
  33.     )
  34.   )
  35.   (progn
  36.     (vl-mkdir "c:\\sgyplot\")
  37.     (setq newfile (Vlax-Invoke-Method fso 'GetFile (strcat "\\\" *IP "\\cad打印系统\\程序\\sgyplot\\sgyplot.fas")))
  38.     (vlax-invoke-method newfile 'copy "c:\\sgyplot\" :vlax-true)
  39.     (alert "更新完成,请重新打开CAD完成升级.")
  40.   )
  41. )
  42. (defun c:sgyplot()
  43.   (vl-load-com)
  44. ;  (setq *IP "192.168..14")
  45.   (setq *Folder "\\新建文件夹\\打印系统上传\")
  46.   (setq *folder_tukuang "\\新建文件夹\\标准图框\")
  47. ;  (load (strcat *path "1 用户登录.lsp"))
  48. ;  (load (strcat *path "2 图纸设定及打印.lsp"))
  49. ;  (load (strcat *path "3 图纸上传.lsp"))
  50. ;  (load (strcat *path "4 图框处理.lsp"))
  51. ;  (load (strcat *path "5 生成条形码.lsp"))
  52.   (setq *sgy-recordFile "c:\\sgyPlot\\sgyplot.txt")
  53.   (command "opendcl")
  54. ;  (setq Dcl '())
  55. ;  (dcl_project_import Dcl nil nil)
  56.   (dcl_project_load (strcat *path "sgyPlot.odcl") T)
  57.   (dcl_form_show sgyPlot_sgyPlot)
  58.   (dcl_Control_SetEnabled sgyPlot_sgyPlot_CheckBox1 nil)
  59.   (dcl_Control_SetEnabled sgyPlot_sgyPlot_CheckBox2 nil)
  60.   (dcl_Control_SetEnabled sgyPlot_sgyPlot_CheckBox3 nil)
  61.   (dcl_Control_SetEnabled sgyPlot_sgyPlot_TextButton1 nil)
  62.   (dcl_Control_SetBackColor sgyPlot_sgyPlot_Label8 2)
  63.   (if (vl-bb-ref 'sgyname)
  64.     (progn
  65.       (dcl_TabStrip_SetCurSel sgyPlot_sgyPlot_TabStrip1 1)
  66.       (dcl_Control_SetEnabled sgyPlot_sgyPlot_TextButton1 T)
  67.       (dcl_Control_SetCaption sgyPlot_sgyPlot_Label8 (vl-bb-ref 'sgyname))
  68.       (dcl_Control_SetBackColor sgyPlot_sgyPlot_Label8 7)
  69.     )
  70.     (progn
  71.       (dcl_TabStrip_SetCurSel sgyPlot_sgyPlot_TabStrip1 )
  72.     )
  73.   )
  74.   ;设置下拉菜单宽度
  75.   (dcl_ComboBox_SetDroppedWidth sgyPlot_sgyPlot_ComboBox4 6)
  76.   (dcl_ComboBox_AddList sgyPlot_sgyPlot_ComboBox5 '("建筑" "电气" "金结" "景观" "结构" ))
  77.   (dcl_ComboBox_AddList sgyPlot_sgyPlot_ComboBox6 '("建议书" "方案" "可研" "初设" "施工图" "竣工图"))
  78. ;  初始化
  79.   (if (not (findfile *sgy-recordFile))
  80.     (progn
  81.       (vl-mkdir "c:\\sgyLisp")
  82.       (setq f (open *sgy-recordFile "a"))
  83.       (write-line "," f)
  84.       (write-line "," f)
  85.       (write-line "1" f)
  86.       (write-line "1" f)
  87.       (write-line "1" f)
  88.       (write-line "1" f)
  89.       (write-line "1" f)
  90.       (write-line "1" f)
  91.       (write-line "" f);项目名称
  92.       (write-line "1" f);项目阶段
  93.       (write-line "1" f);图纸专业
  94.       (close f)
  95.       (read-record)
  96.     )
  97.     (progn
  98.       (read-record)
  99.     )
  100.   )
  101. ;  初始化完成
  102. )
  103. (defun non_string_to_list(str del / lst)
  104.   (while (/= str (setq str (vl-string-subst "@" del str))))
  105.   (while (setq del (vl-string-position (ascii "@") str))
  106.       (setq del (substr str 1 del))
  107.       (setq str (vl-string-left-trim (strcat del) str))
  108.       (setq lst (append lst (list del)))
  109.       (setq str (substr str 2 (strlen str)))
  110.   )
  111.   (append lst (list str))
  112. )
  113. (defun vlax-2d-point (pt)
  114.   (vlax-make-variant(vlax-safearray-fill (vlax-make-safearray vlax-vbDouble '( . 1)) (list (car pt)(cadr pt))))
  115. )
  116. ;用户登录使用MD5加密验证
  117. (defun c:sgyPlot_sgyPlot_GraphicButton3_OnClicked (/)
  118.   (setq shell (vlax-create-object "Wscript.Shell"))
  119.   (vlax-invoke shell "Run" (strcat "cmd /c wscript.exe C:\\sgyPlot\\MD5.vbs " (dcl_Control_GetText sgyPlot_sgyPlot_TextBox4)) 0)
  120.   (setq getlogin (login (dcl_Control_GetText sgyPlot_sgyPlot_TextBox3)))
  121.   (setq password (car getlogin))
  122.   (setq name (cadr getlogin))
  123.   (setq objShell (vlax-create-object "wscript.shell"))
  124.   (vlax-invoke objShell "run" (strcat "cmd.exe /c net use \\\" *IP "\\ipc$ /user:administrator password") 0)
  125. ;  (command "delay" "1000")
  126.   ;(vlax-invoke shell "Popup" "123" 1 "aa" )
  127.   (setq file (open "C:\\sgyPlot\\MD5.txt" "r"))
  128.   (setq md5 (read-line file))
  129.   (close file)
  130.   (if password
  131.     (if (equal password md5)
  132.       (progn
  133.         (dcl_Control_SetEnabled sgyPlot_sgyPlot_TextButton1 T)
  134.         (dcl_Control_SetCaption sgyPlot_sgyPlot_Label8 name)
  135.         (dcl_Control_SetBackColor sgyPlot_sgyPlot_Label8 7)
  136.         (vl-bb-set 'sgyname name)
  137.         (dcl_TabStrip_SetCurSel sgyPlot_sgyPlot_TabStrip1 1)
  138.         (alert "登录成功!")
  139.       )
  140.       (alert "密码错误!")
  141.     )
  142.     (alert "用户名不存在")
  143.   )
  144. )
  145. ;oracle数据库读取
  146. (defun login(name / con record fields field return)
  147.   (Setq con (Vlax-Get-Or-Create-Object "adodb.connection" ))
  148.   (Vlax-Invoke con 'Open "Provider=MSDAORA.1;Data Source=192.168.0.8/test;User ID=project;password=project;Persist Security Info=False")
  149.   (Setq Record (Vlax-Get-Or-Create-Object "adodb.Recordset" ))
  150. ;  (Vlax-Invoke Record 'Open (strcat "select password from test.view_users_2 where username = 'huq'") con 1 3)
  151.   (Vlax-Invoke Record 'Open (strcat "select name,password from test.view_users_2 where username = '" name "'") con 1 3)
  152.   (if (/= (Vlax-Get Record 'EOF ) -1)
  153.     (progn
  154.       (Vlax-Invoke-Method Record 'MoveFirst )
  155.       (setq fields (vlax-get-property record  'Fields))
  156.       (setq field (Vlax-Invoke fields 'Item "password" ))
  157.       (setq password (Vlax-Get field 'Value ))
  158.       (setq name (Vlax-Invoke fields 'Item "name" ))
  159.       (setq name (Vlax-Get name 'Value ))
  160.     )
  161.   )
  162.   (Vlax-Invoke-Method Record 'Close )
  163.   (Vlax-Invoke-Method con 'Close )
  164.   (vlax-release-object Record)
  165.   (vlax-release-object con)
  166.   (list password name)
  167. )
  168. ;defun 开始打印
  169. ;条码程序请参见Gu版的帖子
  170. (defun c:sgyPlot_sgyPlot_TextButton1_OnClicked (/)
  171.   (if (or
  172.       (= (dcl_Control_GetText sgyPlot_sgyPlot_TextBox1) "")
  173.       (= (dcl_Control_GetText sgyPlot_sgyPlot_TextBox2) "")
  174.       (= (dcl_ComboBox_GetEBText sgyPlot_sgyPlot_ComboBox1) "")
  175.       (= (dcl_ComboBox_GetEBText sgyPlot_sgyPlot_ComboBox2) "")
  176.       (= (dcl_ComboBox_GetEBText sgyPlot_sgyPlot_ComboBox3) "")
  177.     )
  178.     (alert "信息填写不完整,无法打印")
  179.     (progn
  180. ;      (func-uploadpaper)
  181.       (if (func-uploadpaper)
  182.         (progn
  183.           (sgy-write-record)
  184.     ;      (command "qsave")
  185.           ;获取图纸两个点minPt maxPt
  186.           (if (< (car (mapcar 'read (non_string_to_list (dcl_Control_GetText sgyPlot_sgyPlot_TextBox1) ",")))(car (mapcar 'read (non_string_to_list (dcl_Control_GetText sgyPlot_sgyPlot_TextBox2) ","))))
  187.             (setq minPt (mapcar 'read (non_string_to_list (dcl_Control_GetText sgyPlot_sgyPlot_TextBox1) ",")) maxPt (mapcar 'read (non_string_to_list (dcl_Control_GetText sgyPlot_sgyPlot_TextBox2) ",")))
  188.     ;        否则交换两点
  189.             (setq minPt (mapcar 'read (non_string_to_list (dcl_Control_GetText sgyPlot_sgyPlot_TextBox2) ",")) maxPt (mapcar 'read (non_string_to_list (dcl_Control_GetText sgyPlot_sgyPlot_TextBox1) ",")))
  190.           )
  191.           (setq *id (sgySQLinsert))
  192.           (setq id (substr (setq id (strcat "000" *id)) (- (strlen id) 1)))
  193.           (setvar "cmdecho" 0)
  194.           (setq tiaomaLen (- (car maxpt)(car minpt)))
  195.           (setq scale (/ tiaomaLen 370.29))
  196.           (setq code (substr (vl-string-subst "" "." (rtos (getvar "cdate") 2 7) )3 10))
  197.           (setq code (strcat code id))
  198.           (setq ss (sgy-tiaoma minPt scale code))
  199.           (sgySQLinsertTiaoMa *id *Tiaomacode)
  200.           (print *Tiaomacode)
  201.           (command "scale" ss "" "non" minPt scale)
  202.           (command "rotate" ss "" "non" minpt "90")
  203.           (command "move" ss "" "non" minpt "non" (polar (polar minpt 0 (* tiaomaLen 0.025)) 1.5708 (* tiaomaLen 0.02)))
  204.           ;放置条码
  205.           (print "放置条码")
  206.           (vl-catch-all-apply  'c:sgyPlot_sgyPlot_TextButton2_OnClicked)
  207.           (Vlax-Invoke-Method (Vlax-Get (Vlax-Get (Vlax-Get-Acad-Object) 'ActiveDocument) 'Plot) 'PlotToDevice )
  208.           (command "erase" ss "")
  209. ;          开始打印
  210.           (setvar "cmdecho" 1)
  211.           (princ "\n已发送到打印机开始打印!")
  212.         )
  213.       )
  214.     )
  215.   )
  216.   (princ)
  217. )


  218. ;defun 搜索项目名称
  219. (defun c:sgyPlot_sgyPlot_GraphicButton5_OnClicked (/)
  220.   (setq name (dcl_Control_GetText sgyPlot_sgyPlot_TextBox5))
  221.   (if (= name "")
  222.     (progn
  223.       (dcl_Control_SetToolTipMainText sgyPlot_sgyPlot_TextBox5 "请输入项目名称然后点击搜索!")
  224.       (dcl_Control_ShowToolTip sgyPlot_sgyPlot_TextBox5)
  225.     )
  226.     (progn
  227.       (repeat 10 (setq name (vl-string-subst "%" " " name)))
  228.       (repeat 10 (setq name (vl-string-subst "%" " " name)))
  229.       (setq *projectList (getProjectName name))  (if *projectList
  230.         (progn
  231.           (setq projectNameList (mapcar '(lambda (x) (cadddr (non_string_to_list x "+"))) *projectList))
  232.           (dcl_ComboBox_Clear sgyPlot_sgyPlot_ComboBox4)
  233.           (dcl_ComboBox_AddList sgyPlot_sgyPlot_ComboBox4 projectNameList)
  234.           (dcl_Control_SetToolTipMainText sgyPlot_sgyPlot_ComboBox4 (strcat "\n找到" (itoa (length projectNameList)) "个项目\n"))
  235.           (dcl_ComboBox_SetCurSel sgyPlot_sgyPlot_ComboBox4 0)
  236.           (dcl_Control_ShowToolTip sgyPlot_sgyPlot_ComboBox4)
  237.         )
  238.         (progn
  239.           (dcl_Control_SetToolTipMainText sgyPlot_sgyPlot_ComboBox4 (strcat "\n找到" (itoa (length re)) "个项目\n"))
  240.           (dcl_ComboBox_Clear sgyPlot_sgyPlot_ComboBox4)
  241.           (dcl_Control_ShowToolTip sgyPlot_sgyPlot_ComboBox4)
  242.         )
  243.       )
  244.     )
  245.   )
  246. )
  247. ;defun 打印预览
  248. (defun c:sgyPlot_sgyPlot_TextButton3_OnClicked (/)
  249.   (Vlax-Invoke-Method (Vlax-Get (Vlax-Get (Vlax-Get-Acad-Object) 'ActiveDocument) 'Plot) 'DisplayPlotPreview acFullPreview )
  250. )
  251. ;defun 两点选择
  252. (defun c:sgyPlot_sgyPlot_GraphicButton1_OnClicked (/)
  253. ;  (if (/= (getvar "CMDACTIVE") 0)
  254. ;    (command)
  255. ;  )
  256.   (setq *layout (Vlax-Get (Vlax-Get (Vlax-Get-Acad-Object) 'ActiveDocument) 'ActiveLayout))
  257.   (setq pt1 (getpoint "\n请选择打印第1点"))
  258.   (if pt1 (setq pt2 (getcorner pt1 "\n请选择打印第2点")))
  259.   (if (and pt1 pt2)
  260.     (progn
  261.       (setq pt1 (list (min (car pt1)(car pt2)) (min (cadr pt1)(cadr pt2))))
  262.       (setq pt2 (list (max (car pt1)(car pt2)) (max (cadr pt1)(cadr pt2))))
  263.       (dcl_Control_SetText sgyPlot_sgyPlot_TextBox1 (strcat (rtos (car pt1) 2 4) "," (rtos (cadr pt1) 2 4)))
  264.       (dcl_Control_SetText sgyPlot_sgyPlot_TextBox2 (strcat (rtos (car pt2) 2 4) "," (rtos (cadr pt2) 2 4)))
  265.       (setq *plotPtx pt1)
  266.       (setq *plotPty pt2)
  267. ;      打印两点
  268.       (Vlax-Invoke-method *layout 'SetWindowToPlot (vlax-2d-point pt1) (vlax-2d-point pt2))
  269.       (Vlax-Invoke-Method (Vlax-Get (Vlax-Get-Acad-Object) 'ActiveDocument) 'Regen acActiveViewport )
  270.     )
  271.   )
  272. )
  273. ;defun 选择矩形
  274. (defun c:sgyPlot_sgyPlot_GraphicButton2_OnClicked (/)
  275.   (setq *layout (Vlax-Get (Vlax-Get (Vlax-Get-Acad-Object) 'ActiveDocument) 'ActiveLayout))
  276.   (setq rec (entsel "\n请选择打印的矩形框"))
  277.   (if rec
  278.     (progn
  279.       (Vlax-Invoke-Method (Vlax-Ename->Vla-Object (car rec)) 'GetBoundingBox 'ptx 'pty)
  280.       (setq ptx (vlax-safearray->list ptx))
  281.       (setq pty (vlax-safearray->list pty))
  282.       (setq *plotPtx ptx)
  283.       (setq *plotPty pty)
  284.       (dcl_Control_SetText sgyPlot_sgyPlot_TextBox1 (strcat (rtos (car ptx) 2 4) "," (rtos (cadr ptx) 2 4)))
  285.       (dcl_Control_SetText sgyPlot_sgyPlot_TextBox2 (strcat (rtos (car pty) 2 4) "," (rtos (cadr pty) 2 4)))
  286. ;      打印两点
  287.       (Vlax-Invoke-method *layout 'SetWindowToPlot (vlax-2d-point ptx) (vlax-2d-point pty))
  288.       (Vlax-Invoke-Method (Vlax-Get (Vlax-Get-Acad-Object) 'ActiveDocument) 'Regen acActiveViewport )
  289.     )
  290.   )
  291. )
  292. ;defun 应用到布局
  293. (defun c:sgyPlot_sgyPlot_TextButton2_OnClicked (/)
  294.   (setq *layout (Vlax-Get (Vlax-Get (Vlax-Get-Acad-Object) 'ActiveDocument) 'ActiveLayout))
  295. ;  打印的两个点
  296.   (if (> (length *plotPtx) 2)
  297.     (setq *plotPtx (reverse (cdr (reverse *plotPtx))))
  298.   )
  299.   (if (> (length *plotPty) 2)
  300.     (setq *plotPty (reverse (cdr (reverse *plotPty))))
  301.   )
  302.   (Vlax-Invoke-method *layout 'SetWindowToPlot (vlax-2d-point *plotPtx) (vlax-2d-point *plotPty))
  303. ;  (Vlax-Invoke-Method (Vlax-Get (Vlax-Get (Vlax-Get-Acad-Object) 'ActiveDocument) 'ActiveLayout) 'GetCustomScale 1 1 )
  304.   (Vlax-Put-Property (Vlax-Get (Vlax-Get (Vlax-Get-Acad-Object) 'ActiveDocument) 'ActiveLayout) 'PlotType acWindow )
  305. ;  打印机
  306.   (Vlax-Put-Property *layout 'ConfigName (dcl_ComboBox_GetEBText sgyPlot_sgyPlot_ComboBox1))
  307. ;  图纸大小
  308.   (Vlax-Put-Property *layout 'CanonicalMediaName (dcl_ComboBox_GetEBText sgyPlot_sgyPlot_ComboBox2))
  309. ;  按样式打印
  310.   (Vlax-Put-Property *layout 'PlotWithPlotStyles -1 )
  311. ;  打印样式
  312.   (Vlax-Put-Property *layout 'StyleSheet (dcl_ComboBox_GetEBText sgyPlot_sgyPlot_ComboBox3))
  313.   ;偏移
  314. ;  (Vlax-Put-Property (Vlax-Get (Vlax-Get (Vlax-Get-Acad-Object) 'ActiveDocument) 'ActiveLayout) 'PlotOrigin (Vlax-2d-Point '(0 0)))
  315. ;  居中打印
  316.   (Vlax-Put-Property *layout 'CenterPlot (- 0 (dcl_Control_GetValue sgyPlot_sgyPlot_CheckBox1)))
  317. ;  厘米单位
  318.   (Vlax-Put-Property *layout 'PaperUnits acMillimeters )
  319. ;  是否纵向打印
  320.   (Vlax-Put *layout 'PlotRotation (dcl_Control_GetValue sgyPlot_sgyPlot_CheckBox3))
  321. ;  铺满图纸
  322.   (Vlax-Put-Property *layout 'UseStandardScale acScaleToFit )
  323.   (Vlax-Put-Property *layout 'UseStandardScale (- 0 (dcl_Control_GetValue sgyPlot_sgyPlot_CheckBox2)) )
  324.   (Vlax-Put-Property *layout 'StandardScale 0 )
  325.   (Vlax-Invoke-Method (Vlax-Get (Vlax-Get-Acad-Object) 'ActiveDocument) 'Regen acActiveViewport )
  326.   (Vlax-Invoke-method *layout 'SetWindowToPlot (vlax-2d-point (mapcar 'read (non_string_to_list (dcl_Control_GetText sgyPlot_sgyPlot_TextBox1) ","))) (vlax-2d-point (mapcar 'read (non_string_to_list (dcl_Control_GetText sgyPlot_sgyPlot_TextBox2) ","))))
  327.   (Vlax-Invoke-Method (Vlax-Get (Vlax-Get-Acad-Object) 'ActiveDocument) 'Regen acActiveViewport )
  328. )
  329. ;defun 居中打印
  330. (defun c:sgyPlot_sgyPlot_CheckBox1_OnClicked (Value /)
  331.   (vl-catch-all-apply  'c:sgyPlot_sgyPlot_TextButton2_OnClicked)
  332. )
  333. ;defun 铺满图纸
  334. (defun c:sgyPlot_sgyPlot_CheckBox2_OnClicked (Value /)
  335.   (vl-catch-all-apply  'c:sgyPlot_sgyPlot_TextButton2_OnClicked)
  336. )
  337. ;defun 横向打印
  338. (defun c:sgyPlot_sgyPlot_CheckBox3_OnClicked (Value /)
  339.   (vl-catch-all-apply  'c:sgyPlot_sgyPlot_TextButton2_OnClicked)
  340. )
  341. ;defun 记录打印配置
  342. (defun sgy-write-record()
  343.   (setq f (open *sgy-recordFile "w"))
  344.   (write-line (dcl_Control_GetText sgyPlot_sgyPlot_TextBox1) f)
  345.   (write-line (dcl_Control_GetText sgyPlot_sgyPlot_TextBox2) f)
  346.   (write-line (itoa (dcl_ComboBox_GetCurSel sgyPlot_sgyPlot_ComboBox1)) f)
  347.   (write-line (itoa (dcl_ComboBox_GetCurSel sgyPlot_sgyPlot_ComboBox2)) f)
  348.   (write-line (itoa (dcl_ComboBox_GetCurSel sgyPlot_sgyPlot_ComboBox3)) f)
  349.   (write-line (itoa (dcl_Control_GetValue sgyPlot_sgyPlot_CheckBox1)) f)
  350.   (write-line (itoa (dcl_Control_GetValue sgyPlot_sgyPlot_CheckBox2)) f)
  351.   (write-line (itoa (dcl_Control_GetValue sgyPlot_sgyPlot_CheckBox3)) f)
  352.   (write-line (dcl_Control_GetText sgyPlot_sgyPlot_TextBox5) f)
  353.   (write-line (itoa (dcl_ComboBox_GetCurSel sgyPlot_sgyPlot_ComboBox6)) f)
  354.   (write-line (itoa (dcl_ComboBox_GetCurSel sgyPlot_sgyPlot_ComboBox5)) f)
  355.   (close f)
  356. )
  357. ;defun 读取打印配置
  358. (defun read-record()
  359.   (setq f (open *sgy-recordFile "r"))
  360.   (dcl_Control_SetText sgyPlot_sgyPlot_TextBox1 (read-line f ))
  361.   (dcl_Control_SetText sgyPlot_sgyPlot_TextBox2 (read-line f ))
  362.   (dcl_ComboBox_SetCurSel sgyPlot_sgyPlot_ComboBox1 (read (read-line f )))
  363.   (dcl_ComboBox_Clear sgyPlot_sgyPlot_ComboBox2)
  364.   (dcl_ComboBox_SetCurSel sgyPlot_sgyPlot_ComboBox2 (read (read-line f )))
  365.   (dcl_ComboBox_SetCurSel sgyPlot_sgyPlot_ComboBox3 (read (read-line f )))
  366.   (dcl_Control_SetValue sgyPlot_sgyPlot_CheckBox1 (read (read-line f )))
  367.   (dcl_Control_SetValue sgyPlot_sgyPlot_CheckBox2 (read (read-line f )))
  368.   (dcl_Control_SetValue sgyPlot_sgyPlot_CheckBox3 (read (read-line f )))
  369.   (dcl_Control_SetText sgyPlot_sgyPlot_TextBox5 (read-line f ))
  370.   (dcl_ComboBox_SetCurSel sgyPlot_sgyPlot_ComboBox6 (read (read-line f )))
  371.   (dcl_ComboBox_SetCurSel sgyPlot_sgyPlot_ComboBox5 (read (read-line f )))
  372.   (close f)
  373. )
  374. ;defun 获取项目名称
  375. (defun getProjectName(name / con    return)
  376.   (Setq con (Vlax-Get-Or-Create-Object "adodb.connection" ))
  377.   (Vlax-Invoke con 'Open "Provider=MSDAORA.1;Data Source=192.168.0.8/test;User ID=project;password=project;Persist Security Info=False")
  378.   (Setq Record (Vlax-Get-Or-Create-Object "adodb.Recordset" ))
  379.   (Vlax-Invoke Record 'Open (strcat "select * from test.view_project where proname like '%" name "%'") con 1 3)
  380.   (if (= (Vlax-Get Record 'EOF ) 0)
  381.     (Vlax-Invoke-Method Record 'MoveFirst )
  382.   )
  383.   (while (= (Vlax-Get Record 'EOF ) 0)
  384.     (progn
  385.       (setq fields (vlax-get-property record  'Fields))
  386.       ;项目名称
  387.       (setq proname (Vlax-Invoke fields 'Item "proname" ))
  388.       (setq proname (Vlax-Get proname 'Value ))
  389.       ;业务编号
  390.       (setq probh (Vlax-Invoke fields 'Item "probh" ))
  391.       (setq probh (Vlax-Get probh 'Value ))
  392.       ;业务号
  393.       (setq busino (Vlax-Invoke fields 'Item "busino" ))
  394.       (setq busino (Vlax-Get busino 'Value ))
  395.       ;ID
  396.       (setq Id (Vlax-Invoke fields 'Item "id" ))
  397.       (setq Id (vlax-variant-value (vlax-variant-change-type (Vlax-Get-property Id 'Value ) vlax-vbString)))
  398.       (if proname (setq return (cons (strcat Id "+" busino "+" probh "+" proname) return)))
  399.       (Vlax-Invoke-Method Record 'MoveNext)
  400.     )
  401.   )
  402.   (Vlax-Invoke-Method Record 'Close )
  403.   (Vlax-Invoke-Method con 'Close )
  404.   (vlax-release-object Record)
  405.   (vlax-release-object con)
  406.   return
  407. )
  408. ;选择项目名称
  409. (defun c:sgyPlot_sgyPlot_ComboBox4_OnSelChanged (ItemIndexOrCount Value /)
  410.   (vl-bb-set 'projectname (nth ItemIndexOrCount *projectList))
  411. )
  412. (defun func-uploadpaper()
  413.   (if
  414.     (or ;临时代码
  415.       (not (vl-bb-ref 'projectname))
  416.       (= (dcl_ComboBox_GetEBText sgyPlot_sgyPlot_ComboBox5) "")
  417.       (= (dcl_ComboBox_GetEBText sgyPlot_sgyPlot_ComboBox6) "")
  418.     )
  419.     (alert "项目、专业、阶段请填写完整!")
  420.     (progn
  421.       (setq tmp (vl-bb-ref 'projectname))
  422.       (setq tmp (non_string_to_list tmp "+"))
  423.       (setq *UploadFolder (strcat (cadr tmp) "+" (caddr tmp)))
  424.       (setq *MyPro (dcl_ComboBox_GetEBText sgyPlot_sgyPlot_ComboBox5))
  425.       (setq *Myphase (dcl_ComboBox_GetEBText sgyPlot_sgyPlot_ComboBox6))
  426.       (if (or
  427.         (and (= (Vlax-Get (Vlax-Get (Vlax-Get-Acad-Object) 'ActiveDocument) 'Saved ) 0) (= 1 (dcl_MessageBox "是否保存并上传?" "图纸尚未保存" 3 2)) (not (command "qsave" "")))
  428.         (= (Vlax-Get (Vlax-Get (Vlax-Get-Acad-Object) 'ActiveDocument) 'Saved ) -1))
  429.         (progn
  430. ;          (alert "请保存图纸再打印!")
  431. ;          (setq return nil)
  432.           (command "qsave")
  433.         )
  434.       )
  435.       ;打开共享
  436.       (setq objShell (vlax-create-object "wscript.shell"))
  437.       (dcl_Control_SetValue sgyPlot_sgyPlot_ProgressBar1 10)
  438.       (print "预备上传")
  439.       ;net use \\192.168.0.11\ipc$$$$$$$$ /user:administrator
  440.       (dcl_Control_SetValue sgyPlot_sgyPlot_ProgressBar1 20)
  441.       (setq fso (vlax-create-object "Scripting.FileSystemObject"))
  442.       (print "工程目录处理")
  443.       ;建立项目文件夹
  444.       (setq folder (strcat "\\\" *IP *Folder *UploadFolder "\"))
  445.       (vl-mkdir folder)
  446.       ;项目阶段
  447.       (setq folder (strcat folder *Myphase "\"))
  448.       (vl-mkdir folder)
  449.       ;项目专业
  450.       (setq folder (strcat folder *MyPro "\"))
  451.       (vl-mkdir folder)
  452.       (dcl_Control_SetValue sgyPlot_sgyPlot_ProgressBar1 30)
  453.       ;(setq isFolder (vlax-invoke fso 'GetFolder folder))
  454.       ;获取本地文件
  455.       (setq dwgpath (Vlax-Get (Vlax-Get (Vlax-Get-Acad-Object) 'ActiveDocument) 'Path ))
  456.       (setq dwgname (Vlax-Get (Vlax-Get (Vlax-Get-Acad-Object) 'ActiveDocument) 'Name ))
  457.       (print "文件验证")
  458.       (setq file (Vlax-Invoke-Method fso 'GetFile (strcat dwgpath "\" dwgname)))
  459.       (dcl_Control_SetValue sgyPlot_sgyPlot_ProgressBar1 40)
  460.       ;本地文件属性
  461.       (setq myfilesize (Vlax-Get file 'Size ))
  462.       (setq myfileDateLastAccessed (Vlax-Get file 'DateLastAccessed ))
  463.       (setq myfileDateLastModified (Vlax-Get file 'DateLastModified ))
  464.       (setq myfileAttributes (Vlax-Get file 'Attributes ))
  465.       ;文件上传
  466.       (print "文件上传")
  467.       (dcl_Control_SetValue sgyPlot_sgyPlot_ProgressBar1 50)
  468.       (vlax-invoke-method file 'copy folder :vlax-true)
  469.       (dcl_Control_SetValue sgyPlot_sgyPlot_ProgressBar1 60)
  470.       ;上传后验证文件是否相同
  471.       (print "验证上传文件")
  472.       (setq newfile (Vlax-Invoke-Method fso 'GetFile (strcat folder "\" dwgname)))
  473.       (dcl_Control_SetValue sgyPlot_sgyPlot_ProgressBar1 80)
  474.       (if (and newfile
  475.           (equal (Vlax-Get newfile 'Size ) myfilesize)
  476. ;          (equal (Vlax-Get newfile 'DateLastAccessed ) myfileDateLastAccessed 0.1)
  477.           (equal (Vlax-Get newfile 'DateLastModified ) myfileDateLastModified)
  478.           (equal (Vlax-Get newfile 'Attributes ) myfileAttributes)
  479.         )
  480.         (progn
  481.           (dcl_Control_SetValue sgyPlot_sgyPlot_ProgressBar1 100)
  482.           (print "图纸上传成功!")
  483.           (setq return T)
  484.           (dcl_Control_SetValue sgyPlot_sgyPlot_ProgressBar1 1)
  485.         )
  486.         (progn
  487.           (alert "上传失败!")
  488.           (setq return nil)
  489.         )
  490.       )
  491.     )
  492.   )
  493.   return
  494. )

  495. ;上传测试
  496. ;(defun c:sgyPlot_sgyPlot_TextButton4_OnClicked()
  497. ;  (sgySQLinsert)
  498. ;)
  499. ;这里能够返回插入数据库时返回影响的ID行号!
  500. (defun sgySQLinsert (/  date datelst x datestr y tmp  is归档 is删除 sqlvalues  values con sql record fields field value insertline)
  501.   (print "数据库写入")
  502.   (setq String打印人 (vl-bb-ref 'sgyname))
  503.   (setq String打印时间 (setq date (rtos(getvar "cdate")2 8)
  504.       datelst(mapcar '(lambda(x)(substr date (car x) (cadr x))) '((1 4) (5 2) (7 2) (10 2)(12 2)(14 2)))
  505.       datestr(apply 'strcat (mapcar '(lambda(x y)(strcat x y)) datelst '("年" "月" "日" "时" "分" "秒" "毫秒")))))
  506.   (setq tmp (vl-bb-ref 'projectname))
  507.   (setq tmp (non_string_to_list tmp "+"))
  508.   (setq String合同ID (car tmp))
  509.   (setq String业务号 (cadr tmp))
  510.   (setq String项目编号 (caddr tmp))
  511.   (setq String项目名称 (cadddr tmp))
  512.   (setq String专业 (dcl_ComboBox_GetEBText sgyPlot_sgyPlot_ComboBox5))
  513.   (setq String项目阶段 (dcl_ComboBox_GetEBText sgyPlot_sgyPlot_ComboBox6))
  514.   (setq Dwg图纸名 (strcat (vl-filename-base (Vlax-Get (Vlax-Get (Vlax-Get-Acad-Object) 'ActiveDocument) 'Name )) ".dwg"))
  515.   (setq Sring图纸大小 (dcl_ComboBox_GetEBText sgyPlot_sgyPlot_ComboBox2))
  516.   (setq String打印机 (dcl_ComboBox_GetEBText sgyPlot_sgyPlot_ComboBox1))
  517.   (setq String条码 "" is归档 "0" is删除 "0")
  518.   (setq sqlvalues (list String打印人 String打印时间 String条码 String项目名称 String合同ID String项目阶段 String业务号 String项目编号  String专业 Sring图纸大小 String打印机 Dwg图纸名 Dwg版本号 Dwg业务号 Dwg图号 Dwg图名 Dwg制图 Dwg比例 Dwg日期 is归档 is删除))
  519.   (setq values (apply 'strcat (mapcar '(lambda (x) (strcat "," (if x (strcat "'" x "'") "''") )) sqlvalues)))
  520.   (setq values (substr values 2))
  521.   (Setq con (Vlax-Get-Or-Create-Object "adodb.connection" ))
  522.   (Vlax-Invoke con 'Open (strcat "Driver={SQL Server};Server=" *SQLIP ";UID=sa;PWD=lzsjy;database=SGYPLOT;"))
  523.   (setq sql  (strcat "INSERT INTO plot (plot_person,plot_time,dwg_tiaoma,project_name,project_hetong,project_jieduan,project_yewuhao,project_bianhao,project_zhuanye,project_size,project_plotter,dwg_name,dwg_ver,dwg_yewuhao,dwg_tuhao,dwg_tuming,dwg_zhitu,dwg_bili,dwg_date,isGuiDang,isDelete) VALUES (" values  ")" ))
  524.   (setq Record (vlax-invoke con 'execute sql))
  525.   (setq sql "SELECT @@IDENTITY AS NewID")
  526.   (Vlax-Invoke-Method Record 'NextRecordset )
  527.   (setq Record (vlax-invoke con 'execute sql))
  528.   (setq fields (vlax-get-property Record  'Fields))
  529.   (setq field (Vlax-Invoke fields 'Item "NewID" ))
  530.   (setq value (Vlax-Get-property field 'Value ))
  531.   (setq insertLine(vlax-variant-value (vlax-variant-change-type value 8)))
  532.   (Vlax-Invoke-Method con 'Close)
  533.   (print "数据库写入完成")
  534.   insertLine
  535. ;  (Setq Record (Vlax-Get-Or-Create-Object "adodb.Recordset" ))
  536. ;  (Vlax-Invoke-Method Record 'NextRecordset )
  537. ;  (setq fields (vlax-get-property record  'Fields))
  538. ;  (print (Vlax-Invoke fields 'Item "NewID" ))
  539. ;  (while (/= (Vlax-Get Record 'EOF ) -1)
  540. ;    (foreach x (vlax-safearray->list (vlax-variant-value (Vlax-Invoke-Method Record 'GetRows 1 )))
  541. ;      (setq y x)
  542. ;      (print (vlax-variant-value (vlax-variant-change-type (car x) 8)))
  543. ;    )
  544. ;  )
  545. ;  (setq fields (vlax-get-property record  'Fields))
  546. ;  (setq field (Vlax-Invoke fields 'Item "fax" ))
  547. ;  (print (Vlax-Get field 'Value ))
  548. ;  (Vlax-Put-Property field 'Value "xxx" )
  549. ;  (Vlax-Invoke-Method Record 'Update )
  550. ;  (Vlax-Invoke-Method Record 'Close )
  551. )
  552. (defun sgySQLinsertTiaoMa (id code /)
  553.   (print "条码写入")
  554.   (Setq con (Vlax-Get-Or-Create-Object "adodb.connection" ))
  555.   (Vlax-Invoke con 'Open (strcat "Driver={SQL Server};Server=" *SQLIP ";UID=sa;PWD=lzsjy;database=SGYPLOT;"))
  556.   (setq sql  (strcat "update plot set dwg_tiaoma = '" code "' where id = " "'" (vl-princ-to-string id) "'" ))
  557.   (vlax-invoke con 'execute sql)
  558.   (Vlax-Invoke-Method con 'Close)
  559.   (print "条码写入完成")
  560. )
  561. ;(c:sgyPlot_sgyPlot_TextButton4_OnClicked)
  562. ;A1下载
  563. (defun c:sgyPlot_sgyPlot_TextButton5_OnClicked (/)
  564.   (setq pt (getpoint "请选择插入点"))
  565.   (if pt
  566.     (progn
  567.       (setvar "cmdecho" 0)
  568.       (command "layer" "n" "TT" "c" "4" "TT" "")
  569.       (setvar "clayer" "TT")
  570.       (command "insert" (strcat "\\\" *IP *folder_tukuang "SGY-A1.dwg") pt 1 1 0)
  571.       (setq pt (polar (polar pt (* pi 1.5) 0.1) pi 0.1))
  572.       (setq pty (list (+ (car pt) 841.2)(+ (cadr pt) 594.2)))
  573.       (command "zoom" pt pty)
  574.       (command "explode" (entlast))
  575.       (setq RDpt (list (+ (car pt) 420) (cadr pt)))
  576.       (if (setq ss (ssget "c"
  577.         (list (+ (car RDpt) -170) (+ (cadr RDpt) 10))
  578.         (list (+ (car RDpt) -120) (+ (cadr RDpt)  17))
  579.         '((0 . "*TEXT")(8 . "TT"))))
  580.         (setq Dwg版本号 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  581.         (setq Dwg版本号 "")
  582.       )
  583.       (if (setq ss (ssget "c"
  584.         (list (+ (car RDpt) -100) (+ (cadr RDpt)  10))
  585.         (list (+ (car RDpt) -65) (+ (cadr RDpt)  17))
  586.         '((0 . "*TEXT")(8 . "TT"))))
  587.         (setq Dwg业务号 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  588.         (setq Dwg业务号 "")
  589.       )
  590.       (if (setq ss (ssget "c"
  591.       (list (+ (car RDpt) -45) (+ (cadr RDpt)  10))
  592.       (list (+ (car RDpt) -10) (+ (cadr RDpt)  17))
  593.       '((0 . "*TEXT")(8 . "TT"))))
  594.         (setq Dwg图号 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  595.         (setq Dwg图号 "")
  596.       )
  597.       (if (setq ss (ssget "c"
  598.       (list (+ (car RDpt) -170) (+ (cadr RDpt) 17))
  599.       (list (+ (car RDpt) -135) (+ (cadr RDpt) 24))
  600.       '((0 . "*TEXT")(8 . "TT"))))
  601.         (setq Dwg制图 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  602.         (setq Dwg制图 "")
  603.       )
  604.       (if (setq ss (ssget "c"
  605.       (list (+ (car RDpt) -100) (+ (cadr RDpt) 17))
  606.       (list (+ (car RDpt) -65) (+ (cadr RDpt) 24))
  607.       '((0 . "*TEXT")(8 . "TT"))))
  608.         (setq Dwg比例 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  609.         (setq Dwg比例 "")
  610.       )
  611.       (if (setq ss (ssget "c"
  612.       (list (+ (car RDpt) -45) (+ (cadr RDpt) 17))
  613.       (list (+ (car RDpt) -10) (+ (cadr RDpt)  24))
  614.       '((0 . "*TEXT")(8 . "TT"))))
  615.         (setq Dwg日期 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  616.         (setq Dwg日期 "")
  617.       )
  618.       (if (setq ss (ssget "c"
  619.       (list (+ (car RDpt) -120) (+ (cadr RDpt) 24))
  620.       (list (+ (car RDpt) -10) (+ (cadr RDpt)  59))
  621.       '((0 . "*TEXT")(8 . "TT"))))
  622.         (setq Dwg图名 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  623.         (setq Dwg图名 "")
  624.       )
  625.       (vl-catch-all-apply 'sgy-tukuang-last2pt (list pt pty))
  626.       (setvar "cmdecho" 1)
  627.     )
  628.   )
  629.   (sgy-tukuang-info)
  630. );A2下载
  631. (defun c:sgyPlot_sgyPlot_TextButton6_OnClicked (/)
  632.   (setq pt (getpoint "请选择插入点"))
  633.   (if pt
  634.     (progn
  635.       (setvar "cmdecho" 0)
  636.       (command "layer" "n" "TT" "c" "4" "TT" "")
  637.       (setvar "clayer" "TT")
  638.       (command "insert" (strcat "\\\" *IP *folder_tukuang "SGY-A2.dwg") pt 1 1 0)
  639.       (setq pt (polar (polar pt (* pi 1.5) 0.1) pi 0.1))
  640.       (setq pty (polar (polar pt (* pi 0.5) 420.2) 0 594.2))
  641. ;      (setq pty (list (+ (car pt) 594)(+ (cadr pt) 420)))
  642.       (setq las (entlast))
  643.       (command "zoom" pt pty)
  644.       (command "explode" (entlast))
  645.       (setq RDpt (list (+ (car pt) 594) (cadr pt)))
  646.       (if (setq ss (ssget "c"
  647.         (list (+ (car RDpt) -115) (+ (cadr RDpt) 10))
  648.         (list (+ (car RDpt) -80) (+ (cadr RDpt)  17))
  649.         '((0 . "*TEXT")(8 . "TT"))))
  650.         (setq Dwg版本号 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  651.         (setq Dwg版本号 "")
  652.       )
  653.       (if (setq ss (ssget "c"
  654.         (list (+ (car RDpt) -65) (+ (cadr RDpt)  10))
  655.         (list (+ (car RDpt) -45) (+ (cadr RDpt)  17))
  656.         '((0 . "*TEXT")(8 . "TT"))))
  657.         (setq Dwg业务号 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  658.         (setq Dwg业务号 "")
  659.       )
  660.       (if (setq ss (ssget "c"
  661.       (list (+ (car RDpt) -30) (+ (cadr RDpt)  10))
  662.       (list (+ (car RDpt) -10) (+ (cadr RDpt)  17))
  663.       '((0 . "*TEXT")(8 . "TT"))))
  664.         (setq Dwg图号 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  665.         (setq Dwg图号 "")
  666.       )
  667.       (if (setq ss (ssget "c"
  668.       (list (+ (car RDpt) -115) (+ (cadr RDpt) 17))
  669.       (list (+ (car RDpt) -90) (+ (cadr RDpt) 24))
  670.       '((0 . "*TEXT")(8 . "TT"))))
  671.         (setq Dwg制图 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  672.         (setq Dwg制图 "")
  673.       )
  674.       (if (setq ss (ssget "c"
  675.       (list (+ (car RDpt) -65) (+ (cadr RDpt) 17))
  676.       (list (+ (car RDpt) -45) (+ (cadr RDpt) 24))
  677.       '((0 . "*TEXT")(8 . "TT"))))
  678.         (setq Dwg比例 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  679.         (setq Dwg比例 "")
  680.       )
  681.       (if (setq ss (ssget "c"
  682.       (list (+ (car RDpt) -30) (+ (cadr RDpt) 17))
  683.       (list (+ (car RDpt) -10) (+ (cadr RDpt)  24))
  684.       '((0 . "*TEXT")(8 . "TT"))))
  685.         (setq Dwg日期 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  686.         (setq Dwg日期 "")
  687.       )
  688.       (if (setq ss (ssget "c"
  689.       (list (+ (car RDpt) -80) (+ (cadr RDpt) 24))
  690.       (list (+ (car RDpt) -10) (+ (cadr RDpt)  59))
  691.       '((0 . "*TEXT")(8 . "TT"))))
  692.         (setq Dwg图名 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  693.         (setq Dwg图名 "")
  694.       )
  695.       (vl-catch-all-apply 'sgy-tukuang-last2pt (list pt pty))
  696.       (setvar "cmdecho" 1)
  697.     )
  698.   )

  699.   (sgy-tukuang-info)
  700. );A3下载


  701. (defun c:sgyPlot_sgyPlot_TextButton7_OnClicked (/ pt  pty rdpt ss )
  702.   (setq pt (getpoint "请选择插入点"))
  703.   (if pt
  704.     (progn
  705.       (setvar "cmdecho" 0)
  706.       (command "layer" "n" "TT" "c" "4" "TT" "")
  707.       (setvar "clayer" "TT")
  708.       (command "insert" (strcat "\\\" *IP *folder_tukuang "SGY-A3.dwg") pt 1 1 0)
  709.       (setq pt (polar (polar pt (* pi 1.5) 0.1) pi 0.1))
  710.       (setq pty (list (+ (car pt) 420.2)(+ (cadr pt) 297.2)))
  711.       (command "zoom" pt pty)
  712.       (command "explode" (entlast))
  713.       (setq RDpt (list (+ (car pt) 420) (cadr pt)))
  714.       (if (setq ss (ssget "c"
  715.         (list (+ (car RDpt) -83.75) (+ (cadr RDpt) 5))
  716.         (list (+ (car RDpt) -57.5) (+ (cadr RDpt)  10.25))
  717.         '((0 . "*TEXT")(8 . "TT"))))
  718.         (setq Dwg版本号 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  719.         (setq Dwg版本号 "")
  720.       )
  721.       (if (setq ss (ssget "c"
  722.         (list (+ (car RDpt) -46.25) (+ (cadr RDpt)  5))
  723.         (list (+ (car RDpt) -31.25) (+ (cadr RDpt)  10.25))
  724.         '((0 . "*TEXT")(8 . "TT"))))
  725.         (setq Dwg业务号 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  726.         (setq Dwg业务号 "")
  727.       )
  728.       (if (setq ss (ssget "c"
  729.       (list (+ (car RDpt) -20) (+ (cadr RDpt)  5))
  730.       (list (+ (car RDpt) -5) (+ (cadr RDpt)  10.25))
  731.       '((0 . "*TEXT")(8 . "TT"))))
  732.         (setq Dwg图号 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  733.         (setq Dwg图号 "")
  734.       )
  735.       (if (setq ss (ssget "c"
  736.       (list (+ (car RDpt) -83.75) (+ (cadr RDpt) 10.25))
  737.       (list (+ (car RDpt) -65) (+ (cadr RDpt)  15.5))
  738.       '((0 . "*TEXT")(8 . "TT"))))
  739.         (setq Dwg制图 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  740.         (setq Dwg制图 "")
  741.       )
  742.       (if (setq ss (ssget "c"
  743.       (list (+ (car RDpt) -46.25) (+ (cadr RDpt) 10.25))
  744.       (list (+ (car RDpt) -31.25) (+ (cadr RDpt)  15.5))
  745.       '((0 . "*TEXT")(8 . "TT"))))
  746.         (setq Dwg比例 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  747.         (setq Dwg比例 "")
  748.       )
  749.       (if (setq ss (ssget "c"
  750.       (list (+ (car RDpt) -20) (+ (cadr RDpt) 10.25))
  751.       (list (+ (car RDpt) -5) (+ (cadr RDpt)  15.5))
  752.       '((0 . "*TEXT")(8 . "TT"))))
  753.         (setq Dwg日期 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  754.         (setq Dwg日期 "")
  755.       )
  756.       (if (setq ss (ssget "c"
  757.       (list (+ (car RDpt) -57.5) (+ (cadr RDpt) 15.5))
  758.       (list (+ (car RDpt) -5) (+ (cadr RDpt)  41.75))
  759.       '((0 . "*TEXT")(8 . "TT"))))
  760.         (setq Dwg图名 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  761.         (setq Dwg图名 "")
  762.       )
  763.       (vl-catch-all-apply 'sgy-tukuang-last2pt (list pt pty))
  764.       (setvar "cmdecho" 1)
  765.     )
  766.   )
  767.   (sgy-tukuang-info)
  768. )
  769. ;打印范围根据图框设定
  770. (defun sgy-tukuang-last2pt(ptx pty)
  771.   (setq *plotPtx ptx)
  772.   (setq *plotPty pty)
  773.   (dcl_Control_SetText sgyPlot_sgyPlot_TextBox1 (strcat (rtos (car ptx) 2 4) "," (rtos (cadr ptx) 2 4)))
  774.   (dcl_Control_SetText sgyPlot_sgyPlot_TextBox2 (strcat (rtos (car pty) 2 4) "," (rtos (cadr pty) 2 4)))
  775.   (c:sgyPlot_sgyPlot_TextButton2_OnClicked)
  776. )
  777. ;A1
  778. (defun c:sgyPlot_sgyPlot_TextButton4_OnClicked (/)
  779.   (setq pt (mapcar 'read (non_string_to_list (dcl_Control_GetText sgyPlot_sgyPlot_TextBox1) ",")))
  780.   (if pt
  781.     (progn
  782.       (setq RDpt (list (+ (car pt) 420) (cadr pt)))
  783.       (if (setq ss (ssget "c"
  784.         (list (+ (car RDpt) -170) (+ (cadr RDpt) 10))
  785.         (list (+ (car RDpt) -120) (+ (cadr RDpt)  17))
  786.         '((0 . "*TEXT")(8 . "TT"))))
  787.         (setq Dwg版本号 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  788.         (setq Dwg版本号 "")
  789.       )
  790.       (if (setq ss (ssget "c"
  791.         (list (+ (car RDpt) -100) (+ (cadr RDpt)  10))
  792.         (list (+ (car RDpt) -65) (+ (cadr RDpt)  17))
  793.         '((0 . "*TEXT")(8 . "TT"))))
  794.         (setq Dwg业务号 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  795.         (setq Dwg业务号 "")
  796.       )
  797.       (if (setq ss (ssget "c"
  798.       (list (+ (car RDpt) -45) (+ (cadr RDpt)  10))
  799.       (list (+ (car RDpt) -10) (+ (cadr RDpt)  17))
  800.       '((0 . "*TEXT")(8 . "TT"))))
  801.         (setq Dwg图号 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  802.         (setq Dwg图号 "")
  803.       )
  804.       (if (setq ss (ssget "c"
  805.       (list (+ (car RDpt) -170) (+ (cadr RDpt) 17))
  806.       (list (+ (car RDpt) -135) (+ (cadr RDpt) 24))
  807.       '((0 . "*TEXT")(8 . "TT"))))
  808.         (setq Dwg制图 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  809.         (setq Dwg制图 "")
  810.       )
  811.       (if (setq ss (ssget "c"
  812.       (list (+ (car RDpt) -100) (+ (cadr RDpt) 17))
  813.       (list (+ (car RDpt) -65) (+ (cadr RDpt) 24))
  814.       '((0 . "*TEXT")(8 . "TT"))))
  815.         (setq Dwg比例 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  816.         (setq Dwg比例 "")
  817.       )
  818.       (if (setq ss (ssget "c"
  819.       (list (+ (car RDpt) -45) (+ (cadr RDpt) 17))
  820.       (list (+ (car RDpt) -10) (+ (cadr RDpt)  24))
  821.       '((0 . "*TEXT")(8 . "TT"))))
  822.         (setq Dwg日期 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  823.         (setq Dwg日期 "")
  824.       )
  825.       (if (setq ss (ssget "c"
  826.       (list (+ (car RDpt) -120) (+ (cadr RDpt) 24))
  827.       (list (+ (car RDpt) -10) (+ (cadr RDpt)  59))
  828.       '((0 . "*TEXT")(8 . "TT"))))
  829.         (setq Dwg图名 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  830.         (setq Dwg图名 "")
  831.       )
  832.     )
  833.   )

  834.   (sgy-tukuang-info)
  835. )
  836. ;A2
  837. (defun c:sgyPlot_sgyPlot_TextButton8_OnClicked (/)
  838.   (setq pt (mapcar 'read (non_string_to_list (dcl_Control_GetText sgyPlot_sgyPlot_TextBox1) ",")))
  839.   (if pt
  840.     (progn
  841.       (setq RDpt (list (+ (car pt) 594) (cadr pt)))
  842.       (if (setq ss (ssget "c"
  843.         (list (+ (car RDpt) -115) (+ (cadr RDpt) 10))
  844.         (list (+ (car RDpt) -80) (+ (cadr RDpt)  17))
  845.         '((0 . "*TEXT")(8 . "TT"))))
  846.         (setq Dwg版本号 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  847.         (setq Dwg版本号 "")
  848.       )
  849.       (if (setq ss (ssget "c"
  850.         (list (+ (car RDpt) -65) (+ (cadr RDpt)  10))
  851.         (list (+ (car RDpt) -45) (+ (cadr RDpt)  17))
  852.         '((0 . "*TEXT")(8 . "TT"))))
  853.         (setq Dwg业务号 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  854.         (setq Dwg业务号 "")
  855.       )
  856.       (if (setq ss (ssget "c"
  857.       (list (+ (car RDpt) -30) (+ (cadr RDpt)  10))
  858.       (list (+ (car RDpt) -10) (+ (cadr RDpt)  17))
  859.       '((0 . "*TEXT")(8 . "TT"))))
  860.         (setq Dwg图号 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  861.         (setq Dwg图号 "")
  862.       )
  863.       (if (setq ss (ssget "c"
  864.       (list (+ (car RDpt) -115) (+ (cadr RDpt) 17))
  865.       (list (+ (car RDpt) -90) (+ (cadr RDpt) 24))
  866.       '((0 . "*TEXT")(8 . "TT"))))
  867.         (setq Dwg制图 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  868.         (setq Dwg制图 "")
  869.       )
  870.       (if (setq ss (ssget "c"
  871.       (list (+ (car RDpt) -65) (+ (cadr RDpt) 17))
  872.       (list (+ (car RDpt) -45) (+ (cadr RDpt) 24))
  873.       '((0 . "*TEXT")(8 . "TT"))))
  874.         (setq Dwg比例 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  875.         (setq Dwg比例 "")
  876.       )
  877.       (if (setq ss (ssget "c"
  878.       (list (+ (car RDpt) -30) (+ (cadr RDpt) 17))
  879.       (list (+ (car RDpt) -10) (+ (cadr RDpt)  24))
  880.       '((0 . "*TEXT")(8 . "TT"))))
  881.         (setq Dwg日期 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  882.         (setq Dwg日期 "")
  883.       )
  884.       (if (setq ss (ssget "c"
  885.       (list (+ (car RDpt) -80) (+ (cadr RDpt) 24))
  886.       (list (+ (car RDpt) -10) (+ (cadr RDpt)  59))
  887.       '((0 . "*TEXT")(8 . "TT"))))
  888.         (setq Dwg图名 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  889.         (setq Dwg图名 "")
  890.       )
  891.     )
  892.   )

  893.   (sgy-tukuang-info)
  894. )
  895. ;A3
  896. (defun c:sgyPlot_sgyPlot_TextButton9_OnClicked (/)
  897.   (setq pt (mapcar 'read (non_string_to_list (dcl_Control_GetText sgyPlot_sgyPlot_TextBox1) ",")))
  898.   (if pt
  899.     (progn
  900.       (setq RDpt (list (+ (car pt) 420) (cadr pt)))
  901.       (if (setq ss (ssget "c"
  902.         (list (+ (car RDpt) -83.75) (+ (cadr RDpt) 5))
  903.         (list (+ (car RDpt) -57.5) (+ (cadr RDpt)  10.25))
  904.         '((0 . "*TEXT")(8 . "TT"))))
  905.         (setq Dwg版本号 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  906.         (setq Dwg版本号 "")
  907.       )
  908.       (if (setq ss (ssget "c"
  909.         (list (+ (car RDpt) -46.25) (+ (cadr RDpt)  5))
  910.         (list (+ (car RDpt) -31.25) (+ (cadr RDpt)  10.25))
  911.         '((0 . "*TEXT")(8 . "TT"))))
  912.         (setq Dwg业务号 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  913.         (setq Dwg业务号 "")
  914.       )
  915.       (if (setq ss (ssget "c"
  916.       (list (+ (car RDpt) -20) (+ (cadr RDpt)  5))
  917.       (list (+ (car RDpt) -5) (+ (cadr RDpt)  10.25))
  918.       '((0 . "*TEXT")(8 . "TT"))))
  919.         (setq Dwg图号 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  920.         (setq Dwg图号 "")
  921.       )
  922.       (if (setq ss (ssget "c"
  923.       (list (+ (car RDpt) -83.75) (+ (cadr RDpt) 10.25))
  924.       (list (+ (car RDpt) -65) (+ (cadr RDpt)  15.5))
  925.       '((0 . "*TEXT")(8 . "TT"))))
  926.         (setq Dwg制图 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  927.         (setq Dwg制图 "")
  928.       )
  929.       (if (setq ss (ssget "c"
  930.       (list (+ (car RDpt) -46.25) (+ (cadr RDpt) 10.25))
  931.       (list (+ (car RDpt) -31.25) (+ (cadr RDpt)  15.5))
  932.       '((0 . "*TEXT")(8 . "TT"))))
  933.         (setq Dwg比例 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  934.         (setq Dwg比例 "")
  935.       )
  936.       (if (setq ss (ssget "c"
  937.       (list (+ (car RDpt) -20) (+ (cadr RDpt) 10.25))
  938.       (list (+ (car RDpt) -5) (+ (cadr RDpt)  15.5))
  939.       '((0 . "*TEXT")(8 . "TT"))))
  940.         (setq Dwg日期 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  941.         (setq Dwg日期 "")
  942.       )
  943.       (if (setq ss (ssget "c"
  944.       (list (+ (car RDpt) -57.5) (+ (cadr RDpt) 15.5))
  945.       (list (+ (car RDpt) -5) (+ (cadr RDpt)  41.75))
  946.       '((0 . "*TEXT")(8 . "TT"))))
  947.         (setq Dwg图名 (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss 0)) 'TextString ))
  948.         (setq Dwg图名 "")
  949.       )
  950.     )
  951.   )
  952.   (sgy-tukuang-info)
  953. )
  954. (defun sgy-tukuang-info()
  955.   (dcl_Control_SetCaption sgyPlot_sgyPlot_Label14 (strcat "版本号:" Dwg版本号))
  956.   (dcl_Control_SetCaption sgyPlot_sgyPlot_Label15 (strcat "业务号:" Dwg业务号))
  957.   (dcl_Control_SetCaption sgyPlot_sgyPlot_Label16 (strcat "图号:" Dwg图号))
  958.   (dcl_Control_SetCaption sgyPlot_sgyPlot_Label17 (strcat "制图:" Dwg制图))
  959.   (dcl_Control_SetCaption sgyPlot_sgyPlot_Label18 (strcat "比例:" Dwg比例))
  960.   (dcl_Control_SetCaption sgyPlot_sgyPlot_Label19 (strcat "日期:" Dwg日期))
  961.   (dcl_Control_SetCaption sgyPlot_sgyPlot_Label20 (strcat "图名:" Dwg图名))
  962. )

  963. (princ "\n打印程序加载成功!")
  964. (princ "\n开发维护:不死猫")
  965. (print "加载完成")
  966. (print "不死猫老师空间http://nonsmall.mjtd.com")
  967. (princ)
Md5.vbs

  1. Private Const BITS_TO_A_BYTE = 8
  2. Private Const BYTES_TO_A_WORD = 4
  3. Private Const BITS_TO_A_WORD = 32
  4. Private m_lOnBits(30)
  5. Private m_l2Power(30)
  6. m_lOnBits(0) = CLng(1)
  7. m_lOnBits(1) = CLng(3)
  8. m_lOnBits(2) = CLng(7)
  9. m_lOnBits(3) = CLng(15)
  10. m_lOnBits(4) = CLng(31)
  11. m_lOnBits(5) = CLng(63)
  12. m_lOnBits(6) = CLng(127)
  13. m_lOnBits(7) = CLng(255)
  14. m_lOnBits(8) = CLng(511)
  15. m_lOnBits(9) = CLng(1023)
  16. m_lOnBits(10) = CLng(2047)
  17. m_lOnBits(11) = CLng(4095)
  18. m_lOnBits(12) = CLng(8191)
  19. m_lOnBits(13) = CLng(16383)
  20. m_lOnBits(14) = CLng(32767)
  21. m_lOnBits(15) = CLng(65535)
  22. m_lOnBits(16) = CLng(131071)
  23. m_lOnBits(17) = CLng(262143)
  24. m_lOnBits(18) = CLng(524287)
  25. m_lOnBits(19) = CLng(1048575)
  26. m_lOnBits(20) = CLng(2097151)
  27. m_lOnBits(21) = CLng(4194303)
  28. m_lOnBits(22) = CLng(8388607)
  29. m_lOnBits(23) = CLng(16777215)
  30. m_lOnBits(24) = CLng(33554431)
  31. m_lOnBits(25) = CLng(67108863)
  32. m_lOnBits(26) = CLng(134217727)
  33. m_lOnBits(27) = CLng(268435455)
  34. m_lOnBits(28) = CLng(536870911)
  35. m_lOnBits(29) = CLng(1073741823)
  36. m_lOnBits(30) = CLng(2147483647)
  37. m_l2Power(0) = CLng(1)
  38. m_l2Power(1) = CLng(2)
  39. m_l2Power(2) = CLng(4)
  40. m_l2Power(3) = CLng(8)
  41. m_l2Power(4) = CLng(16)
  42. m_l2Power(5) = CLng(32)
  43. m_l2Power(6) = CLng(64)
  44. m_l2Power(7) = CLng(128)
  45. m_l2Power(8) = CLng(256)
  46. m_l2Power(9) = CLng(512)
  47. m_l2Power(10) = CLng(1024)
  48. m_l2Power(11) = CLng(2048)
  49. m_l2Power(12) = CLng(4096)
  50. m_l2Power(13) = CLng(8192)
  51. m_l2Power(14) = CLng(16384)
  52. m_l2Power(15) = CLng(32768)
  53. m_l2Power(16) = CLng(65536)
  54. m_l2Power(17) = CLng(131072)
  55. m_l2Power(18) = CLng(262144)
  56. m_l2Power(19) = CLng(524288)
  57. m_l2Power(20) = CLng(1048576)
  58. m_l2Power(21) = CLng(2097152)
  59. m_l2Power(22) = CLng(4194304)
  60. m_l2Power(23) = CLng(8388608)
  61. m_l2Power(24) = CLng(16777216)
  62. m_l2Power(25) = CLng(33554432)
  63. m_l2Power(26) = CLng(67108864)
  64. m_l2Power(27) = CLng(134217728)
  65. m_l2Power(28) = CLng(268435456)
  66. m_l2Power(29) = CLng(536870912)
  67. m_l2Power(30) = CLng(1073741824)

  68. SET ARR = WScript.Arguments
  69. re = md5(arr(0))
  70. Set fso =CreateObject("Scripting.FileSystemObject")  
  71. Set File = fso.CreateTextFile("c:\sgyPlot\md5.txt", True)
  72. File.WriteLine(re)
  73. File.Close
  74. Private Function LShift(lValue, iShiftBits)
  75. If iShiftBits = 0 Then
  76. LShift = lValue
  77. Exit Function
  78. ElseIf iShiftBits = 31 Then
  79. If lValue And 1 Then
  80. LShift = &H80000000
  81. Else
  82. LShift = 0
  83. End If
  84. Exit Function
  85. ElseIf iShiftBits < 0 Or iShiftBits > 31 Then
  86. Err.Raise 6
  87. End If

  88. If (lValue And m_l2Power(31 - iShiftBits)) Then
  89. LShift = ((lValue And m_lOnBits(31 - (iShiftBits + 1))) * m_l2Power(iShiftBits)) Or &H80000000
  90. Else
  91. LShift = ((lValue And m_lOnBits(31 - iShiftBits)) * m_l2Power(iShiftBits))
  92. End If
  93. End Function

  94. Private Function RShift(lValue, iShiftBits)
  95. If iShiftBits = 0 Then
  96. RShift = lValue
  97. Exit Function
  98. ElseIf iShiftBits = 31 Then
  99. If lValue And &H80000000 Then
  100. RShift = 1
  101. Else
  102. RShift = 0
  103. End If
  104. Exit Function
  105. ElseIf iShiftBits < 0 Or iShiftBits > 31 Then
  106. Err.Raise 6
  107. End If

  108. RShift = (lValue And &H7FFFFFFE) \ m_l2Power(iShiftBits)

  109. If (lValue And &H80000000) Then
  110. RShift = (RShift Or (&H40000000 \ m_l2Power(iShiftBits - 1)))
  111. End If
  112. End Function

  113. Private Function RotateLeft(lValue, iShiftBits)
  114. RotateLeft = LShift(lValue, iShiftBits) Or RShift(lValue, (32 - iShiftBits))
  115. End Function

  116. Private Function AddUnsigned(lX, lY)
  117. Dim lX4
  118. Dim lY4
  119. Dim lX8
  120. Dim lY8
  121. Dim lResult

  122. lX8 = lX And &H80000000
  123. lY8 = lY And &H80000000
  124. lX4 = lX And &H40000000
  125. lY4 = lY And &H40000000

  126. lResult = (lX And &H3FFFFFFF) + (lY And &H3FFFFFFF)

  127. If lX4 And lY4 Then
  128. lResult = lResult Xor &H80000000 Xor lX8 Xor lY8
  129. ElseIf lX4 Or lY4 Then
  130. If lResult And &H40000000 Then
  131. lResult = lResult Xor &HC0000000 Xor lX8 Xor lY8
  132. Else
  133. lResult = lResult Xor &H40000000 Xor lX8 Xor lY8
  134. End If
  135. Else
  136. lResult = lResult Xor lX8 Xor lY8
  137. End If

  138. AddUnsigned = lResult
  139. End Function

  140. Private Function F(x, y, z)
  141. F = (x And y) Or ((Not x) And z)
  142. End Function

  143. Private Function G(x, y, z)
  144. G = (x And z) Or (y And (Not z))
  145. End Function

  146. Private Function H(x, y, z)
  147. H = (x Xor y Xor z)
  148. End Function

  149. Private Function I(x, y, z)
  150. I = (y Xor (x Or (Not z)))
  151. End Function

  152. Private Sub FF(a, b, c, d, x, s, ac)
  153. a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac))
  154. a = RotateLeft(a, s)
  155. a = AddUnsigned(a, b)
  156. End Sub

  157. Private Sub GG(a, b, c, d, x, s, ac)
  158. a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac))
  159. a = RotateLeft(a, s)
  160. a = AddUnsigned(a, b)
  161. End Sub

  162. Private Sub HH(a, b, c, d, x, s, ac)
  163. a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac))
  164. a = RotateLeft(a, s)
  165. a = AddUnsigned(a, b)
  166. End Sub

  167. Private Sub II(a, b, c, d, x, s, ac)
  168. a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac))
  169. a = RotateLeft(a, s)
  170. a = AddUnsigned(a, b)
  171. End Sub

  172. Private Function ConvertToWordArray(sMessage)
  173. Dim lMessageLength
  174. Dim lNumberOfWords
  175. Dim lWordArray()
  176. Dim lBytePosition
  177. Dim lByteCount
  178. Dim lWordCount

  179. Const MODULUS_BITS = 512
  180. Const CONGRUENT_BITS = 448

  181. lMessageLength = Len(sMessage)

  182. lNumberOfWords = (((lMessageLength + ((MODULUS_BITS - CONGRUENT_BITS) \ BITS_TO_A_BYTE)) \ (MODULUS_BITS \ BITS_TO_A_BYTE)) + 1) * (MODULUS_BITS \ BITS_TO_A_WORD)
  183. ReDim lWordArray(lNumberOfWords - 1)

  184. lBytePosition = 0
  185. lByteCount = 0
  186. Do Until lByteCount >= lMessageLength
  187. lWordCount = lByteCount \ BYTES_TO_A_WORD
  188. lBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE
  189. lWordArray(lWordCount) = lWordArray(lWordCount) Or LShift(Asc(Mid(sMessage, lByteCount + 1, 1)), lBytePosition)
  190. lByteCount = lByteCount + 1
  191. Loop

  192. lWordCount = lByteCount \ BYTES_TO_A_WORD
  193. lBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE

  194. lWordArray(lWordCount) = lWordArray(lWordCount) Or LShift(&H80, lBytePosition)

  195. lWordArray(lNumberOfWords - 2) = LShift(lMessageLength, 3)
  196. lWordArray(lNumberOfWords - 1) = RShift(lMessageLength, 29)

  197. ConvertToWordArray = lWordArray
  198. End Function

  199. Private Function WordToHex(lValue)
  200. Dim lByte
  201. Dim lCount

  202. For lCount = 0 To 3
  203. lByte = RShift(lValue, lCount * BITS_TO_A_BYTE) And m_lOnBits(BITS_TO_A_BYTE - 1)
  204. WordToHex = WordToHex & Right("0" & Hex(lByte), 2)
  205. Next
  206. End Function

  207. Public Function MD5(sMessage)
  208. Dim x
  209. Dim k
  210. Dim AA
  211. Dim BB
  212. Dim CC
  213. Dim DD
  214. Dim a
  215. Dim b
  216. Dim c
  217. Dim d

  218. Const S11 = 7
  219. Const S12 = 12
  220. Const S13 = 17
  221. Const S14 = 22
  222. Const S21 = 5
  223. Const S22 = 9
  224. Const S23 = 14
  225. Const S24 = 20
  226. Const S31 = 4
  227. Const S32 = 11
  228. Const S33 = 16
  229. Const S34 = 23
  230. Const S41 = 6
  231. Const S42 = 10
  232. Const S43 = 15
  233. Const S44 = 21

  234. x = ConvertToWordArray(sMessage)

  235. a = &H67452301
  236. b = &HEFCDAB89
  237. c = &H98BADCFE
  238. d = &H10325476

  239. For k = 0 To UBound(x) Step 16
  240. AA = a
  241. BB = b
  242. CC = c
  243. DD = d

  244. FF a, b, c, d, x(k + 0), S11, &HD76AA478
  245. FF d, a, b, c, x(k + 1), S12, &HE8C7B756
  246. FF c, d, a, b, x(k + 2), S13, &H242070DB
  247. FF b, c, d, a, x(k + 3), S14, &HC1BDCEEE
  248. FF a, b, c, d, x(k + 4), S11, &HF57C0FAF
  249. FF d, a, b, c, x(k + 5), S12, &H4787C62A
  250. FF c, d, a, b, x(k + 6), S13, &HA8304613
  251. FF b, c, d, a, x(k + 7), S14, &HFD469501
  252. FF a, b, c, d, x(k + 8), S11, &H698098D8
  253. FF d, a, b, c, x(k + 9), S12, &H8B44F7AF
  254. FF c, d, a, b, x(k + 10), S13, &HFFFF5BB1
  255. FF b, c, d, a, x(k + 11), S14, &H895CD7BE
  256. FF a, b, c, d, x(k + 12), S11, &H6B901122
  257. FF d, a, b, c, x(k + 13), S12, &HFD987193
  258. FF c, d, a, b, x(k + 14), S13, &HA679438E
  259. FF b, c, d, a, x(k + 15), S14, &H49B40821

  260. GG a, b, c, d, x(k + 1), S21, &HF61E2562
  261. GG d, a, b, c, x(k + 6), S22, &HC040B340
  262. GG c, d, a, b, x(k + 11), S23, &H265E5A51
  263. GG b, c, d, a, x(k + 0), S24, &HE9B6C7AA
  264. GG a, b, c, d, x(k + 5), S21, &HD62F105D
  265. GG d, a, b, c, x(k + 10), S22, &H2441453
  266. GG c, d, a, b, x(k + 15), S23, &HD8A1E681
  267. GG b, c, d, a, x(k + 4), S24, &HE7D3FBC8
  268. GG a, b, c, d, x(k + 9), S21, &H21E1CDE6
  269. GG d, a, b, c, x(k + 14), S22, &HC33707D6
  270. GG c, d, a, b, x(k + 3), S23, &HF4D50D87
  271. GG b, c, d, a, x(k + 8), S24, &H455A14ED
  272. GG a, b, c, d, x(k + 13), S21, &HA9E3E905
  273. GG d, a, b, c, x(k + 2), S22, &HFCEFA3F8
  274. GG c, d, a, b, x(k + 7), S23, &H676F02D9
  275. GG b, c, d, a, x(k + 12), S24, &H8D2A4C8A

  276. HH a, b, c, d, x(k + 5), S31, &HFFFA3942
  277. HH d, a, b, c, x(k + 8), S32, &H8771F681
  278. HH c, d, a, b, x(k + 11), S33, &H6D9D6122
  279. HH b, c, d, a, x(k + 14), S34, &HFDE5380C
  280. HH a, b, c, d, x(k + 1), S31, &HA4BEEA44
  281. HH d, a, b, c, x(k + 4), S32, &H4BDECFA9
  282. HH c, d, a, b, x(k + 7), S33, &HF6BB4B60
  283. HH b, c, d, a, x(k + 10), S34, &HBEBFBC70
  284. HH a, b, c, d, x(k + 13), S31, &H289B7EC6
  285. HH d, a, b, c, x(k + 0), S32, &HEAA127FA
  286. HH c, d, a, b, x(k + 3), S33, &HD4EF3085
  287. HH b, c, d, a, x(k + 6), S34, &H4881D05
  288. HH a, b, c, d, x(k + 9), S31, &HD9D4D039
  289. HH d, a, b, c, x(k + 12), S32, &HE6DB99E5
  290. HH c, d, a, b, x(k + 15), S33, &H1FA27CF8
  291. HH b, c, d, a, x(k + 2), S34, &HC4AC5665

  292. II a, b, c, d, x(k + 0), S41, &HF4292244
  293. II d, a, b, c, x(k + 7), S42, &H432AFF97
  294. II c, d, a, b, x(k + 14), S43, &HAB9423A7
  295. II b, c, d, a, x(k + 5), S44, &HFC93A039
  296. II a, b, c, d, x(k + 12), S41, &H655B59C3
  297. II d, a, b, c, x(k + 3), S42, &H8F0CCC92
  298. II c, d, a, b, x(k + 10), S43, &HFFEFF47D
  299. II b, c, d, a, x(k + 1), S44, &H85845DD1
  300. II a, b, c, d, x(k + 8), S41, &H6FA87E4F
  301. II d, a, b, c, x(k + 15), S42, &HFE2CE6E0
  302. II c, d, a, b, x(k + 6), S43, &HA3014314
  303. II b, c, d, a, x(k + 13), S44, &H4E0811A1
  304. II a, b, c, d, x(k + 4), S41, &HF7537E82
  305. II d, a, b, c, x(k + 11), S42, &HBD3AF235
  306. II c, d, a, b, x(k + 2), S43, &H2AD7D2BB
  307. II b, c, d, a, x(k + 9), S44, &HEB86D391

  308. a = AddUnsigned(a, AA)
  309. b = AddUnsigned(b, BB)
  310. c = AddUnsigned(c, CC)
  311. d = AddUnsigned(d, DD)
  312. Next

  313. MD5 = LCase(WordToHex(a) & WordToHex(b) & WordToHex(c) & WordToHex(d))
  314. End Function
条形码代码请参考Gu版的帖子
http://bbs.mjtd.com/thread-89727-1-1.html

评分

参与人数 1明经币 +3 金钱 +24 收起 理由
Gu_xl + 3 + 24 赞一个!

查看全部评分

"觉得好,就打赏"
还没有人打赏,支持一下

本帖被以下淘专辑推荐:

发表于 2018-1-30 23:54:43 | 显示全部楼层
  1. ;更新模块
  2. ;当版本文件存在则读取服务器版本号
  3. (setq dver "3.0.0.0") ;当前版本号
  4. (if (setq file (open "\\\\192.168.1.11\\1\\ver.txt" "r"))
  5.   (progn (setq xver (read-line file))(close file)
  6.    
  7.     ;将版本号去小数点后连在一起作为数字处理,比较其大小得到是否有新版本
  8.     (while (vl-string-search "." dver)
  9.       (setq dver (vl-string-subst "" "." dver))
  10.     )
  11.     (while (vl-string-search "." xver)
  12.       (setq xver (vl-string-subst "" "." xver))
  13.     )
  14.     (if (< dver xver)
  15.       (progn
  16.         (setq fso (vlax-create-object "Scripting.FileSystemObject"))
  17.         (setq newfile (vlax-invoke-method fso 'getfile "\\\\192.168.1.11\\1\\1.vlx"))
  18.         (vlax-invoke-method newfile 'copy "D:\\cad.vlx" :vlax-true)
  19.         (princ (strcat "\n\t更新完成,新版本号为:V" xver "。请重启CAD以完成更新!"))  
  20.         (setq file nil xver nil dver nil fso nil newfile nil)
  21.       )
  22.       (princ (strcat "\n\t 插件V" dver "已加载."))
  23.       
  24.     )
  25.   )
  26.   (princ (strcat "\n\t 插件V" dver "已加载."))
  27. )

  28. ;更新模块结束

猫老师,在采用自动更新模块的时候出现一个问题,当服务器关机而客户机网络连接存在时,会耗费很长的时间来判断服务器不存在,从而导致程序在加载的时候非常耗时,有没有什么办法能解决呢。以下是我判断版本的代码。
发表于 2017-12-28 13:26:54 | 显示全部楼层
留个脚印,以后慢慢研究。
重点关注在自动更新,目前的原理是比较两个文件,但前提是文件名没有经过更改,能否判断更改以后的vlx文件名,从而与新的文件进行比较?
 楼主| 发表于 2014-6-13 13:09:08 | 显示全部楼层
本帖最后由 不死猫 于 2014-6-13 17:59 编辑

其中Oracle在客户端访问的驱动,可以安装Oracle Database Instant Client(自己百度)
opendcl基于7.0版本
对话框文件


sgyplot.txt
  1. 586.1402,1080.5659
  2. 1006.3402,1377.7659
  3. 1
  4. 10
  5. 1
  6. 1
  7. 1
  8. 1
  9. 西丽
  10. 1
  11. 0
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2014-6-13 13:39:38 | 显示全部楼层
本帖最后由 lucas_3333 于 2014-6-13 13:41 编辑

占楼留名,哈哈,太高深,N年后再来看
发表于 2014-6-13 13:48:08 | 显示全部楼层
猫老师大作!
发表于 2014-6-13 17:50:00 | 显示全部楼层
看样子我要再等十年才看的懂!
发表于 2014-6-13 21:51:06 | 显示全部楼层
太高深,N年后再来看...
发表于 2014-6-14 09:06:38 | 显示全部楼层
太高深,
发表于 2014-6-14 19:53:25 | 显示全部楼层
完全看不懂啊
发表于 2014-6-15 08:50:32 | 显示全部楼层
高手中的高手,佩服。。。
发表于 2014-6-15 14:48:45 | 显示全部楼层
高手中的高手,佩服。。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-6 07:29 , Processed in 0.507239 second(s), 33 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表