Help centering MTEXT in a command macro

Help centering MTEXT in a command macro

Anonymous
Not applicable
1,168 Views
9 Replies
Message 1 of 10

Help centering MTEXT in a command macro

Anonymous
Not applicable

Hi everyone,

I really felt on the vurge of finally nutting one out for myself but this "_J" and "_MC" options are killing me.  I am wanting to create a bunch of prefilled text notes, could add them to a tool palette and drag and drop as I see fit.  The kind of notes you use all the time in standard jobs.  So I'm basically here at this point:

 

(command
"mtext" (setq pt1 (getpoint "\nSelect Point: ")) (getcorner pt1 "\nSelect Other point:") "GARAGE SLAB\\P F.F.L 99.44" ""
"_.chprop" "_last" "" "_color" 1 "_LA" "LEADERS_&_ANNOTATION" "")

 

Which does indeed work and drops the prefilled text in, changes it to the right layer and color etc.  Only thing is that its LEFT justifying the text.  I need it MIDDLE CENTERED...hence the battling with the 'J' and 'MC' variables.  I've tried putting them in a bunch of places, with and without brackets, quotes etc... every time I do though, my working version falls over and doesn't work anymore.  I'll kick myself when someone shows me but at nearly 1:00am, I'm happy to wear the shame.

 

Thanks everyone.

0 Likes
Accepted solutions (1)
1,169 Views
9 Replies
Replies (9)
Message 2 of 10

ronjonp
Advisor
Advisor

You might take a look at this as well 🙂

0 Likes
Message 3 of 10

Anonymous
Not applicable

Not sure how signing up & becoming a member of another site for helps me..?

0 Likes
Message 4 of 10

ronjonp
Advisor
Advisor

@Anonymous wrote:

Not sure how signing up & becoming a member of another site for helps me..?


Many great solutions on that forum .. that is how it 'might' help you.

ronjonp_0-1625153439338.png

 

0 Likes
Message 5 of 10

Anonymous
Not applicable

Yeah I should have said sorry; I am aware of that TextInsert LISP routine. Doing it with a macro command just seemed less cumbersome & fewer mouse clicks to get the desired text in. Once they were all set up anyway.

I also felt so close to nailing it with what I'd written above..didn't want to let it beat me!

Will check out the suggested site for future reference though, thankyou.

0 Likes
Message 6 of 10

ronjonp
Advisor
Advisor

No worries .. try these three options. The nice thing about entmake is the layer does not have to exist and in 2022 it works as intended. 🍻

 

(defun c:foo (/ p)
  (if (setq p (getpoint "\nPick a point to place mtext: "))
    (entmake (list '(0 . "MTEXT")
		   '(100 . "AcDbEntity")
		   '(8 . "LEADERS_&_ANNOTATION")
		   '(100 . "AcDbMText")
		   (cons 10 p)
		   '(46 . 0.)
		   '(71 . 5)
		   '(62 . 1)
		   '(1 . "GARAGE SLAB\P F.F.L 99.44")
		   '(7 . "Romans")
		   (cons 11 p)
		   '(50 . 0.)
	     )
    )
  )
  (princ)
)

(command "_.mtext"
	 (setq pt1 (getpoint "\nSelect Point: "))
	 "_J"
	 "_MC"
	 (getcorner pt1 "\nSelect Other point:")
	 "GARAGE SLAB\\P F.F.L 99.44"
	 ""
	 "_.chprop"
	 "_last"
	 ""
	 "_color"
	 1
	 "_LA"
	 "LEADERS_&_ANNOTATION"
	 ""
)
;; Hybrid
(defun c:foo2 (/ pt1)
  (command "_.mtext"
	   (setq pt1 (getpoint "\nSelect Point: "))
	   "_J"
	   "_MC"
	   (getcorner pt1 "\nSelect Other point:")
	   "GARAGE SLAB\\P F.F.L 99.44"
	   ""
  )
  (entmod (append (entget (entlast)) '((62 . 1) (8 . "LEADERS_&_ANNOTATION"))))
  (princ)
)

 

 

0 Likes
Message 7 of 10

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

....  I am wanting to create a bunch of prefilled text notes, could add them to a tool palette and drag and drop as I see fit.  ...

(command
"mtext" (setq pt1 (getpoint "\nSelect Point: ")) (getcorner pt1 "\nSelect Other point:") "GARAGE SLAB\\P F.F.L 99.44" ""
"_.chprop" "_last" "" "_color" 1 "_LA" "LEADERS_&_ANNOTATION" "")

....  I need it MIDDLE CENTERED...hence the battling with the 'J' and 'MC' variables.  ....


This works for me in a macro in a Tool Palette button:

^C^C_.-mtext \_j _mc \GARAGE SLAB;F.F.L 99.44;;_.chprop _l ;_c 1 _la LEADERS_&_ANNOTATION ;

Kent Cooper, AIA
0 Likes
Message 8 of 10

Sea-Haven
Mentor
Mentor

Like Ronjonp look at mtext entmake and the codes 71 72 & 73 these can set orientation, I had to do a start end text so needed a left and right mtext.

 

 

0 Likes
Message 9 of 10

Kent1Cooper
Consultant
Consultant

@Sea-Haven wrote:

.... look at mtext entmake and the codes 71 72 & 73 these can set orientation....


You're confusing things by mixing up codes for Text vs. Mtext.  For Mtext, 71 is the justification, but 72 is for drawing direction, and 73 is for line spacing.  For plain Text, 71 is about whether it's backwards and/or upside-down, and it's the combination of the values of 72 & 73 that stores the justification.

Kent Cooper, AIA
0 Likes
Message 10 of 10

Anonymous
Not applicable

Hey everyone,

 

I accepted Kents reply but props and much gratitude to you all as each of your suggestions and solutions worked.  Was just a question of which would was easiest to deploy.  I really do thank everyone that helped me here. Have a great night guys.

 

Brad

0 Likes