ronjonp 发表于 2022-7-5 17:01:27

Here's a quick one to place text "SHEET X OF X" on each paperspace tab @ 0,0,0 .. enjoy

(defun c:foo (/ _maketext r o n s ll) ;; Creates text "SHEET X OF X" on each paper space tab at 0,0,0 ;; RJP - 06.28.2017 (defun _maketext (space point string height width rotation layer)   (if        point   (entmakex        (list '(0 . "TEXT")              '(100 . "AcDbEntity")              (cons 8 layer)              (cons 410 space)              '(100 . "AcDbText")              (cons 10 (trans point 1 0))              (cons 40 height)              (cons 1 string)              (cons 50 rotation)              (cons 41 width)              '(72 . 1)              (cons 11 (trans point 1 0))              '(73 . 2)        )   )   ) ) (and (setq r (cdr (assoc -1 (dictsearch (namedobjdict) "acad_layout"))))      (setq o (itoa (length (setq ll (layoutlist)))))      (foreach        l ll (setq n (itoa (cdr (assoc 71 (dictsearch r l))))) (if (setq s (ssget "x" (list '(0 . "text") '(8 . "Sheet_Numbers") (cons 410 l))))   (entmod (subst (cons 1 (strcat "SHEET " n " OF " o))                  (assoc 1 (entget (ssname s 0)))                  (entget (ssname s 0))           )   )   (_maketext l '(0 0 0) (strcat "SHEET " n " OF " o) 0.125 1 0.0 "Sheet_Numbers") )      ) ) (princ))

tmelancon 发表于 2022-7-5 17:06:07

Lee, I am going to try and modify your code just a little bit (while keeping all of your original author notes and copyrights) so that It prompts the user to actually place the text, rather than select. The majority of the time we are drawing from scratch and having to enter these "DWG 1 OF 10" manually. That is why i designed my code to work the way it does; allowing the user to specify where they want to place the "DWG 1 OF 10", then proceeding to process the code to enter it. If you beat me to it, I would be happy to give it a try! Thanks for everything! God bless everyone! Keep up the great work!

ronjonp 发表于 2022-7-5 17:11:51

 
If you feed my code above a point it will do all your tabs at once

tmelancon 发表于 2022-7-5 17:15:28

Ron Sweet code, but my basic code does what I need. However, your code could eliminate the user having to even enter "Number of Sheets". But have a look at my code, its a little different that yours. You have yours putting the string at 0,0 in each layout. My code is always in model space and prompts the user to specify number of sheets then prompts user to place text (this is not automated because sometimes our titleblocks are on the left, and other times they are on the right).
 

(DEFUN C:DWG(/ *error* count countup oldlayr t_size point dwgof)(setvar "cmdecho" 0) (defun *error* (msg)   (if    oldlayr   (setvar "clayer" oldlayr)   ) )(SETQ COUNT (GETSTRING "\nHow many drawings do you have? "))(SETQ COUNTUP 1)(setq oldlayr (getvar "clayer"))(setq t_size 0.08) (REPEAT (ATOI COUNT)(SETQ DWGOF (STRCAT "DWG " (TRIM (ITOA COUNTUP)) " OF " (TRIM COUNT)))(setq point (getpoint "\nPick Text Placement: "))(command "layer" "s" "text" "")(command "._text" "L" point t_size "0" DWGOF)(COMMAND "MOVE" "L" "" "0,0" "0,.05")(SETQ COUNTUP (1+ COUNTUP)) )(SETVAR "CLAYER" OLDLAYR)(PRINC))
页: 1 [2]
查看完整版本: 简单绘图计数/总Rou