Add a layout

Discussion in 'AutoCAD' started by hulioman, Dec 13, 2004.

  1. hulioman

    hulioman Guest

    I have used ObjectDBX to grab a Layout object from a drawing (not the drawing I am currently using).
    Through Lisp, how do I add this object to the current drawing? (or is this possible?")
     
    hulioman, Dec 13, 2004
    #1
  2. hulioman

    perriwinkle Guest

    (command "-Layout" "template" "file name" "layout name")
     
    perriwinkle, Dec 13, 2004
    #2
  3. hulioman

    hulioman Guest

    I am trying to figure it out by using vlisp without using commands. This is a specific example, but in the future I may want to add other objects (for example PlotConfigurations).
     
    hulioman, Dec 13, 2004
    #3
  4. hulioman

    T.Willey Guest

    It is possible, but you need to add it to a current layout tab. In essence you are copying properties. Is this what you want, or is there something you want to do?

    Tim
     
    T.Willey, Dec 13, 2004
    #4
  5. hulioman

    Jeff Mishler Guest

    Here's some code from a routine I wrote last year to do this. Since you
    already have the ODBX stuff I'm only posting the actual layout
    portion....WARNING, this was written for my own use and removes tabs named
    Layout1 & Layout2 from the current drawing. Modify the code if this is not
    something you want to occur.

    Code:
    (vla-open oDBX source);; "opens" source for our use
    (setq lays (vla-get-layouts oDBX));; source layout table
    (if (> (vla-get-count lays) 1);;ensure there are layouts to import
    (progn
    (vlax-for x lays ;; cycle thru table & check if name
    ;; exists in this drawing, omit if so
    (if (not (or (= "Model" (vla-get-name x))
    (member (vla-get-name x) (layoutlist))))
    (setq l_list (append (list x) l_list ))
    );if
    );for
    (setvar "ctab" "Model")
    (foreach x (layoutlist)
    (cond ((= x "Layout1")(vla-delete (vla-item (vla-get-layouts doc)
    x)))
    ((= x "Layout2")(vla-delete (vla-item (vla-get-layouts doc) x)))
    )
    )
    (if l_list
    (progn
    (setq l_import (vlax-safearray-fill
    (vlax-make-safearray vlax-vbObject
    (cons 0 (- (length l_list) 1))
    ) l_list)
    );; create safearray for use in ActiveX method
    (vla-copyobjects oDBX l_import (vla-get-layouts doc))
    (princ (strcat "\nLayouts imported successfully: "
    (itoa (length l_list))))
    ;;import the layouts
    );progn
    (princ "\No new layouts to import from the source drawing...")
    );if
    );progn
    (princ "\nSorry, no layouts found in source drawing, try again.")
    );if
    (vlax-release-object oDBX);; we're done with it
    
     
    Jeff Mishler, Dec 14, 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.