Text on Multi Layouts

Discussion in 'AutoCAD' started by arshadmirza786, May 19, 2004.

  1. Is there a way to write/ edit the text on more than ONE layout at time "TENDER DWG/ CONSTRUCTION DWG" at same place of each layout

    Thanks
     
    arshadmirza786, May 19, 2004
    #1
  2. arshadmirza786

    Jamie Duncan Guest

    The easiest way for notes like that is to make them part of an xref that's
    attached to each layout, or as an attribute part of the title block and then
    use the expresstool gatte

    Jamie Duncan


    "TENDER DWG/ CONSTRUCTION DWG" at same place of each layout
     
    Jamie Duncan, May 19, 2004
    #2
  3. arshadmirza786

    R.K. McSwain Guest

    Include the text in a block that is inserted in each desired layout.
    Use REFEDIT to change.
     
    R.K. McSwain, May 19, 2004
    #3
  4. arshadmirza786

    Jeff Mishler Guest

    You've received a number of good solutions, but here's one that places text
    into all PS layouts - PSText. To revise, use the PSText-edit command.

    Jeff

    (defun c:pStext (/ str pt)
    (vl-load-com)
    (setq str (getstring "\nText to place on all PS layouts: ")
    pt (getpoint "\nSelect/Enter common insertion Point: "))
    (vlax-for x (vla-get-layouts
    (vla-get-activedocument
    (vlax-get-acad-object)))
    (if (not (wcmatch (strcase (vla-get-name x)) "MODEL"))
    (vlax-invoke (vla-get-block x) "addText" str pt (getvar "textsize"))
    )
    )
    (princ)
    )

    (defun c:pStext-edit (/ str pt)
    (vl-load-com)
    (princ "\nSelect text to revise in all PS layouts: ")
    (if (setq ss (ssget ":S" '((0 . "TEXT"))))
    (progn
    (setq str (getstring "\nNew text string: ")
    ent (vlax-ename->vla-object (ssname ss 0))
    pt (vlax-get ent "insertionpoint")
    oldstr (vlax-get ent "textstring")
    )
    (vlax-for x (vla-get-layouts
    (vla-get-activedocument
    (vlax-get-acad-object)))
    (if (not (wcmatch (strcase (vla-get-name x)) "MODEL"))
    (progn
    (vlax-for y (vla-get-block x)
    (if (and (= (vla-get-objectname y) "AcDbText")
    (= (vla-get-textstring y) oldstr)
    (= (car pt) (car (vlax-get ent "insertionpoint")))
    (= (cadr pt) (cadr (vlax-get ent "insertionpoint")))
    )
    (vla-put-textstring y str)
    )
    )
    )
    )
    )
    )
    )
    (princ)
    )

    "TENDER DWG/ CONSTRUCTION DWG" at same place of each layout
     
    Jeff Mishler, May 22, 2004
    #4
  5. arshadmirza786

    CAB2k Guest

    Nice one Jeff,
    I as looking for something like that..
    Thanks
    CAB
     
    CAB2k, May 23, 2004
    #5
  6. arshadmirza786

    CAB2k Guest

    Jeff,
    I hope you don't mind, I tweaked your routine a bit for my own use.


    Code:
    ;;  Multi Tab Text Insert/Edit
    ;;  By Jeff Mishler
    ;;
    ;;  Places text into all PS layouts - PSText.lsp
    ;;  To revise, use the PSText-edit.lsp command.
    ;;  Uses current text style, and current layer
    ;;  Uses current text style text size, if 0 uses sys var TextSize
    ;;
    ;;
    ;;  Modified by CAB 05/23/04
    ;;  added force->paperspace & user input error check
    ;;  added allow spaces in user text string
    ;;  added text style current & correction for TextSize variable
    ;;  added ability to pick existing text in ps to insert in layouts
    
    
    (defun c:pstext (/ str pt txt_ht elst ent cnt)
    (vl-load-com)
    (force->paperspace)
    (prompt "\nSelect nothing or ENTER to type text: ")
    (setq loop t)
    (while loop
    (if (setq ent (entsel "\nSelect text to place on all PS layouts: "))
    (progn
    (if (= (cdr (assoc 0 (setq elst (entget (car ent))))) "TEXT")
    (progn
    (setq ent  (vlax-ename->vla-object (car ent))
    pt   (vlax-get ent "insertionpoint")
    str  (vlax-get ent "textstring")
    loop nil
    )
    (setvar "clayer" (vlax-get ent "layer"))
    (setvar "textstyle" (vlax-get ent "stylename"))
    ;; del because it is recreated in the foreach
    (vla-delete ent)
    (vlax-release-object ent)
    )
    (prompt "\nNot a TEXT object, Try Again.")
    ) ; endif
    ) ; progn
    ;;  nothing selected
    (setq loop nil)
    ) ; endif
    ) ; end while
    (and
    (null str)
    (/=(setq str (getstring t "\nText to place on all PS layouts: "))"")
    (setq pt (getpoint "\nSelect/Enter common insertion Point: "))
    )
    (if (and str pt)
    (progn
    ;;Get the current text style height
    (setq txt_ht (cdr (assoc 40 (tblsearch "style"
    (getvar "textstyle")))))
    (if (= txt_ht 0) ; use the acad default
    (setq txt_ht (getvar "textsize"))
    )
    (setq cnt 0)
    ;;  step through all layouts
    (vlax-for x (vla-get-layouts
    (vla-get-activedocument
    (vlax-get-acad-object)))
    ;;  skip model space
    (if (not (wcmatch (strcase (vla-get-name x)) "MODEL"))
    (progn
    (vlax-invoke(vla-get-block x) "addText" str pt txt_ht)
    (setq cnt (1+ cnt))
    )
    ) ; endif
    ) ; foreach
    (prompt (strcat "\n"(itoa cnt) " Layouts Updated."))
    ) ; progn
    (prompt "\nUser Quit.")
    ) ; endif
    (princ)
    )
    
    (defun c:pstext-edit (/ str pt)
    (vl-load-com)
    (force->paperspace)
    (princ "\nSelect text to revise in all PS layouts: ")
    (if (setq ss (ssget ":S" '((0 . "TEXT"))))
    (progn
    (setq str    (getstring t "\nNew text string: ")
    ent    (vlax-ename->vla-object (ssname ss 0))
    pt     (vlax-get ent "insertionpoint")
    oldstr (vlax-get ent "textstring")
    )
    ;;  step through all layouts
    (vlax-for x (vla-get-layouts
    (vla-get-activedocument(vlax-get-acad-object)))
    ;;  skip model space
    (if (not (wcmatch (strcase (vla-get-name x)) "MODEL"))
    (progn
    (vlax-for y (vla-get-block x)
    (if
    (and (= (vla-get-objectname y) "AcDbText")
    (= (vla-get-textstring y) oldstr)
    (= (car pt) (car (vlax-get ent "insertionpoint")))
    (= (cadr pt) (cadr (vlax-get ent "insertionpoint")))
    )
    (vla-put-textstring y str) )))
    ); endif
    ); vlax-for
    (vlax-release-object ent)
    ); progn
    ); endif
    (princ)
    ); defun
    
    ;;  Force Paper Space if in Model
    (defun force->paperspace ()
    (if (= 1 (vla-get-activespace
    (vla-get-activedocument (vlax-get-acad-object))))
    (vla-put-activespace
    (vla-get-activedocument (vlax-get-acad-object))0)
    ); endif
    (princ)
    ); defun
     
    CAB2k, May 23, 2004
    #6
  7. arshadmirza786

    Jeff Mishler Guest

    CAB, no problem tweaking it as you desire...that's whay I post these little
    snippets, to let others determine how best to use them in their environment.
    I do have a few comments about the revised code, though.

    When selecting an existing Text object to place on other Tabs I think it
    best to leave the existing instead of deleting/recreating it. The main
    reason is due to the possibility of dictionary/xdata being associated with
    the original which would be lost by deleting it. It would be just as easy to
    exclude the current Tab along with the Model Tab when placing the new Text
    objects.

    Just a personal preference, but I would check that the user is in Paperspace
    and if not, warn them that this must be used in PS and exit. This way if the
    command is entered by mistake they are not sent to PS.

    I'm glad you could put it to use,
    Jeff
     
    Jeff Mishler, May 23, 2004
    #7
  8. arshadmirza786

    CAB2k Guest

    Jeff Said:
    | I think it best to leave the existing

    Yes, i didn't think about x-data, good idea

    | Just a personal preference, but I would check that the user is in Paperspace
    | and if not, warn them that this must be used in PS and exit. This way if the
    | command is entered by mistake they are not sent to PS.

    Another good suggestion, I sometimes forget there is a viewport active and
    need a helpful reminder.

    CAB
     
    CAB2k, May 24, 2004
    #8
  9. arshadmirza786

    CAB2k Guest

    Jeff,

    AS per your suggestions see the revised code.

    Also added Line test edit to the edit routine.

    Thanks again.
    CAB

    Code:
    ;;  Multi Tab Text Insert/Edit
    ;;  By Jeff Mishler
    ;;
    ;;  Places text into all PS layouts - PSText.lsp
    ;;  To revise, use the PSText-edit.lsp command.
    ;;  Uses current text style, and current layer
    ;;  Uses current text style text size, if 0 uses sys var TextSize
    ;;
    ;;
    ;;  Modified by CAB 05/23/04
    ;;  added paperspace check & user input error check
    ;;  added close active viewport
    ;;  added allow spaces in user text string
    ;;  added text style current & correction for TextSize variable
    ;;  added ability to pick existing text in ps to insert in layouts
    ;;  added Line Text Edit to pstext-edit
    
    
    (defun c:pstext (/ str pt txt_ht elst ent cnt tab)
    (vl-load-com)
    (if (= (getvar "tilemode") 1)
    (alert "\nYou must be in Paper Space to run this routine.\t")
    (progn
    (if (/= (getvar "cvport") 1)
    (command "_pspace") ; close the view port
    )
    (prompt "\nSelect nothing or ENTER to type text: ")
    (setq loop t)
    (while loop
    (if
    (setq ent (entsel "\nSelect text to place on all PS layouts: "))
    (progn
    (if (= (cdr (assoc 0 (setq elst (entget (car ent))))) "TEXT")
    (progn
    (setq ent  (vlax-ename->vla-object (car ent))
    pt   (vlax-get ent "insertionpoint")
    str  (vlax-get ent "textstring")
    tab  (getvar "ctab")
    loop nil
    )
    (setvar "clayer" (vlax-get ent "layer"))
    (setvar "textstyle" (vlax-get ent "stylename"))
    (vlax-release-object ent)
    )
    (prompt "\nNot a TEXT object, Try Again.")
    ) ; endif
    ) ; progn
    ;;  nothing selected
    (setq loop nil)
    ) ; endif
    ) ; end while
    (and
    (null str)
    (/= (setq str (getstring t "\nText to place on all PS layouts: ")) "")
    (setq pt (getpoint "\nSelect/Enter common insertion Point: "))
    )
    (if (and str pt)
    (progn
    ;;Get the current text style height
    (setq txt_ht (cdr
    (assoc 40 (tblsearch "style"
    (getvar "textstyle")))))
    (if (= txt_ht 0) ; use the acad default
    (setq txt_ht (getvar "textsize"))
    )
    (setq cnt 0)
    ;;  step through all layouts
    (vlax-for x (vla-get-layouts
    (vla-get-activedocument
    (vlax-get-acad-object)))
    ;;  skip model space
    (if (and tab
    (/= tab (vla-get-name x))
    (not (wcmatch (strcase (vla-get-name x)) "MODEL")))
    (progn
    (vlax-invoke (vla-get-block x) "addText" str pt txt_ht)
    (setq cnt (1+ cnt))
    )
    ) ; endif
    ) ; foreach
    (prompt (strcat "\n" (itoa cnt) " Layouts Updated."))
    ) ; progn
    (prompt "\nUser Quit.")
    ) ; endif
    ) ; progn
    ) ;endif
    (princ)
    ); end defun
    
    
    (defun c:pstext-edit (/ str pt)
    (vl-load-com)
    (if (= (getvar "tilemode") 1)
    (alert "\nYou must be in Paper Space to run this routine.\t")
    (progn
    (if (/= (getvar "cvport") 1)
    (command "_pspace") ; close the view port
    )
    (princ "\nSelect text to revise in all PS layouts: ")
    (if (setq ss (ssget ":S" '((0 . "TEXT"))))
    (progn
    (setq ;str    (getstring t "\nNew text string: ")
    ent    (vlax-ename->vla-object (ssname ss 0))
    pt     (vlax-get ent "insertionpoint")
    oldstr (vlax-get ent "textstring")
    )
    (command "_.ddedit" (ssname ss 0) "")
    (if (= (setq str (vlax-get ent "textstring")) oldstr)
    (prompt "\nNo change in text, nothing to do.")
    (progn;  step through all layouts
    (vlax-for x
    (vla-get-layouts
    (vla-get-activedocument (vlax-get-acad-object)))
    ;;  skip model space
    (if (not (wcmatch (strcase (vla-get-name x)) "MODEL"))
    (vlax-for y (vla-get-block x)
    (if
    (and
    (= (vla-get-objectname y) "AcDbText")
    (= (vla-get-textstring y) oldstr)
    (= (car pt)(car (vlax-get ent "insertionpoint")))
    (= (cadr pt)(cadr (vlax-get ent "insertionpoint")))
    )
    (vla-put-textstring y str)
    ) ; endif
    ); vlax-for
    ) ; endif
    ) ; vlax-for
    (vlax-release-object ent)
    ) ; progn
    ) ; endif
    ) ; progn
    ) ; endif
    ) ; progn
    ) ;endif
    (princ)
    ) ; defun
     
    CAB2k, May 24, 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.