乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
楼主: tmelancon

[编程交流] 简单绘图计数/总Rou

[复制链接]

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 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
  1. (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))
回复

使用道具 举报

47

主题

257

帖子

216

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
229
发表于 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!
回复

使用道具 举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2022-7-5 17:11:51 | 显示全部楼层
 
If you feed my code above a point it will do all your tabs at once
回复

使用道具 举报

47

主题

257

帖子

216

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
229
发表于 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).
 
  1. (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))
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-13 16:41 , Processed in 0.726055 second(s), 58 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表