+ Reply to Thread
Results 1 to 10 of 10
  1. #1
    Junior Member SpeakNoEvil's Avatar
    Computer Details
    SpeakNoEvil's Computer Details
    Operating System:
    XP
    Using
    AutoCAD 2007
    Join Date
    Jan 2010
    Location
    Washington, DC
    Posts
    17

    Drawing "Smart Close" MACRO - Suggestions and Help

    Registered forum members do not see this ad.

    Hello all,

    You've given such outstanding help in the past, I'm optimistic that this will be easily solvable as well. I wrote a "Smart Close" MACRO to automatically perform some cleanup/tidying steps before a file is closed. (The goal is to help other engineers in my department get more clean and consistent with their files.) Specifically, you click the button and it executes the MACRO

    ^C^C_TILEMODE;0;_AUDIT;Y;_-LA;S;0;;_Z;E;_LWDISPLAY;ON;_VISRETAIN;1;_MVIEW;L;O N;ALL;;_qsave;_close;

    Which:
    • Switches to Paperspace
    • Runs an Audit
    • Sets the current layer to 0
    • Zooms to the extents of the page
    • Turns the lineweight display on
    • Saves the on/off visibility settings for all layers
    • Locks all viewports
    • Saves the sheet
    • Closes the sheet

    Admittedly, I'm a bit new at MACROS, so my formatting may be a bit unorthodox. It works great though, and I tend to use it in place of my usual close button.

    FIRST: does anyone have any suggestions for other things to add to the list?

    SECOND: I'm having a small problem with it. If there aren't any viewports in Paperspace for a particular file, it hiccups at the "lock viewports" part and exits out of the MACRO - leaving me to manually save and close.

    Any suggestions on how to make it run smoothly regardless of the presence/absence of viewports? I'm fairly sure you could solve this in LISP, but I don't know any LISP and I feel like the amount of work to turn it to a LISP code is substantially more than the work of just saving and closing manually. (I even made a separate MACRO to do that in one step too.) Any suggestions on a fix to the hiccup? Please let me know, and thank you in advance!

    TC

  2. #2
    Full Member Nardino's Avatar
    Using
    AutoCAD 2011
    Join Date
    May 2010
    Location
    New York, USA
    Posts
    82

    Default

    ^C^CZ;E;-purge;all;*;n;audit;y;-purge;all;*;n;-overkill;all;;;


    try this

  3. #3
    Junior Member SpeakNoEvil's Avatar
    Computer Details
    SpeakNoEvil's Computer Details
    Operating System:
    XP
    Using
    AutoCAD 2007
    Join Date
    Jan 2010
    Location
    Washington, DC
    Posts
    17

    Default

    Thanks for the response, Nardino! I've done a manual routine like that before, but in this case I'm shooting for something a little less destructive. A lot of things get deleted in that process, and since it all happens at once, then saves and closes, there's no opportunity for an undo button - and I'd like the changes to be reversible.

    I may make a new routine for that set of tasks separately, though.

  4. #4
    Full Member Nardino's Avatar
    Using
    AutoCAD 2011
    Join Date
    May 2010
    Location
    New York, USA
    Posts
    82

    Default

    actually in this little script i enclosed, there is no save command in there, leaving it up to you to decide if you should save or not. i have used it many times without any problems.

  5. #5
    Full Member kevinp's Avatar
    Computer Details
    kevinp's Computer Details
    Operating System:
    XP Pro SP3
    Motherboard:
    Gigabyte DS3L
    CPU:
    Q8200
    RAM:
    4GB
    Graphics:
    HD3850 modded to FireGL V7700
    Primary Storage:
    WD 250GB
    Monitor:
    2x Acer x223w
    Using
    AutoCAD 2012
    Join Date
    Jan 2009
    Location
    Storrs, CT
    Posts
    45

    Default

    I have almost the same exact macro (im stealing the lock viewport bit - I LIKE!), but I add in addition:
    -scalelistedit;reset;yes;exit;

    because when we insert some xrefs and blocks we get hundreds of xrefed scales listed, and this cleans it up and makes it a bit nicer. Very quick to run the command too.

  6. #6
    Full Member T704's Avatar
    Computer Details
    T704's Computer Details
    Operating System:
    XP PRO
    Computer:
    DELL DIMENSION
    Monitor:
    DUO DELLs
    Using
    Land Desktop 2002
    Join Date
    Dec 2009
    Location
    LAREDO, TEXAS
    Posts
    42

    Default

    I like this would like to use here in our office..... however don't know how to run much less install a Macro.

  7. #7
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,041

    Default

    Quote Originally Posted by T704 View Post
    don't know how to run much less install a Macro.
    You don't have to install it - just create a new button on your toolbars and paste the code above under Macro field.

    Regards

  8. #8
    Junior Member SpeakNoEvil's Avatar
    Computer Details
    SpeakNoEvil's Computer Details
    Operating System:
    XP
    Using
    AutoCAD 2007
    Join Date
    Jan 2010
    Location
    Washington, DC
    Posts
    17

    Default

    T704,

    Don't worry, it's pretty easy, actually. Here's a video showing how to do it; the interface is in Russian, but it's still straightforward.

    http://s004.radikal.ru/i205/1001/e0/7bdeb274a818.gif

    The gist of it is this:
    Go into CUI
    Click “new” under Command List
    Give your new command a title (e.g. Smart Close), and paste the Macro above into the Macro field. Give it an icon by selecting from the library.
    Choose the toolbar where you want it to go and drag the command from the command list (bottom left) to the tool.

    Here's a good intro if you want to try making your own; there's probably a great overview here on CADTutor as well, no doubt.
    http://www.cadalyst.com/cad/autocad/...o-madness-3181

  9. #9
    Full Member T704's Avatar
    Computer Details
    T704's Computer Details
    Operating System:
    XP PRO
    Computer:
    DELL DIMENSION
    Monitor:
    DUO DELLs
    Using
    Land Desktop 2002
    Join Date
    Dec 2009
    Location
    LAREDO, TEXAS
    Posts
    42

    Default

    AS always .............Thanks Again Guys!!

  10. #10
    Junior Member SpeakNoEvil's Avatar
    Computer Details
    SpeakNoEvil's Computer Details
    Operating System:
    XP
    Using
    AutoCAD 2007
    Join Date
    Jan 2010
    Location
    Washington, DC
    Posts
    17

    Drawing Smart Close / Smart Clean MACRO

    Registered forum members do not see this ad.

    Thought I'd update everyone, in case you wanted to use the code. I've added one more handy function that was kind of a pain to make; the "Smart Close" now also selects all the viewports in the drawing and sets them to my standard viewport layer. The added script is in bold.

    ^C^C_TILEMODE;0;_AUDIT;Y;_-LA;S;0;;_-COLOR;BYLAYER;-linetype;set;bylayer;;_Z;E;_LWDISPLAY;ON;_VISRETAI N;1;_ssx;;e;viewport;;-ch;p;;p;la;"SE VIEWPORT";;_qsave;_close;

    I've also created a similar function called "Smart Clean," which does everything the Smart Close does, regens and keeps the file open instead of closing it.

    ^C^C_TILEMODE;0;_AUDIT;Y;_-LA;S;0;;_-COLOR;BYLAYER;-linetype;set;bylayer;;_Z;E;_LWDISPLAY;ON;_VISRETAI N;1;_ssx;;e;viewport;;-ch;p;;p;la;"SE VIEWPORT";;_RE;_QSAVE;

    You'll want to change the "SE VIEWPORT" to the name of the layer you want viewports on, of course.

    It uses a function called SSX, which I find very handy but somewhat disconcerting. Does anyone else know about this "hidden selection set" it creates? Am I tampering with forces greater than I understand by using it? Can I clear it somehow?

    Hope these help!

Similar Threads

  1. Macro for "clicking" OK in dialogue
    By rustysilo in forum AutoLISP, Visual LISP & DCL
    Replies: 18
    Last Post: 27th Dec 2012, 10:52 pm
  2. creating "align" command (lsp or macro in 2009 LT
    By furnituredziner in forum AutoCAD Beginners' Area
    Replies: 7
    Last Post: 8th Mar 2010, 04:10 pm
  3. Replies: 1
    Last Post: 25th Nov 2009, 06:35 pm
  4. writting a macro for a "D" loop
    By Jfall in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 17th Mar 2008, 01:06 pm
  5. macro to plot multiple "pages" to pdf
    By wmw99a in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 8th Jan 2008, 06:59 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts