乐筑天下

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

[编程交流] Text - Justification Routine H

[复制链接]

88

主题

346

帖子

281

银币

后起之秀

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

铜币
423
发表于 2022-7-6 17:10:23 | 显示全部楼层 |阅读模式
This works with one caveat. It moves the text to 0,0.
Can someone help me modify this code to work correctly?
ie: NOT moving the text!
(re-adjusting it a bit is fine, moving off screen is a PITA!!)
It only works with TEXT as well. Not a real problem but..
 
Thanks!
 
;------------------ CODE ---------------------------------
 
(defun C:JMR ()
  (setq t (ssget))
  (prompt "\nSet to Middle Right Justification . . .")
(setq j1 "MR")  
  (setq m (sslength t)
        index 0)
  (repeat m
    (setq a (entget (ssname t index))
          p (cdr (assoc 0 a)))
    (if (= p "TEXT")
      (progn
         (setq j  (assoc 72 a)
               j2 (assoc 73 a)
               p  (assoc 10 a)
               q  (assoc 11 a)
               j0 (cdr j))
      (progn
         (setq q1 (cdr q)
               p1 (cons (car p) q1)
               n1 (subst p1 p a))
             )        
         (setq n  (subst '(72 . 2) j n1))
         (setq n  (subst '(73 . 2) j2 n))
         (entmod n)
      )
    )
    (setq index (+ index 1))
  ))
回复

使用道具 举报

4

主题

29

帖子

25

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 17:40:55 | 显示全部楼层
If you're using 2009, why can't you just use the tjust command?
回复

使用道具 举报

88

主题

346

帖子

281

银币

后起之秀

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

铜币
423
发表于 2022-7-6 17:54:13 | 显示全部楼层
I use 3 justifications for the most part and it's easier to type a 2-3 letter command instead of having to select objects, hit enter, enter the justification and hit enter.
 
I could just script it but I like coding and am still learning
so solving the problem via code is half the fun.
 
There are people on here lightyears ahead of me in their knowledge and I like seeing their methods.. (Thanks guys!)
I'm wanting to learn more about coding in autolisp..
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 18:17:53 | 显示全部楼层
Hi ILoveMadoka,
 
Hopefully this LISP will do the job
 
  1. (defun C:JMR (/ ss1 sslen index tents ent1 enttyp bspt1)   (setq ss1 (ssget))   (setq sslen (sslength ss1)        index 0       tents 0   ) ; end setq   (repeat sslen       (setq     ent1 (entget (ssname ss1 index))           enttyp (cdr (assoc 0 ent1))       ) ; end setq       (if (= enttyp "TEXT")           (progn               (setq bspt1 (cdr (assoc 10 ent1)))               (setq ent1 (subst (cons 11 bspt1) (assoc 11 ent1) ent1))               (entmod ent1)               (setq ent1 (subst (cons 72 2) (assoc 72 ent1) ent1))               (setq ent1 (subst (cons 73 2) (assoc 73 ent1) ent1))               (entmod ent1)               (setq tents (+ tents 1))           ) ; end progn       ) ; end if       (setq index (+ index 1))   ) ; end repeat   (if (/= tents 1)   (alert (strcat (itoa tents) " Text Entities Modified."))   (alert (strcat (itoa tents) " Text Entity Modified. "))   ) ; end if   (princ)) ; end defun
Let me know if this is what you were after
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-4 16:27 , Processed in 0.416910 second(s), 60 queries .

© 2020-2025 乐筑天下

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