Jump to content

Recommended Posts

Posted

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

Posted

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.

Posted

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?

Posted
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?

Posted

Nope.

 

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

Posted

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 ?
)

  • 2 weeks later...
Posted

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.

Posted

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?

Posted

[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:

Posted

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 ?

Posted

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

Posted
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!

Posted
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

Posted

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

 

You're welcome, MiningDave. :beer:

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...