Jump to content

Multiple Drawing Titleblock on one tab


pBe

Recommended Posts

I'm having a problem on how to start this routine

I have a drawing with mulitple drawing titles on one layout

 

Like this

Multiple sheets.png

 

Annotations were done on paperspace.

I need to separate these into its own layout tab on the same drawing

Create layout, 3 more on this example

Go thru every tab and delete 3 of the four for every tab.

 

Will that work?

 

There are close to 2000 of these drawings

 

Any ideas?

Link to comment
Share on other sites

That sounds like an absolute nightmare. Your approach above does sound the 'best' though

- duplicate the file, then in the new file copy each layout an additional 3 times then delete all the relevance areas (a, b, c, d) on each of the , then resize the page layout

 

Is every sheet setup with the same papersize or does it vary between drawings?

Link to comment
Share on other sites

Consider using the Add Method on the Layouts Collection, then use the CopyObjects Method to place the appropriate items on the newly created Layout (perhaps the Move Method will be required?), followed by the Delete Method for the objects copied (from the original Layout).

 

Edit - I would make a void copy of the drawing *FIRST* (using vl-file-copy) before taking any action(s), let alone using the Save / SaveAs Methods!

Link to comment
Share on other sites

That sounds like an absolute nightmare. Your approach above does sound the 'best' though

- duplicate the file, then in the new file copy each layout an additional 3 times then delete all the relevance areas (a, b, c, d) on each of the , then resize the page layout

 

Is every sheet setup with the same papersize or does it vary between drawings?

 

Fortunately the papersize are all the same for a particualr drawing

which means,if B-size Tblock the rest are B-size for that single drawing.

 

Another thing is, some layout may have as many as 10 Tblocks, (9 more layout tab)

 

I cant imagine how to start writing the code for this. Thought of using ODBX, but then again. i may need to select a window thru ssget which is a no-no for ODBX

 

Oh well :) I'll keep digging

 

Thanks Dink87522

Link to comment
Share on other sites

Fortunately the papersize are all the same for a particualr drawing

which means,if B-size Tblock the rest are B-size for that single drawing.

 

Another thing is, some layout may have as many as 10 Tblocks, (9 more layout tab)

 

Since all of the sizes are the same (per drawing), this provides you the conditional filter you need for pre-determined dimensions, distances, etc. in your routine(s).

 

I cant imagine how to start writing the code for this. Thought of using ODBX, but then again. i may need to select a window thru ssget which is a no-no for ODBX

 

I've already provided you a starting point, in the listed functions from my earlier post.

 

There are two ways to do this via Visual LISP - with, or without ODBX. Regardless, you need a working function first.

 

That said, the vlax-for method will be necessary to step through the Layout's Block Object in the with option, whereas ssget "_x" can be used in the without option.

 

I'd suggest that you write a function that works without ODBX first, because it's going to be simpler, and permits the usage of commands.

Link to comment
Share on other sites

Since all of the sizes are the same (per drawing), this provides you the conditional filter you need for pre-determined dimensions, distances, etc. in your routine(s).

 

 

 

I've already provided you a starting point, in the listed functions from my earlier post.

 

There are two ways to do this via Visual LISP - with, or without ODBX. Regardless, you need a working function first.

 

That said, the vlax-for method will be necessary to step through the Layout's Block Object in the with option, whereas ssget "_x" can be used in the without option.

 

I'd suggest that you write a function that works without ODBX first, because it's going to be simpler, and permits the usage of commands.

 

Will comply. Thanks Renderman

Link to comment
Share on other sites

Heres a draft:

 

(defun SepLayout (blkname / adoc LayoutColl pt_list NewLayoutTab space ObjToMove safObjects MoveToLayout)
(vl-load-com)
(cond ((and
  (setq adoc (vla-get-activedocument (vlax-get-acad-object)))
       (= (vla-get-activespace adoc) 0)
  (= (vla-get-count (setq LayoutColl (vla-get-layouts adoc))) 2)
  (vlax-for
     objs (vla-get-paperspace adoc)
    (cond
      ((and
         (eq (vla-get-objectname objs) "AcDbBlockReference")
         (eq (vla-get-name objs) blkname)
         (setq pt_list
            (cons
              (vlax-safearray->list
                (variant-value
                  (vlax-get-property objs 'insertionpoint)
                )
              )
              pt_list
            )
         )
       )
      )
    ) T
  )
(repeat (setq i (1- (length pt_list)))
 (vla-add LayoutColl (setq NLNAme (strcat "NLayout " (itoa (setq i (1- i)))))
          )
   (setq NewLayoutTab (cons NLNAme NewLayoutTab ))
  )
(foreach SpaceToMove NewLayoutTab
   (setq space (vla-item LayoutColl SpaceToMove))
   (ssget "_W"  (car pt_list) 
(mapcar '+ (car pt_list) '(36.0 24.0)))[color=blue];<---size of Tblock[/color]
   (vlax-for x (setq ObjToMove (vla-get-activeselectionset aDoc))
           (setq MoveToLayout (cons x MoveToLayout)))
   (vla-delete ObjToMove)
 (vla-CopyObjects ADoc
          (vlax-make-variant
            (vlax-safearray-fill
              (vlax-make-safearray
                vlax-vbObject
                (cons 0 (1- (length MoveToLayout)))
              )
              MoveToLayout
            )
          )
          (vla-get-block space)
        )
 (foreach O MoveToLayout (vla-delete O))
   (setq pt_list (cdr pt_list) MoveToLayout nil)
    )
   )
      )
 )
)

Usage: (SepLayout "Blockname")

 

 

One question, it copies the entities selected except the viewport object.

Why is that?

Link to comment
Share on other sites

Hi pBe,

 

Give this a try, change the name of the Titleblock accordingly (in red):

 

(defun c:LayoutCutter
  
 ( / *error* _StartUndo _EndUndo _UniqueKey
     acdoc aclay aclyo acpvp blockobject blockselection bname i j lowerleft newlayout subselection upperright
 )
 (vl-load-com)
 ;; © Lee Mac 2011

 (setq bname [color=red]"Titleblock"[/color]) ;; <-- Name of Titleblock

 (defun *error* ( msg )
   (if acdoc (_EndUndo acdoc))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ)
 )

 (defun _StartUndo ( doc ) (_EndUndo doc)
   (vla-StartUndoMark doc)
 )

 (defun _EndUndo ( doc )
   (if (= 8 (logand 8 (getvar 'UNDOCTL)))
     (vla-EndUndoMark doc)
   )
 )

 (defun _UniqueKey ( collection seed / i key ) (setq i 0)
   (while
     (not
       (vl-catch-all-error-p
         (vl-catch-all-apply 'vla-item
           (list collection (setq key (strcat seed (itoa (setq i (1+ i))))))
         )
       )
     )
   )
   key
 )

 (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object))
       aclyo (vla-get-layouts acdoc)
       aclay (vla-get-activelayout acdoc)
       acpvp (vla-item (vla-get-block aclay) 0)
 )
 (_StartUndo acdoc)
 
 (if (setq blockselection (ssget "_X" (list (cons 0 "INSERT") (cons 2 bname) (cons 410 (getvar 'CTAB)))))
   (repeat (setq i (1- (sslength blockselection)))
     (vla-getboundingbox
       (setq blockobject
         (vlax-ename->vla-object (ssname blockselection (setq i (1- i))))
       )
       'lowerleft 'upperright
     )
     (if
       (setq subselection
         (apply 'ssget
           (cons "_C"
             (mapcar
               (function
                 (lambda ( v ) (trans (vlax-safearray->list v) 0 1))
               )
               (list lowerleft upperright)
             )
           )
         )
       )
       (
         (lambda ( / objects )
           (vla-copyfrom aclay
             (setq newlayout (vla-add aclyo (_UniqueKey aclyo "Layout")))
           )            
           (repeat (setq j (sslength subselection))
             (setq objects (cons (vlax-ename->vla-object (ssname subselection (setq j (1- j)))) objects))
           )
           (vla-copyobjects acdoc
             (vlax-make-variant
               (vlax-safearray-fill
                 (vlax-make-safearray vlax-vbobject (cons 0 (length objects))) (cons acpvp (reverse objects))
               )
             )
             (vla-get-block newlayout)
           )
           (mapcar 'vla-delete objects)
         )
       )
     )
   )
 )

 (_EndUndo acdoc) (princ)
)

 

Type 'LayoutCutter' to start.

Link to comment
Share on other sites

Hi pBe,

             (cons "_C"
             (mapcar
               (function
                 (lambda ( v ) (trans (vlax-safearray->list v) 0 1))
               )
               (list lowerleft upperright)
             )
           )
         )
       )
    

 

Type 'LayoutCutter' to start.

 

Works well my friend, only thing i change is the line above from "_C" to "_W"

 

The bounding box approach is brilliant Lee.

 

Now tell me, what is missing on my code that it doesnt copy the viewport object

 

It copies eveything else except the VPs. what gives? (teach! teach!)

 

thanks Lee

Link to comment
Share on other sites

Works well my friend, only thing i change is the line above from "_C" to "_W"

 

The bounding box approach is brilliant Lee.

 

Thanks pBe, glad it works for you :)

 

Now tell me, what is missing on my code that it doesnt copy the viewport object

 

It copies eveything else except the VPs. what gives? (teach! teach!)

 

Your approach to use the CopyObjects method on all objects in the SelectionSet was correct, however, each layout has a PaperSpace Viewport (the first item in the Layout Block Definition) - encoding the view pertaining to looking at objects residing in PaperSpace. Hence, when creating a new Layout programmatically, one must create/copy its associated PaperSpace Viewport.

 

Also, notice that I use the CopyFrom method to also copy Plot/PageSetup Settings.

 

Regards,

 

Lee

Link to comment
Share on other sites

Thanks pBe, glad it works for you :)

 

Your approach to use the CopyObjects method on all objects in the SelectionSet was correct, however, each layout has a PaperSpace Viewport (the first item in the Layout Block Definition) - encoding the view pertaining to looking at objects residing in PaperSpace. Hence, when creating a new Layout programmatically, one must create/copy its associated PaperSpace Viewport.

 

Also, notice that I use the CopyFrom method to also copy Plot/PageSetup Settings.

 

Regards,

 

Lee

 

Thanks Lee, it all make sense now :)

 

BTW: ODBX wont work on this one doesnt it? I'll just have to make do with script then

 

again Thanks a mil

Link to comment
Share on other sites

BTW: ODBX wont work on this one doesnt it? I'll just have to make do with script then

 

No it won't since you can't use SelectionSets with ObjectDBX and IMO the workaround would be far too difficult for the little you are gaining in not using a script.

 

You're welcome pBe. :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...