Jump to content

Text - Justification Routine Help


ILoveMadoka

Recommended Posts

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))

))

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

Hi ILoveMadoka,

 

Hopefully this LISP will do the job :P

 

(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 :D

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...