从批处理中运行脚本
我有一个Tony Tanzillo的LISP,它可以在一个图形目录中运行,并且应该能够在每个图形上运行一个程序,但我不能让这个工作。我想要它做的是调用我编写的导出脚本。dwg到。dgn。所有参数都已在转换脚本中解决。现在,我使用一个名为EZ Script Pro的程序在图形目录中运行此脚本,但我希望能够从autocad中执行此操作,而不必打开完全不同的程序来执行此操作。有人能帮我找出我在这个程序中做错了什么,并可能帮我找出如何使用Tony Tanzillo批处理程序达到我认为是它的预期目的吗?谢谢
; Function from Tony Tanzillo Maestro Guru ;
(defun browse-folder (msg path / sh fld folderobject result)
(vl-load-com)
(setq sh (vla-getInterfaceObject
(vlax-get-acad-object)
"Shell.Application"
)
)
(setq fld (vlax-invoke-method
sh 'BrowseForFolder
vlax-vbDefaultButton1
msg ; dialogue box message
vlax-vbDefaultButton3 ; BIF_NONEWFOLDERBUTTON Bruno Toniutti
path ; path start
)
)
(vlax-release-object sh)
(if fld
(progn
(setq folderobject (vlax-get-property fld 'Self))
(setq result (vlax-get-property folderObject 'Path))
(vlax-release-object fld)
(vlax-release-object folderobject)
result
)
)
)
; ;
(defun list-dwg (path / file_list full_list)
(setq file_list
(vl-directory-files path "*.dwg" 1)
)
(setq file_list
(mapcar (function (lambda (x) (strcat path "\\" x)))
file_list
)
full_list (append full_list file_list)
)
full_list
)
; ;
(prompt "\n********************************************")
(prompt "\n Enter OPB to run batch file operation\n")
(prompt "\n********************************************")
; ;
(defun C:dgnex (/ *good-files* acapp adoc file_obj full-names-list osd)
(alert
"\nPlease wait a minute
\nto ending of batch file operation"
)
(vl-load-com)
(setq acapp (vlax-get-acad-object)
adoc(vla-get-activedocument acapp)
)
(vla-startundomark adoc)
(setq osd (vla-getvariable adoc "SDI"))
(vla-setvariable adoc "SDI" 0)
(setq olsp (vla-getvariable adoc "LISPINIT"))
(vla-setvariable adoc "LISPINIT" 0)
(if (setq full-names-list
(list-dwg (browse-folder "SELECT FOLDER" "w:\\Projects\\"))
)
; change on your start path folder
(progn
(mapcar
(function
(lambda (i)
(progn
(setq file_obj (vla-open (vla-get-documents acapp) i))
(setq *good-files* (cons file_obj *good-files*))
;;here will your batch function:
(COMMAND "_SCRIPT" "DGNEXPORT.scr" ) ;;My script.
(vla-setvariable file_obj "mirrtext" 0)
; (vla-setvariable file_obj "insunits" 0)
; (vla-setvariable file_obj "annotativedwg" 0)
(vla-close file_obj :vlax-true)
(vlax-release-object file_obj)
(setq file_obj nil)
)
)
)
full-names-list
)
(cond ((zerop (length *good-files*))
(princ "\nThere isn't opened files\n")
)
((not (eq (length full-names-list) (length *good-files*)))
(princ "\nSome files is not opened\n")
)
(T nil)
)
)
(princ "\nThere isn't .DWG files in selected directory\n")
)
(vla-setvariable adoc "SDI" osd)
(vla-setvariable adoc "LISPINIT" olsp)
(vla-endundomark adoc)
(princ)
)
我已经改变了调用dgnexport的方式,现在它可以很好地转换目录中的第一个图形,但一直尝试转换我启动程序的图形。。。我觉得我离得有点近了。
; Function from Tony Tanzillo Maestro Guru ;
(defun browse-folder (msg path / sh fld folderobject result)
(vl-load-com)
(setq sh (vla-getInterfaceObject
(vlax-get-acad-object)
"Shell.Application"
)
)
(setq fld (vlax-invoke-method
sh 'BrowseForFolder
vlax-vbDefaultButton1
msg ; dialogue box message
vlax-vbDefaultButton3 ; BIF_NONEWFOLDERBUTTON Bruno Toniutti
path ; path start
)
)
(vlax-release-object sh)
(if fld
(progn
(setq folderobject (vlax-get-property fld 'Self))
(setq result (vlax-get-property folderObject 'Path))
(vlax-release-object fld)
(vlax-release-object folderobject)
result
)
)
)
; ;
(defun list-dwg (path / file_list full_list)
(setq file_list
(vl-directory-files path "*.dwg" 1)
)
(setq file_list
(mapcar (function (lambda (x) (strcat path "\\" x)))
file_list
)
full_list (append full_list file_list)
)
full_list
)
;;-------------------------------------------------------
;;DGNEXPORT Function
;;Author: Andrew Qucsai Jr.
;;Date: 08-18-2010
(defun dgnfun ( )
(command "-dgnexport" "v8" "" "master" "standard" "W:\\AutoCAD\\PGE_CUI\\V8-Imperial-Seed3D.dgn" )
(PRINC)
)
;;-------------------------------------------------------
; ;
(prompt "\n********************************************")
(prompt "\n Enter OPB to run batch file operation\n")
(prompt "\n********************************************")
; ;
(defun C:dgnex (/ *good-files* acapp adoc file_obj full-names-list osd)
(alert
"\nPlease wait a minute
\nto ending of batch file operation"
)
(vl-load-com)
(setq acapp (vlax-get-acad-object)
adoc(vla-get-activedocument acapp)
)
(vla-startundomark adoc)
(setq osd (vla-getvariable adoc "SDI"))
(vla-setvariable adoc "SDI" 0)
(setq olsp (vla-getvariable adoc "LISPINIT"))
(vla-setvariable adoc "LISPINIT" 0)
(if (setq full-names-list
(list-dwg (browse-folder "SELECT FOLDER" "w:\\Projects\\"))
)
; change on your start path folder
(progn
(mapcar
(function
(lambda (i)
(progn
(setq file_obj (vla-open (vla-get-documents acapp) i))
(setq *good-files* (cons file_obj *good-files*))
;;here will your batch function:
(progn (dgnfun)) ;;My Function
(vla-setvariable file_obj "mirrtext" 0)
; (vla-setvariable file_obj "insunits" 0)
; (vla-setvariable file_obj "annotativedwg" 0)
(vla-close file_obj :vlax-true)
(vlax-release-object file_obj)
(setq file_obj nil)
)
)
)
full-names-list
)
(cond ((zerop (length *good-files*))
(princ "\nThere isn't opened files\n")
)
((not (eq (length full-names-list) (length *good-files*)))
(princ "\nSome files were not opened\n")
)
(T nil)
)
)
(princ "\nThere isn't .DWG files in selected directory\n")
)
(vla-setvariable adoc "SDI" osd)
(vla-setvariable adoc "LISPINIT" olsp)
(vla-endundomark adoc)
(princ)
)
你好
我不确定,但这不是与不能使用命令有关吗?我记得不久前问过类似的问题,但涉及批量导入。 隐马尔可夫模型。。。我没想过。在那种情况下,我可能会把这一切都搞错。 我没有autocad要检查,但我想知道它是否适用于任何不使用命令的东西。 李Mac帮我用这个程序写了一个批量文本替换程序,但那个并没有用命令。 我认为你是对的。我确实认为部分问题在于命令的使用。如果我能找到autocad将dgnexport LISP函数放置在哪里并将其放置在我的程序中,我想我可以绕过这个问题。这样我就不必使用命令,我可以使用progn。
有人知道在哪里可以找到autocad正在使用的实际dgnexport程序吗? 我想你找不到。不仅仅是一些express工具是Lisp吗?
我希望我错了,但我要说的是,如果你没有microstation,你必须坚持使用EZ script Pro(如果它已经完成了这项工作,那听起来很不错)。
页:
[1]