the problem of the code is it can't sendcommand between the documents...please help
thank you first...
(defun c:pc ()
(setq *command* (getstring "\nInput the command:" T))
(IF (setq DWGS (cjw-CommonDialog "Open" "*.dwg" "*.dwg"))
(PROGN
(setq APP (vlax-get-acad-object))
(setq SDI (getvar "SDI"))
(mapcar
'(lambda (DWGNAME)
(setq LSPIN (getvar "LISPINIT"))
(setvar "cmdecho" 0)
(cond
((= SDI 0)
(progn
(setvar "LISPINIT" 0)
(setq DOC (vla-open (vla-get-documents APP) DWGNAME))
)
)
((= SDI 1)
(progn
(command "open" DWGNAME)
(setq DOC (vla-get-ActiveDocument APP))
)
)
)
($Sub_Funtion$ DOC *command*)
(prompt (strcat "\n*** " DWGNAME " ***\n"))
(vla-save DOC)
(if (= SDI 0)
(vla-close DOC :vlax-false)
)
(setvar "LISPINIT" LSPIN)
)
DWGS
)
(vlax-release-object DOC)
(vlax-release-object APP)
(prompt "\n*** 批处理完毕 ***\n")
)
(prompt "\n*** 所选目录中未有任何DWG图档 ***\n")
)
(princ)
)
(defun $Sub_Funtion$ (DOC *command*)
(vla-sendcommand
DOC
*command*
)
)
;;;(setq str "F:\\2008\\ 1.dwg 2.dwg 3.dwg")
;;;(string_split str " ")
;;;("F:\\2008\\" "1.dwg" "2.dwg" "3.dwg")
(defun string_split (str
delimiter
/
lenStr
lenDelimiter
start@
lstStr
done
find@
)
(setq lenStr (strlen str)
lenDelimiter (strlen delimiter)
start@ 0
lstStr nil
done nil
)
(while (and (not done) (<= (1+ start@) lenStr))
(if (setq find@ (vl-string-search delimiter str start@))
(setq lstStr (cons
(if (zerop find@)
""
(substr str (1+ start@) (- find@ start@))
)
lstStr
)
start@ (+ find@ lenDelimiter)
)
(setq done t
lstStr (cons (substr str (1+ start@)) lstStr)
)
)
)
(if (= start@ lenStr)
(setq lstStr (cons "" lstStr))
)
(reverse lstStr)
)
;;;(cjw-CommonDialog "Get the DWG files" "*.dwg" "*.dwg")
(defun cjw-CommonDialog (DialogTitle
FileName
Filter
/
BLKNAS
CHAR
DELIMITER
N
RETURN
SEARCHSTR
STR
STRINGLEN
OBJ
)
(vl-registry-write
"HKEY_CLASSES_ROOT\\Licenses\\4D553650-6ABE-11cf-8ADB-00AA00C00905"
""
"gfjmrfkfifkmkfffrlmmgmhmnlulkmfmqkqj"
)
(if (setq x (vlax-create-object "MSComDlg.CommonDialog"))
(progn (vlax-put-property x "DialogTitle" DialogTitle)
(vlax-put-property x "Filename" FileName)
(vlax-put-property x "Filter" Filter)
(vlax-put-property x "MaxFileSize" 10000)
(vlax-put-property x "Flags" 512)
(vlax-put-property x "Action" 1)
(setq str (vlax-get-property x "Filename"))
)
)
(if (/= str "*.dwg")
(progn
(setq p&f (cjw-string-split str " "))
(setq p (car p&f)
fns (cdr p&f)
files nil
)
(if fns
(foreach f fns
(setq files (cons (strcat p f) files))
)
(setq files p&f)
)
(reverse files)
)
(setq files nil)
)
)