Author Topic: Paste text in ALL Layouts simultaneously  (Read 10382 times)

0 Members and 1 Guest are viewing this topic.

deegeecees

  • Guest
Re: Paste text in ALL Layouts simultaneously
« Reply #15 on: September 08, 2005, 07:30:58 PM »
Man, if ComEd hadn't crippled themselves by not using Paperspace, THAT would be a keeper for me. Nice work CAB, you always amaze me.

whdjr

  • Guest
Re: Paste text in ALL Layouts simultaneously
« Reply #16 on: September 09, 2005, 08:47:05 AM »
Looks like Will removed the routine..

How about a delete in all tabs except the one you are in?

CAB,
I don't know what happened to that link I didn't remove it.

Here is the code:
Code: [Select]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;copyb.lsp by Will DeLoach    Copyright 2004                      ;;;
;;;                                                                 ;;;
;;;Description:                                                     ;;;
;;;The user selects an object on screen (not a viewport) and then it;;;
;;;is copied on all other layout tabs in the same location as the   ;;;
;;;object that was selected.                                        ;;;
;;;                                                                 ;;;
;;;This was tested on AutoCad 2000                                  ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;This is a rewrite of the ssget function to handle missed picks   ;;;
;;;and right clicks.  It also filters out viewports because they    ;;;
;;;wreck havoc in this routine.                                     ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ss_get (msg filter / ent)
  (while (not ent)
    (princ msg)
    (cond ((setq ent (ssget filter)))
  ((= (getvar "ErrNo") 52)
   (exit)
  )
  ((null ent)
   (princ "\nSelection missed.  Please try again.")
  )
    )
  )
  ent
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;This is a subr to collect all the layout tab objects into a list.;;;
;;;This subr removes the "Model" tab and the current tab as well.   ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun layout_list_no_activelayout (doc / lst)
  (vlax-map-collection
    *layouts*
    '(lambda (x) (setq lst (cons x lst)))
  )
  (vl-remove (vla-get-activelayout doc)
     (cdr
       (*sort* lst 'vla-get-taborder)
     )
  )
)
;;;
;;;
;;;
(defun *sort* (lst func)
  (vl-sort lst
   '(lambda (e1 e2)
      (< ((eval func) e1) ((eval func) e2))
    )
  )
)
;;;
;;;
;;;
(defun getSelectedItems (tilename AllItemsList / indexes)
  (if (setq indexes (get_tile tilename))
    (setq indexes (read (strcat "(" indexes ")"))
  indexes (mapcar '(lambda (n) (nth n AllItemsList))
  indexes
  )
    )
  )
  indexes
)
;;;
;;;
;;;
(defun get_selected_layouts (lst / id)
 ;
  (defun on_list_pick ()
    (if (= (get_tile "layout_list") "")
      (mode_tile "select" 1)
      (mode_tile "select" 0)
    )
  )
 ;
  (and (setq id (load_dcl))
       (start_list "layout_list")
       (mapcar 'add_list (mapcar 'vla-get-name lst))
       (not (end_list))
       (action_tile "cancel" "(done_dialog 0)")
       (action_tile
"select"
(strcat
   "(setq selection (getSelectedItems \"layout_list\" lst))"
   "(done_dialog 1)"
)
       )
       (action_tile "layout_list" "(on_list_pick)")
       (not (mode_tile "select" 1))
       (start_dialog)
       (not (unload_dialog id))
  )
  (if selection
    selection
    *error*
  )
)
;;;
;;;
;;;
(defun load_dcl (/ dcl dcl_id)
  (setq dcl "copyb_layouts.dcl")
  (while
    (if (minusp (setq dcl_id (load_dialog dcl)))
      (setq dcl (getfiled "Select correct DCL file location: "
  dcl
  "dcl"
  (+ 8 128)
)
      )
      (not (new_dialog "copyb_layouts" dcl_id))
    )
  )
  dcl_id
)
;;;
;;;
;;;
(defun *ssnames* (selection_set / num lst)
  (repeat (setq num (sslength selection_set))
    (setq num (1- num)
  lst (cons (ssname selection_set num) lst)
    )
  )
  lst
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;This is the main routine.  It copys an object to all selected    ;;;
;;;layout tabs at the exact location of the selected object.        ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:copyb (/ ss objs *acad* *adoc* *layouts*)
  (setq *acad*   (vlax-get-acad-object)
*adoc*   (vla-get-activedocument *acad*)
*layouts* (vla-get-layouts *adoc*)
  )
  (cond ((= (getvar "TILEMODE") 1)
(princ "\nThis command does not work in Modelspace.  ")
)
((> (getvar "CVPORT") 1)
(princ "\nThis command does not work in a Viewport.  ")
)
((not
   (setq ss (ss_get
      "\nSelect an Object to copy to selected Layout tabs:  "
      '((-4 . "<NOT") (0 . "VIEWPORT") (-4 . "NOT>"))
    )
   )
)
(princ "\nError:  Function Cancelled ")
)
(T
(setq objs (mapcar 'vlax-ename->vla-object (*ssnames* ss)))
(mapcar '(lambda (x)
    (vla-copyobjects
      *adoc*
      (vlax-safearray-fill
(vlax-make-safearray
  vlax-vbobject
  (cons 0 (1- (length objs)))
)
objs
      )
      (vla-get-block x)
    )
  )
(get_selected_layouts
   (layout_list_no_activelayout *adoc*)
)
)
)
  )
  (princ)
)

DCL file:
Code: [Select]
copyb_layouts : dialog {
  label = "Available Layouts";
  :boxed_column {
    label = "Select Layouts to copy objects to:";
    : list_box {
      key = "layout_list";
      height = 12;
      multiple_select = true;
      }
    }
  : row {
    : button {
      label = "&Select...";
      key = "select";
      }
    : button {
      label = "&Cancel";
      is_cancel = true;
      key = "cancel";
      }
  }
}

I hope this helps everyone.

****Edit:  Replaced the copyb routine with a newer version. 9.9.05 8:56:am
« Last Edit: September 09, 2005, 08:58:08 AM by whdjr »

ELOQUINTET

  • Guest
Re: Paste text in ALL Layouts simultaneously
« Reply #17 on: September 09, 2005, 09:32:50 AM »
alright cab i'll give it a shot when i get a chance thanks alot. does this work for dtext because i believe each line is an indvidual? i still have to figure out a way to paste the see sheet #1 to all remaining sheets. i really need that paste block to all layouts routine for another situation, will where are ya buddy heeeeellllp.


deegeecees

  • Guest
Re: Paste text in ALL Layouts simultaneously
« Reply #18 on: September 09, 2005, 10:15:24 AM »
Eloquintet,
If I may make a suggestion:

I'm going to make some assumptions here, but if you are using titleblocks in your layouts, then how about an attribute that is updated with its corresponding layout name? Just a thought.

Deeg

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Paste text in ALL Layouts simultaneously
« Reply #19 on: September 09, 2005, 11:27:45 AM »
Man, if ComEd hadn't crippled themselves by not using Paperspace, THAT would be a keeper for me. Nice work CAB, you always amaze me.
Thank you Sir...
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

deegeecees

  • Guest
Re: Paste text in ALL Layouts simultaneously
« Reply #20 on: September 09, 2005, 01:17:37 PM »
Absolutely no problem whatsoever.

ELOQUINTET

  • Guest
Re: Paste text in ALL Layouts simultaneously
« Reply #21 on: September 09, 2005, 02:05:19 PM »
assum nothing deegeecees. we enter our info into access. we have an empty titleblock which is not a block of which these general notes are a part of. then we use a button to insert an attributed block based on the drawing number we search for in the database. some screwy ways of doing things around here. anyway i'll give all of this a try when i get a chance thanks guys

whdjr

  • Guest
Re: Paste text in ALL Layouts simultaneously
« Reply #22 on: September 09, 2005, 02:17:05 PM »
alright cab i'll give it a shot when i get a chance thanks alot. does this work for dtext because i believe each line is an indvidual? i still have to figure out a way to paste the see sheet #1 to all remaining sheets. i really need that paste block to all layouts routine for another situation, will where are ya buddy heeeeellllp.



I posted the routine.  Holler louder (read PM) if you need more help.

ELOQUINTET

  • Guest
Re: Paste text in ALL Layouts simultaneously
« Reply #23 on: September 09, 2005, 02:32:29 PM »
i got it will just don't have alot of time lately to fiddle  :x

ELOQUINTET

  • Guest
Re: Paste text in ALL Layouts simultaneously
« Reply #24 on: September 09, 2005, 03:25:46 PM »
both routines work great on this end. i do have a couple requests if it's not asking too much. first will is it possible to not have to specify the dcl location upon using the routine? second is for cab. would it be possible to modify one of these routines to change the text i pick on all other layouts to     SEE NOTES ON SHEET #1 ? i can work with what i have but it would work like a dream with these 2 additions. pllllllease


CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Paste text in ALL Layouts simultaneously
« Reply #25 on: September 09, 2005, 04:27:51 PM »
Code: [Select]
;; special version for Dan
;;  changes all matching text to SEE NOTES ON SHEET #1
;;  but does not change the selected text.
(defun c:pstext-edit-dan (/ str pt ent oldstr cnt ctab)
  (vl-load-com)
  (defun get_point (e)
     ;;  get a referance point to compare, if dtext use alignment point
     ;;  because center justification can change the insertion point
     (if (= (vla-get-objectname e) "AcDbText")
       (vlax-get e "textalignmentpoint")
       (vlax-get e "insertionpoint")
     )
  )
  (if (= (getvar "tilemode") 1)
    (alert "\nYou must be in Paper Space to run this routine.\t")
    (progn ; else you are in paper space, ok to proceed
      (if (/= (getvar "cvport") 1); a view port is active
        (command "_pspace") ; close the view port
      )
      (princ "\nSelect text to revise to SEE NOTES ON SHEET #1")
      (if (setq ss (ssget ":S" '((0 . "TEXT,MTEXT"))))
        (progn
          (setq ent    (vlax-ename->vla-object (ssname ss 0))
                oldstr (vlax-get ent "textstring")
                pt     (get_point ent)
                cnt    0
                ctab   (getvar "CTab")
          )
         
              (vlax-for x (vla-get-layouts
                            (vla-get-activedocument
                              (vlax-get-acad-object)
                            )
                          )
                ;;  skip model space
            ;;  skip model space or current tab
            (if (not (or (= (strcase (vla-get-name x)) "MODEL")
                         (= (vla-get-name x) ctab)
                     )
                )
                  (vlax-for y (vla-get-block x)
                    (if
                      (and
                        (member (vla-get-objectname y) '("AcDbMText" "AcDbText"))
                        (= (vla-get-textstring y) oldstr)
                        (= (car pt)(car (get_point y)))
                        (= (cadr pt)(cadr (get_point y)))
                      )
                      (progn
                        (vla-put-textstring y "SEE NOTES ON SHEET #1")  ; str)
                        (setq cnt (1+ cnt))
                      )
                    ) ; endif
                  ) ; vlax-for
                ) ; endif
              ) ; vlax-for
              (vlax-release-object ent)
              (prompt (strcat "\n" (itoa cnt) " Layouts Updated."))

         
        ) ; progn
        (prompt "\nObject is not plain text or Mtext.")
      ) ; endif
    ) ; progn
  ) ;endif
  (princ)
) ; defun
(prompt "\nEnter psText-edit-dan to edit text.")
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ELOQUINTET

  • Guest
Re: Paste text in ALL Layouts simultaneously
« Reply #26 on: September 09, 2005, 05:24:52 PM »
thanks a million gazillion cab you truly deserve the cypress

ELOQUINTET

  • Guest
Re: Paste text in ALL Layouts simultaneously
« Reply #27 on: September 12, 2005, 11:14:20 AM »
will how would i avoid having to load the dcl everytime i run the routine?

whdjr

  • Guest
Re: Paste text in ALL Layouts simultaneously
« Reply #28 on: September 12, 2005, 11:56:37 AM »
will how would i avoid having to load the dcl everytime i run the routine?
Dan,

That is an evil trick I put in the tool to piss people off. :evil: :mrgreen:


Just kiddin'. :laugh:

The 'copyb' routine only asks you for the location of the DCL file because it can't find it.  If you move it to a location in your support path then it will find it and not ask you for it.

ELOQUINTET

  • Guest
Re: Paste text in ALL Layouts simultaneously
« Reply #29 on: September 12, 2005, 02:01:56 PM »
aha now i traced my problem. i changed the file from copyb_layouts to just copyb but didn't update everything within. i got it working now thanks for the hint :police: ha these icons suck the big one cept for mr green of course  :mrgreen: