
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So my most recent adventure into lisp / scripting I'm trying to automate the following process. We have about 5-20 files we run these operations on daily. The below process process repeats for the files that we've worked on that day.
Here's what I have so far in my lsp.
(setq cpath (getvar "dwgprefix")); get current drawing path (setq subfolder "subfolder_we_save_to"); passing subfolder name (setq newpath (strcat cpath subfolder)); add the new sub-folder to the end of the current path (command "saveas" "" (strcat newpath "\\" (getvar "dwgname"))"_Yes"); saveas with new path and existing dwg name (command "xref" "U" "*"); unload xrefs (command "purge" "A" "*" "n"); purge (command "plan" "W"); planview (command "zoom" "E"); zoom to extents (command "ucs" "V"); set ucs to view (command "filedia" "0" "nwcout" (strcat (getvar 'DwgPrefix) (vl-filename-base(getvar 'DwgName))) "filedia" "1"); nwcout as same file name in same folder
here's my script.
(load "my.lsp") _.qsave _.close (open "next_file.dwg") (load "my.lsp") _.qsave _.close (open "next_file.dwg") (load "my.lsp") _.qsave _.close
because we have fabrication parts, and when you open the file it asks about the database to use, and credentials - I am opening the first file in the list of files, and selecting the database/login info then executing the script that starts by loading the lisp file, saving, and closing.
The problem is that after the NWCOUT the drawing doesn't close, and the next one doesn't open. It seems that the lisp executes / ends cleanly - although I'm not really sure.
EDIT - Here's the command window after running the script that executes the lisp.
Command: SCR SCRIPT Command: (load "my.lsp") saveas Current file format: AutoCAD 2013 Drawing Enter file format [R14(LT98<97)/2000(LT2000)/2004(LT2004)/2007(LT2007)/2010(LT2010)/2013(LT2013)/Standards/DXF/Template] <2013>: Save drawing as <C:\...\test_1.dwg>: C:\...\test_1.dwg A drawing with this name already exists. Do you want to replace it? <N> _Yes Command: xref Current project path: BEND SWIP Enter an option [?/Bind/Detach/Path/pathType/Unload/Reload/Overlay/Attach] <Attach>: U Enter xref name(s) to unload: * No matching and loaded xref names found. Command: purge Enter type of unused objects to purge [Blocks/DEtailviewstyles/Dimstyles/Groups/LAyers/LTypes/MAterials/MUltileaderstyles/Plotstyles/SHapes/textSTyles/Mlinestyles/SEctionviewstyles/Tablestyles/Visualstyles/Regapps/Zero-length geometry/Empty text objects/Orphaned data/All]: A Enter name(s) to purge <*>: * Verify each name to be purged? [Yes/No] <Y>: n No unreferenced blocks found. No unreferenced layers found. No unreferenced linetypes found. No unreferenced text styles found. No unreferenced shape files found. No unreferenced dimension styles found. No unreferenced mlinestyles found. No unreferenced plotstyles found. No unreferenced table styles found. No unreferenced materials found. No unreferenced visual styles found. No unreferenced multileader styles found. No unreferenced groups found. No unreferenced Detail view styles found. No unreferenced Section view styles found. Command: plan Enter an option [Current ucs/Ucs/World] <Current>: W Regenerating model. Command: zoom Specify corner of window, enter a scale factor (nX or nXP), or [All/Center/Dynamic/Extents/Previous/Scale/Window/Object] <real time>: E Command: ucs Current ucs name: *WORLD* Specify origin of UCS or [Face/NAmed/OBject/Previous/View/World/X/Y/Z/ZAxis] <World>: V Command: filedia Enter new value for FILEDIA <1>: 0 Command: nwcout File name <test_1.nwc>:C:\...\test_1 C:\...\test_uploads3\test_1.nwc Command: filedia Enter new value for FILEDIA <0>: 1 Command:
Thanks for the help!
Shane
Solved! Go to Solution.