Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can I change the justification of the text to middle left

18 REPLIES 18
SOLVED
Reply
Message 1 of 19
marlance
4706 Views, 18 Replies

How can I change the justification of the text to middle left

I found this lisp here in this forum and I tried to modify it by adding an option to set the offset distance of the text from the alignment.

And it works. But what I want is to change the justification of the text from left to middle left. When I change the dxf code 73 from 0 to 2, all the texts created were place at 0,0.

How can I change the justification of the text to middle left?

 

I've attached the modified lisp and the screen shot of what I want with the lisp.

 

 

Thank you in advance

18 REPLIES 18
Message 2 of 19
pbejse
in reply to: marlance


@rulep21 wrote:

I found this lisp here in this forum and I tried to modify it by adding an option to set the offset distance of the text from the alignment.

And it works. But what I want is to change the justification of the text from left to middle left. When I change the dxf code 73 from 0 to 2, all the texts created were place at 0,0.

How can I change the justification of the text to middle left?

 

Thank you in advance


(defun _text (p b o h c)
;;; pBe -<-- dont forget to mention the original author dude (entmake (append '((0 . "MTEXT") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (7 . "Standard Arial") (8 . "C-CTRL_TXT") (100 . "AcDbMText") ) (list (cons 10 (polar p (+ b PI) o)) ) (list (cons 40 h)) (list (cons 1 (strcat "CH " (if (setq ld (nth (strlen (rtos c 2 0)) '(x ""))) ld "") (rtos c 2 2)))) (list (cons 50 (+ b PI))) '((41 . 1.0) (71 . 4) (72 . 5) (210 0.0 0.0 1.0) (73 . 1) ) ) ) )

 MTEXT and Middle Left among other things

 

Message 3 of 19
marlance
in reply to: pbejse

It does not work pbjse.

I tried it just while ago.

Text are missing or not created.

 

But anyway thanks very much for your quick response.

 

Can you modify the lisp and and attach it here?

Message 4 of 19
marlance
in reply to: pbejse

I'm so sorry I forgot to mention the original author of this lisp.

 

Message 5 of 19
Ajilal.Vijayan
in reply to: marlance

 

Add the below highlighted code and try

 

(defun _text (p b o h c)
       (entmake
	 (append
	   '((0 . "TEXT")
	     (100 . "AcDbEntity")
	     (67 . 0)
	     (410 . "Model")
	     (7 . "Arial")
	     (8 . "C-CTRL_TXT")
	     (100 . "AcDbText")
	     )
	   (list (cons 10 (polar p (+ b PI) (* o 1.0)))
		 )
	   (list (cons 40 h))
	   (list (cons 1 (strcat "CH "
				 (if (setq ld (nth (strlen (rtos  c 2 0)) '(x   "")))
				   	ld "")
				 (rtos c 2 2))))
	   (list (cons 50 (+ b PI)))
	   
	   '((41 . 1.0)
	     (51 . 180)
	     (71 . 0)
	     (72 . 0)
	     (11 0.0 0.0 0.0)
	     (210 0.0 0.0 1.0)
	     (100 . "AcDbText")
	     (73 . 2)
	     )
	   )
	 )
	 
	 ;change the Alignemnt
	 (setq txt (entget(entlast)))
	 (setq Align (polar p (+ b PI) (* o 1.0)))
	 (setq txt (subst (cons 11 Align) (assoc 11 txt) txt))
	 (entmod txt)
	 
  )

 

Message 6 of 19
Kent1Cooper
in reply to: marlance


@rulep21 wrote:

.... I want is to change the justification of the text from left to middle left. When I change the dxf code 73 from 0 to 2, all the texts created were place at 0,0.

How can I change the justification of the text to middle left?

....


The 10 code is the left end of the baseline of the text for all justifications, but that's only the insertion point for ordinary Left justification.  For other justifications, the 10 code is a resultant that you wouldn't be able to calculate, and the 11 code is the insertion point.  [For Left justification, the 11 code is always 0,0,0, regardless of the insertion point.]  I think you can just omit the 10 code from the (entmake) list.  Middle left justification is a combination of (72 . 0) and (73 . 2).

 

....

(list (cons 11 (polar p (+ b PI) (* o 1.0))); insertion point [11 instead of 10, or put it below and omit 10 altogether]
   )
    (list (cons 40 h))
    (list (cons 1 (strcat "CH "
     (if (setq ld (nth (strlen (rtos  c 2 0)) '(x   "")))
        ld "")
     (rtos c 2 2))))
    (list (cons 50 (+ b PI)))
   
    '((41 . 1.0)
      (51 . 180)
      (71 . 0)
      (72 . 0)
;;      (11 0.0 0.0 0.0) ; leave this out or put the (polar function above here instead of above
      (210 0.0 0.0 1.0)
      (100 . "AcDbText")
      (73 . 2)

....

Kent Cooper, AIA
Message 7 of 19
pbejse
in reply to: marlance


@rulep21 wrote:

It does not work pbjse.

I tried it just while ago.

Text are missing or not created.

 

But anyway thanks very much for your quick response.

 

Can you modify the lisp and and attach it here?


Works find here rulep21, At first i thought its the TEXT STYLE issue but apparently not, is there any error message? 

 

See attached file

 

Message 8 of 19
marlance
in reply to: pbejse

Hi pbe!

 

thank you for your help.

 

How can I change the textstyle? and is it possible to make the text annotative and put a background mask?

 

 

Message 9 of 19
marlance
in reply to: Ajilal.Vijayan

thanks Ajilal.Vijayan       

 

It  works!!!

Can you please help me again?

I want to change text to mtext and make it annotative with a background mask.

Is it possible?

Message 10 of 19
pbejse
in reply to: marlance


@rulep21 wrote:

Hi pbe!

 

thank you for your help.

 

How can I change the textstyle? and is it possible to make the text annotative and put a background mask?

 

 


Are you using a specific Textstyle? YES and YES. Did the modification even work for you rulep21 ?

 

I havent had a situtation where the program did not work.

 

Message 11 of 19
marlance
in reply to: pbejse

yes i used specific textstyle.
Your lisp work for me.

 

I attach the sample generated by your lisp and what i want to achieve.

 

much appreciate your help pbe

thanks a lot

 

 

 

 

Message 12 of 19
pbejse
in reply to: marlance


@rulep21 wrote:

yes i used specific textstyle.
Your lisp work for me.

 

I attach the sample generated by your lisp and what i want to achieve.

 

much appreciate your help pbe

thanks a lot 


The background Mask is easy. I'll just leave the Annotative thingy and Text Style creation to you. As you may already know, you can set Annotative on the TEXTSTYLE you create. Then modify the code to remove the prompt for height. but you need to replace that part of code to account for the value referencing height variable

 

(defun _text (p b o h c)
;;;  pBe -<-- dont forget to mention the original author dude
       (entmake
	 (append
	   '((0 . "MTEXT")
	     (100 . "AcDbEntity")
	     (67 . 0)
	     (410 . "Model")
	     (7 . "Standard Arial")
	     (8 . "C-CTRL_TXT")
	     (100 . "AcDbMText")
	     )
	   (list (cons 10 (polar p (+ b PI) o))
		 )
	   (list (cons 40 h))
	   (list (cons 1 (strcat "CH "
				 (if (setq ld (nth (strlen (rtos  c 2 0)) '(x   "")))
				   	ld "")
				 (rtos c 2 2))))
	   (list (cons 50 (+ b PI)))
	   
	   '((41 . 0);<-- width issue
	     (90 . 3);<-- Mask
	     (63 . 256)<--Mask
	     (441 . 3935927);<-- Mask 
	     (71 . 4)
	     (72 . 5)
	     (210 0.0 0.0 1.0)
	     (73 . 1)
	     )
	   )
	 )
  )

 

HTH

Message 13 of 19
marlance
in reply to: pbejse

Hi pbe.

 

How can I change the default textstyle to a current textstyle which is already exist in the drawing?

Message 14 of 19
hmsilva
in reply to: marlance


rulep21 wrote:

How can I change the default textstyle to a current textstyle which is already exist in the drawing?


@pbejse I hope you don't mind...

Cheers

 

@marlance at pBe's _text function, remove this code line

 

(7 . "Standard Arial")

 and replace these code lines

 

	   '((41 . 0);<-- width issue
	     (90 . 3);<-- Mask
	     (63 . 256)<--Mask
	     (441 . 3935927);<-- Mask 
	     (71 . 4)
	     (72 . 5)
	     (210 0.0 0.0 1.0)
	     (73 . 1)
	     )

 by these code lines

 

	   (list '(41 . 0)
	     '(90 . 3);<-- Mask
	     '(63 . 256);<--Mask
	     '(441 . 3935927);<-- Mask 
	     '(71 . 4)
	     '(72 . 5)
	     (cons 7 (getvar "textstyle"))
	     '(210 0.0 0.0 1.0)
	     '(73 . 1)
	     )

 

HTH

Henrique

EESignature

Message 15 of 19
marlance
in reply to: hmsilva

hi hm silva.

 

That's what I'm looking for

 

thank you ver much

Message 16 of 19
hmsilva
in reply to: marlance

You're welcome, rulep21

Henrique

EESignature

Message 17 of 19
pbejse
in reply to: hmsilva


@hmsilva wrote:
@pbejse I hope you don't mind...

I dont mind at all Henrique and thank you for your support.

 

Cheers  beer.gif

 

@rulep21

 

Glad it works for you.

 

HTH

Message 18 of 19
hmsilva
in reply to: pbejse


pbejse wrote:

I dont mind at all Henrique and thank you for your support.

 

Cheers  beer.gif

 

 


Cheers, pbejse!

Henrique

EESignature

Message 19 of 19
santosh.loka
in reply to: hmsilva

Your Lisp file working Fine There is a issue with Starting Chainage

your LISP start from 0.000 but

i want to start Chainage from middle 

Example:25.000,25.020....etc.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost