Trying to copy viewports and save layers states

Discussion in 'AutoCAD' started by Daniel J. Ellis, Mar 3, 2004.

  1. Hey guys wonder if you can help,

    I'm working on a set of drawings for a housetype that includes a number
    alternative elevational treatments on a single model-space ele.

    In my viewports I have various layers set as "freeze in this viewport"
    to allow me to select the elevation I want. I now need to copy these
    viewports onto a separate viewport to c reate some planning drawings.

    When I do this, most, not all, of the layers become un-frozen.
    Obviously this situation leaves me having to repeat work. I'm sure that
    there is a way round this - does anybody know it?

    Thanks in advance,
    DJ
     
    Daniel J. Ellis, Mar 3, 2004
    #1
  2. ?
     
    Michael Bulatovich, Mar 3, 2004
    #2
  3. Sorry, layout


     
    Daniel J. Ellis, Mar 3, 2004
    #3
  4. Daniel J. Ellis

    Jeff Mishler Guest

    Yep,
    Here's a lisp to save the layer states (vp related) and then another to
    put them in another vp. Only works in the same drawing session....

    Jeff

    ;;;*********code starts here************
    ;| Functions to copy, and later place, the fozen layers from one
    paperspace viewport to another. Works with both standard and
    polygonal viewports.
    This was created for use in one drawing at a time! The layers
    obtained with the copyvplayers function are not saved for use
    in another drawing or even another editing session.

    Command: copyvplayers - creates the variable "laylist", if you
    think that the routine isn't working, check the value of this
    variable at the command line like this: Command: !laylist
    If this returns nil then the list hasn't been saved.

    Command: putvplayers - freezes the layers obtained with
    copyvplayers in the selected viewport. If you want the 2 viewports
    to match exactly, make sure to reset the layers in the target
    viewport first.

    (c) Jeff Mishler, June 2003 - Updated Jan. 2004 to work with
    Acad2004.
    |;

    (defun c:copyvplayers (/ obj)
    (if (setq obj
    (entsel "\nSelect viewport to save layer data for: "))
    (progn
    (setq obj (entget (car obj))
    laylist nil)
    (if (and
    (= (cdr (assoc 0 obj)) "LWPOLYLINE")
    (setq vptest (member '(102 . "{ACAD_REACTORS") obj))
    (setq vptest (member '(102 . "}") (reverse vptest)))
    (assoc 330 vptest)
    )
    (setq obj (entget (cdr (assoc 330 vptest))))
    )
    (if (and
    (= (cdr (assoc 0 obj)) "VIEWPORT")
    (setq objlist
    (cdr (car (cdr (assoc -3
    (entget
    (cdr
    (assoc -1 obj))(list "acad")))))))
    (assoc 1003 objlist)
    )
    (progn
    (foreach x objlist
    (if (= (car x) 1003)
    (setq laylist (cons (cdr x) laylist))
    )
    )
    (setq laylist (reverse laylist))
    )
    (princ
    (strcat "\nInvalid Viewport entity {"
    (cdr (assoc 0 obj))
    "} selected, or VP has no frozen layers, try again..."))
    )
    )
    )
    (princ)
    )

    (defun c:putvplayers (/ tempstr int smallstr vpent)
    (if laylist
    (progn
    (setq tempstr "")
    (foreach x laylist
    (setq tempstr (strcat tempstr x ","))
    )
    (setq tempstr (substr tempstr 1 (- (strlen tempstr) 1)))
    (setq oldecho (getvar "cmdecho"))
    (setvar "cmdecho" 0)
    (command "_undo" "_be")
    (while (not vpent)
    (setq vpent (entsel "\nSelect Viewport object: "))
    )
    (setq vpent (car vpent))
    (while (> (strlen tempstr) 256)
    (setq smallstr (substr tempstr 1 256))
    (setq int (vl-string-position (ascii ",") smallstr 0 t))
    (setq smallstr (substr smallstr 1 int)
    tempstr (substr tempstr (+ int 1))
    )
    (command "vplayer" "f" smallstr "s" vpent "" "")
    )
    (command "vplayer" "f" tempstr "s" vpent "" "")
    (command "_undo" "_end")
    (setvar "cmdecho" oldecho)
    );progn
    );if
    (princ)
    )
    ;;;*********code ends here************
     
    Jeff Mishler, Mar 3, 2004
    #4
  5. That'a amazing, thankyou very much indeed.


    DJE
     
    Daniel J. Ellis, Mar 3, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.