Jump to content
MiningDave

Adding something to every layout

Recommended Posts

MiningDave

Hi all,

 

I have about 140 layouts and I've just been asked to add a piece of information (some mtext) to every other layout, any ideas?

 

Any help is appreciated,

 

Dave

Share this post


Link to post
Share on other sites
RobDraw

Copy and paste is probably the fastest way. You could also use an XREF or a block.

 

If this is something that you will be doing on a regular basis, then you might be able to get someone to write some code for you that will insert something into selected layouts.

Share this post


Link to post
Share on other sites
rkent

Make that piece of information a .dwg file and xref it into your files. It is likely to change and then you only have to change it once rather than open 140 drawings/layouts.

 

Are you saying you have one file with 140 layouts?

Share this post


Link to post
Share on other sites
ROBP
Make that piece of information a .dwg file and xref it into your files. It is likely to change and then you only have to change it once rather than open 140 drawings/layouts.

 

Are you saying you have one file with 140 layouts?

 

If drawing layout was done with dwt then updating the dwt should do it would it?

Share this post


Link to post
Share on other sites
RobDraw

Nope.

 

If the layout was done with an XREF, that would do it, except for the ones you don't want to see.

Share this post


Link to post
Share on other sites
BIGAL

Looping through layouts is easy this is not tested but should work

 

(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for lay (vla-get-Layouts doc)
(setvar "ctab" (vla-get-name lay))
(command "pspace")
do your thing here insert block of mtext ?
)

Share this post


Link to post
Share on other sites
MiningDave

Thanks all, I bit the bullet and just copied and pasted with base points.

 

I did try that script but had no joy.

 

And yeah just over 140 layouts in one file. Big Project time.

Share this post


Link to post
Share on other sites
BlackBox

Thanks all, I bit the bullet and just copied and pasted with base points.

 

I did try that script but had no joy.

 

And yeah just over 140 layouts in one file. Big Project time.

 

I _really_ wish I had seen this earlier... The only thing _slower_ than performing this task manually, is saving and closing the drawing after you perform this task in each layout manually. :rofl:

 

Short of coding this in either .NET, or ObjectARX APIs (which would be faster), this is about as fast as you can get... No changing the active layout (CTAB), active Viewports are a non-issue, and supports UNDO functionality :thumbsup: :

 

(vl-load-com)

(defun c:CopyToAllLayouts (/ *error* layouts acDoc objects)

 (defun *error* (msg)
   (if acDoc
     (vla-endundomark acDoc)
     )
   (cond ((not msg))                                                   ; Normal exit
         ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
         ((princ (strcat "\n** Error: " msg " ** ")))                  ; Fatal error, display it
   )
   (princ)
 )

 (if (= 1 (getvar 'cvport))
   (progn
     (prompt "\nSelect object(s) to copy to all Layouts: ")
     (princ)
     (if (ssget "_:L")
       (progn
         (setq layouts (list "Model" (getvar 'ctab)))
         (vla-startundomark
           (setq acDoc (vla-get-activedocument (vlax-get-acad-object)))
         )
         (vlax-for x (vla-get-activeselectionset acDoc)
           (setq objects (cons x objects))
         )
         (vlax-for layout (vla-get-layouts acDoc)
           (if (not (vl-position (vla-get-name layout) layouts))
             (vlax-invoke
               acDoc
               'copyobjects
               objects
               (vla-get-block layout)
             )
           )
         )
       )
     )
   )
   (prompt "\n** Command not available in Model Tab ** ")
 )

 (*error* nil)
)

 

 

Cheers

 

 

 

[Edit] - I'd be very interested to know approximately how long it took you to do manually, as compared to how long this option takes?

Share this post


Link to post
Share on other sites
BlackBox

[Edit] - I'd be very interested to know approximately how long it took you to do manually, as compared to how long this option takes?

 

I just bench tested this on a drawing with 140 layouts, copying 104 circles (an exploded 8 x 13 array) to each layout, and it only took +/- 3 seconds... _Including_ the time it took me to select the circles to copy:

 

Command: (length (layoutlist))
140

Command: (bench '(c:foo) '() 1)

C:FOO
Select object(s) to copy to all Layouts: 104 found

Elapsed: 2610
Average: 2610.0000

 

 

 

Cheers :beer:

Share this post


Link to post
Share on other sites
BIGAL

I agree 140 to slow manually.

 

A question Blackbox most of my layout stuff requires the use of 'CTAB using the vlax-invoke can you update a attributed block "Titleblock" with out having to go to that layout and force a display ? Thats the time killer mind you 89 layouts takes about max 1 min to do lots of stuff ?

Share this post


Link to post
Share on other sites
BlackBox

Certainly you can, however I will say that when it comes to title blocks specifically, I'm a strong advocate for the use of Sheet Set Manager (SSM) Properties populating your title blocks attributes via Fields.

 

My reason is simple - I can modify any sheet set (project), or sheet-specific value of a given title block from SSM without even opening a single sheet in the editor, and print when done.

 

Cheers

Share this post


Link to post
Share on other sites
BIGAL

Thanks blackbox will look into it more

Share this post


Link to post
Share on other sites
MiningDave
I _really_ wish I had seen this earlier... The only thing _slower_ than performing this task manually, is saving and closing the drawing after you perform this task in each layout manually. :rofl:

 

Short of coding this in either .NET, or ObjectARX APIs (which would be faster), this is about as fast as you can get... No changing the active layout (CTAB), active Viewports are a non-issue, and supports UNDO functionality :thumbsup: :

 

(vl-load-com)

(defun c:CopyToAllLayouts (/ *error* layouts acDoc objects)

 (defun *error* (msg)
   (if acDoc
     (vla-endundomark acDoc)
     )
   (cond ((not msg))                                                   ; Normal exit
         ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
         ((princ (strcat "\n** Error: " msg " ** ")))                  ; Fatal error, display it
   )
   (princ)
 )

 (if (= 1 (getvar 'cvport))
   (progn
     (prompt "\nSelect object(s) to copy to all Layouts: ")
     (princ)
     (if (ssget "_:L")
       (progn
         (setq layouts (list "Model" (getvar 'ctab)))
         (vla-startundomark
           (setq acDoc (vla-get-activedocument (vlax-get-acad-object)))
         )
         (vlax-for x (vla-get-activeselectionset acDoc)
           (setq objects (cons x objects))
         )
         (vlax-for layout (vla-get-layouts acDoc)
           (if (not (vl-position (vla-get-name layout) layouts))
             (vlax-invoke
               acDoc
               'copyobjects
               objects
               (vla-get-block layout)
             )
           )
         )
       )
     )
   )
   (prompt "\n** Command not available in Model Tab ** ")
 )

 (*error* nil)
)

Cheers

 

 

 

[Edit] - I'd be very interested to know approximately how long it took you to do manually, as compared to how long this option takes?

 

 

It took me a fair old while as I had add individual detail to all the items. It was dimensions of the object on the previous sheet, so I wanted to apply the Mtext 'Shaft Dimensions', or 'Tunnel Dimensions' etc to all the pages and then just add the number on after.

 

Thanks for the help and the code though! Might well use that next time!

Share this post


Link to post
Share on other sites
BlackBox
Thanks blackbox will look into it more

 

Always happy to help a friend :); if you don't find what you're after in other threads, and\or would simply like to discuss more, let me know. :thumbsup:

 

Cheers

Share this post


Link to post
Share on other sites
BlackBox

Thanks for the help and the code though! Might well use that next time!

 

You're welcome, MiningDave. :beer:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×