Layout Question

Discussion in 'AutoCAD' started by Mark Douglas, Jan 9, 2004.

  1. Mark Douglas

    Mark Douglas Guest

    Does anyone know the bit of code to retrieve all the Layout names in a
    Drawing? I want my code to insert a block on every layout tab in my drawing
    at 0,0. And then explode it?

    Thanks if anyone has a quick little code

    Mark
     
    Mark Douglas, Jan 9, 2004
    #1
  2. Mark Douglas

    Mark Douglas Guest

    Ok how do i make it activate each layout tab so I can insert a block on each
    one?
    Mark
     
    Mark Douglas, Jan 9, 2004
    #2
  3. Mark Douglas

    Jeff Mishler Guest

    (setvar "ctab" "tabUwantCurrent")

    HTH,
    Jeff

     
    Jeff Mishler, Jan 9, 2004
    #3
  4. One way would be:

    (foreach x (layoutlist)
    (setvar "ctab" x)
    (command ".insert" ......)
    )

    You might watch out for (layoutlist) returning "Model".
    Sometimes it does other times it doesn't (was/is a bug)

    Or you could try and use activeX methods so you don't
    have to switch to each tab.
     
    Jason Piercey, Jan 9, 2004
    #4
  5. Mark Douglas

    Jaime Guest

    (defun C:blahb ()
    (setq blah (layoutlist))
    (setq ctr 0)
    (while (/= (nth ctr blah) nil)
    (princ (nth ctr blah))
    (setq ctr (1+ ctr))
    )
    )

    something kinda like this?
     
    Jaime, Jan 9, 2004
    #5
  6. Mark Douglas

    Jaime Guest

    nm..i forgot about the foreach function :\

    Jaime
     
    Jaime, Jan 9, 2004
    #6
  7. Mark Douglas

    Mark Douglas Guest

    Thanks Guys, I got it to work with a few modifications....Works great and
    saves a lot of time!!
    Mark
     
    Mark Douglas, Jan 9, 2004
    #7
  8. Mark Douglas

    Jeff Mishler Guest

    Here's a quick 'n dirty vla- way. No jumping from tab to tab.

    BTW, Mark......do you work for the MKM in Santa Rosa, Calif.? If so,
    tell Larry & Jeff I said "Hi!", I used to work with them many moons ago.

    HTH,
    Jeff

    ;;;Insert a block into all PaperSpace Layout Tabs,
    ;;;all at 0,0,0 & 0 deg. rotation
    ;;;by Jeff Mishler, January 2004

    (defun c:ins2tabs ( / lays bname blk newblk)
    (setq lays (vla-get-layouts
    (vla-get-activedocument
    (vlax-get-acad-object)))
    bname (getstring "\nBlock to insert in all Layouts?: ")
    )
    (if (not (tblsearch "block" bname))
    (progn
    (princ "\nBlock not found, please select block: ")
    (setq bname
    (getfiled "Block Selection for Tab Insert" bname "dwg" 0))
    )
    )
    (vlax-for x lays
    (if (not (= "Model" (vla-get-name x)))
    (progn
    (setq blk (vla-get-block x)
    newblk (vlax-invoke-method
    blk
    'insertblock
    (vlax-3d-point
    '(0.0 0.0 0.0))
    bname 1.0 1.0 1.0 0.0))
    ;;; (vla-add (vla-get-layouts
    ;;; (vla-get-activedocument
    ;;; (vlax-get-acad-object))) "Title")
    ;;; (vla-put-layer newblk "Title")
    ;;; uncomment above to place on layer other than the current one
    (vla-explode newblk);;comment this if not exploding
    (vla-delete newblk);;comment this if not exploding
    )
    )
    )
    (princ)
    )
     
    Jeff Mishler, Jan 9, 2004
    #8
  9. Mark Douglas

    Mark Douglas Guest

    Yup I work here with Larry and Jeff, I'll let them know you said Hi!!
    And also Thanks for the help
    Mark
     
    Mark Douglas, Jan 9, 2004
    #9
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.