(close (open (strcat "C:\\" (getvar 'dwgname) ".txt") "w"))
Hi all,..WOW !!! unbelievable trick !!!
I've seen many user trying to run LISP in Batch,...
some have created Huge tools, or using script...seeing running 1 by one open each drawing and wasting user time..
some use ODBX who I think is good but limited.
there is my contribution...
Why not using PUBLISH ?
yes,...you can do it what ever you want with PUBLISH !
PUBLISH open each drawing before printing...
so if you put your LISP on the SuitCase it will RUN !
ex:
Lisp Code:Code: [Select](close (open (strcat "C:\\" (getvar 'dwgname) ".txt") "w"))
Put this Lisp in your Application SuitCase Startup.
and run Publish with any configuration you want.
I use DWF options to prevent wasting Paper print.
so the process its simple...
before runing your Lisp,.
1) add you LISP in the suitcase
2) make a publish
3) remove your lisp from the suitcase.
that's all.
the only problem is if a drawing is already opened, It can't be saved,.
:ugly:
(setq fd (open (strcat "d:\\" (getvar 'dwgname) ".txt") "w"))
(write-line (itoa (sslength (setq ss (ssget "_X" '((0 . "INSERT")))))) fd)
(vla-delete (vlax-ename->vla-object (ssname ss 0)))
(close fd)
Hi all,..WOW !!! unbelievable trick !!!
I've seen many user trying to run LISP in Batch,...
some have created Huge tools, or using script...seeing running 1 by one open each drawing and wasting user time..
some use ODBX who I think is good but limited.
there is my contribution...
Why not using PUBLISH ?
yes,...you can do it what ever you want with PUBLISH !
PUBLISH open each drawing before printing...
so if you put your LISP on the SuitCase it will RUN !
ex:
Lisp Code:Code: [Select](close (open (strcat "C:\\" (getvar 'dwgname) ".txt") "w"))
Put this Lisp in your Application SuitCase Startup.
and run Publish with any configuration you want.
I use DWF options to prevent wasting Paper print.
so the process its simple...
before runing your Lisp,.
1) add you LISP in the suitcase
2) make a publish
3) remove your lisp from the suitcase.
that's all.
the only problem is if a drawing is already opened, It can't be saved,.
:ugly:
we can ssget, leave current save version... no changes to date file, that's sick... :o
fantastic Andre
is someone noticed that before ?!
kruugerCode: [Select](setq fd (open (strcat "d:\\" (getvar 'dwgname) ".txt") "w"))
(write-line (itoa (sslength (setq ss (ssget "_X" '((0 . "INSERT")))))) fd)
(vla-delete (vlax-ename->vla-object (ssname ss 0)))
(close fd)
addendum #1From a few hours I'm trying to figure out if the command "pubblish" can be a solution to replace AutoCAD scripts for 64bit versions (see my message): http://www.theswamp.org/index.php?topic=43869.msg491387#msg491387
DRAWINGS CAN ALSO BE SAVED !! :)
Now you can Purge, insert block, create entity...well..and make (vl-cmdf "._qsave")
[DWF6Sheet:01186-Model]
DWG=E:\__Temp\DwgSmall\01186.dwg
Layout=Model
[DWF6Sheet:01187-Model]
DWG=E:\__Temp\DwgSmall\01187.dwg
Layout=Model
[DWF6Sheet:01188-Model]
DWG=E:\__Temp\DwgSmall\01188.dwg
Layout=Model
[DWF6Sheet:01194D-Model]
DWG=E:\__Temp\DwgSmall\01194D.dwg
Layout=Model
[DWF6Sheet:01194S-Model]
DWG=E:\__Temp\DwgSmall\01194S.dwg
Layout=Model
[Target]
Type=2
and run -pubblish (command line version) I can process dwg files without print any file.other question:It's saved in the registry: HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\[Revision]\[Version]\Profiles\[CurrentProfile]\Dialogs\Appload\Startup\
q4) how can I add, by program, a Lisp file in Application SuitCase Startup?
n1) if I run in background the process is more slow and one time i saw x64VBAServer18.exe runningOld problem, since 2005 it's been something to avoid like the plague. Background plot/publish has always been this slow, not to mention error prone. Ensure BackgroundPlot is not set to 2 or 3 - actually I set mine to 0 so plots are also in the foreground.
there is my contribution...Awesome Andrea!
Why not using PUBLISH ?
As for the Measurement thing, that does sound like a BIG problem. I'd also like to know what to do about this.Thanks for your response!
Thanks for your response!I haven't yet tried changing my Measurement setting, mine is constantly on 1 because I'm using metric systems - thus the ISO stuff are my defaults. Not to mention, ACad is now mostly turned off on my PC - I'm using Revit for around 95% of all my drawing stuff.
OK about Backgroundplot = 0!
Have you tried to process files with Measurement = 0 and = 1?
What do you think about the use of -pubblish (command line version) and minimal DSD file
only for process without print?
Is there documentation for DSD files?
Thanks again.
DSD files are probably not too dificult to understand (i.e. reverse engineer), but I cannot find any documentation regarding their structure. Closest I came to is a sample C# which saves a DSD file: http://adndevblog.typepad.com/autocad/2012/05/how-to-use-the-autodeskautocadpublishingpublisherpublishdsd-api-in-net.html (http://adndevblog.typepad.com/autocad/2012/05/how-to-use-the-autodeskautocadpublishingpublisherpublishdsd-api-in-net.html) Though that is simply using the API's methods to save the file, doesn't help in showing how the file is structured.Interesting, maybe I can come up with something.
The only issue I can see (if such non-plotting DSD file works) would be that you'd need to create a dialog (or such) to allow the user to select files and/or folders to run through. This is not needed if you use Publish's own dialog.For me this is not a problem, I have a much more comprehensive selection method with a choice of folders and subfolder, files in folders or files in different folders and save on file the selection mode it for future reuse.
Now I'll try if Bricscad Publish works the same way.
;;; batch process drawings, currently hard coded purge routine only
(defun C:ABCBatch (/ files dwgpath plotTabs dwgTabs parts drive path name pdffile layoutName appendLayoutName message );dwgpath drive path name pdffile )
;; check for default Batch paths
(if (and (not ABC_BatchDir)
(not (setq ABC_BatchDir (getenv "ABC_BatchDir"))))
(setq ABC_BatchDir (getvar "dwgprefix"))
) ;_if
;; check for default Batch tabs
(if (and (not ABC_BatchDefaultTabs )
(not (setq ABC_BatchDefaultTabs (getenv "ABC_BatchDefaultTabs"))))
(setq ABC_BatchDefaultTabs "Last Used")
) ;_if
;; select drawings
(setq files (dos_getfilem "Select files to process" ABC_BatchDir "Drawing Files (*.dwg)|*.dwg"))
(setq dwgpath (car files))
;; remember batch plot path
(setq ABC_BatchDir dwgpath)
(if dwgpath (setenv "ABC_BatchDir" dwgpath))
(if files (setq plotTabs (dos_combolist "Batch Process" "Select Layout Tabs to Plot (wildcards accepted)" '("Model" "Paper Space" "All" "Last Used" "30x42" "24x36" "11x17" ) ABC_BatchDefaultTabs )))
;; remember default tabs
(setq ABC_BatchDefaultTabs plotTabs)
(if plotTabs (setenv "ABC_BatchDefaultTabs" plotTabs))
;; do exporting
(if (and files plotTabs )
(progn
(foreach dwgfile (acad_strlsort (cdr files))
(if (not ABCdebug)(setvar "cmdecho" 0))
(princ (strcat "\nOpening " dwgfile))
;;; turn off ABC commands
(setenv "ABC\\BatchMode" "1")
;;;
(command ".open" (strcat dwgpath dwgfile))
;;; turn on ABC commands
(setenv "ABC\\BatchMode" "0")
(setq parts (dos_splitpath (strcat (getvar "dwgprefix")(getvar "dwgname")))
drive (car parts)
path (cadr parts)
name (caddr parts)
pdffile (strcat drive path name )
) ;setq
;; if all - get list of all tabs & Model
(if (= "All" plotTabs) (setq dwgTabs (append '"Model" (layoutlist))))
;; if paper - get just layout tab names
(if (= "Paper Space" plotTabs) (setq dwgTabs (layoutlist)))
;; last used, use current layout
(if (= "Last Used" plotTabs) (setq dwgTabs (list (ABC_Get_CLayout))))
;; if name given, use matching layouts - accepts wildcards
(if (not dwgTabs) (setq dwgTabs (member_wc plotTabs (layoutlist))))
;; if no tab list made from above, record error
(if (not dwgTabs) (setq message (strcat message "\n" (getvar "dwgname") " - FAILED - no layout named " plotTabs)))
;(alert (foreach x dwgTabs (strcat x "\n")))
(foreach layoutName dwgTabs
(command "layout" "set" layoutName )
(if ABCdebug (princ "\n1"))
(if (and
(/= (getvar "cvport") 1)
(/= "Model" (ABC_Get_CLayout))
) ;_and
(command "_.pspace")
) ;_if
(if ABCdebug (princ "\n2"))
;;; =======================================
;;; DO WORK
;;; =======================================
(c:ABCaudit)
(c:pb)
(command ".qsave")
;(command "-xref" "detach" "*")
;(command "qsave" ".close")
;(command ".open" (strcat dwgpath dwgfile))
;(c:ABCaudit)
;(c:pb)
;(c:ABCaudit)
;;; =======================================
(if ABCdebug (princ "\n3"))
;(setq message (strcat message "\n" (getvar "dwgname") " - layout " layoutName " - processed" ))
) ;_foreach
(if (/= 0 (getvar "dbmod")) ;check if drawing modified
(command ".close" "n")
(command ".close")
)
(setvar "cmdecho" 1)
) ;_foreach
;; echo results
;(if ABC_htmlMessage (ABC_htmlMessage "Batch" message) (alert message))
) ;_progn
) ;_if
(princ)
)
Bricscad seems to be easier to batch as one drawing can run a lisp to process multiple files, unlike autocad. Here is my code that works in Bricscad v13. Note I didn't include any lisp subroutines called, just providing to show how it works.Thanks for your code and info. I know "Bricscad Lisp Engine" before it was incorporated into Bricscad and it seem I use a similar method to your.
Note Bricscad can be fussy, often crashes after batch, and sometimes hangs, so use with caution and test on a small # of files first. I do have a similar batch plot/export to PDF routine that works very well so far.I'm also using version V14 and I have to say that for a while time processing of files is fairly stable.
Bk0 = Backgroundplot = 0
Bk2 = Backgroundplot = 2
Min:Sec
---------------------------------------------------------------
AutoCAD Bricscad
Bk0 Bk2 Bk0 Bk2
Script_OpenSave : 1:45 --- 1:00 ---
_Pubblish_OpenSave: 1:59 --- 50 46
Script_OpenOnly : 35 --- --- 30
_Pubblish_OpenOnly: 58 --- 1:25 26
there is my contribution...Awesome Andrea!
Why not using PUBLISH ?
BTW, why use the Startup Suite? Is it simply to avoid problems with the ACadDoc.LSP file? I'd have thought it might even be easier to simply rename the old existing ACadDoc.LSP (if it exists) then create a new temporary one which loads the renamed one (as well as your lisp), then runs the publish command so the user can select the files, and after publish completes delete the temporary ACadDoc and rename the old one back.
In "NoPubblish" folder there are files that have not been processed by AutoCAD.same here. don't know why but some files are not processed with publish :(
In "NoPubblish" folder there are files that have not been processed by AutoCAD.same here. don't know why but some files are not processed with publish :(
k.
Ciao Marc'Antonio..
are you using the script with publish ?
Ciao Marc'Antonio..
are you using the script with publish ?
No... "I have abandoned this route because it is slowest of the script and Bricscad I always print all the files..."
Now I use scripts.
Ciao.
Gracie !The best way for me is (was :realmad: ):
my guess is "_.VBASTMT" isn't working in higher acad versionit works, but:
So if I use VBASTMT in >= 2010 I need to load VBAsee: http://www.theswamp.org/index.php?topic=43869.msg491387;topicseen#msg491387 and others...
(x64VBAServer.exe on 64 bit) and *everything* runs 6-8x slower,
including AutoCAD commands! It is much true particularly if you
must use many commands inside of the Lisp function.
Then I need to close AutoCAD to restore previous speed.
this bug as been fixed in our offices by reinstalling MSOffice 64bits.thank you, will try this solution
just let you know...