want to add mtext pointer(leader) in existed lisp

want to add mtext pointer(leader) in existed lisp

miroslav.pristov
Advocate Advocate
1,279 Views
14 Replies
Message 1 of 15

want to add mtext pointer(leader) in existed lisp

miroslav.pristov
Advocate
Advocate

Hello all,

 

i need help in making typical leader (pointer) for my L steel profiles.

 

the leader (pointer) looks like the one bellow on picture, and i attach the example file too from which i made picture.

 

I alreday have a lisp in which i have input data values "A","B","C1","C2","D" and "E", calculated dimension "rast" and insert point T1, i only need a few lines which will do this what i want.

 

I need to make some polyline T1-TA-TB where TA if defined as 100 in X, and 100 in Y, direction from T1, and TB is defined as 100 in X, and (100 + lenght of mtext) in Y direction from point T1. Points TA and TB also represents the lower corners of Mtext (TA left corner, TB right corner). the corners of MTEXT should fit the text inside

 

Those dimension lines in picture is only for understanding the problem. there is no need lisp to draw them, also there is no need that the color of the polyline to be magenta just by the layer.

 

The MTEXT should look on the way I describe on the picture bellow. if you dont have font gradj and i presume you dont, then use some other standard and i will change it letter. The corners of MTEXT should fit the text inside

 

thanks for help

 

 

 

picture 1.jpg

0 Likes
1,280 Views
14 Replies
Replies (14)
Message 2 of 15

devitg
Advisor
Advisor

Hi Miroslav , if you can use , as a base , your MTEXT sample , it is easy to do . 

 

What I mean , you have to do ,"by hand" , at least one MTEXT sample . 

 

By this way it can be do , as per my known . 

 

The core is here 

 

Pick the sample mtext 

geting  its TEXTSTRING  or DXF code 1 for it , i got it 

 

"{\\fArial Narrow|b1|i0|c0|p34;\\L01\\fArial Narrow|b0|i0|c0|p34;\\H0.625x;\\l \\fgradj|b0|i0|c0|p34;\\H0.88x;l\\fArial Narrow|b0|i0|c0|p34;\\H1.136x;50.50.5...585}"

I dig it , an notice that you can rebuild it as follow 

 

(setq order (itoa 02))

(setq rast "50.50.5...585")

(setq new-text (strcat "{\\fArial Narrow|b1|i0|c0|p34;\\L" order "\\fArial Narrow|b0|i0|c0|p34;\\H0.625x;\\l \\fgradj|b0|i0|c0|p34;\\H0.88x;l\\fArial Narrow|b0|i0|c0|p34;\\H1.136x;" rast "}" ))

Then you can entmake the new MTEXT by entmake 

 

(entmake 
(list
  '(0 . "MTEXT")
  '(100 . "AcDbEntity")
  '(67 . 0)
  '(410 . "Model")
  '(8 . "Layer1")
  '(100 . "AcDbMText")
  (cons 10  (list (+ 1500 49578.4) -10134.7 0.0))
  '(40 . 40.0)
  '(46 . 0.0)
  '(71 . 1)
  '(72 . 5)
  (cons 1 new-text)
  '(7 . "STANDARD")
  '(210 0.0 0.0 1.0)
  '(11 1.0 0.0 0.0)
  '(50 . 0.0)
  '(73 . 1)
  '(44 . 1.0)
)

)

Then you must 

 

(setq new-mtext (entget (entlast)))

From it you have to get the width as it is the 42 DXF code 

 

(setq width (cdr (assoc 42 new-mtext)))

From now , you can build your t1, ta, tb, points . 

 

(cons 10  (list (+ 1500 49578.4) -10134.7 0.0))

this 10 dxf code is ramdom , it shall be your ta point 

 

 

I change wellow  ,as I use almost whit background 

 

 

Hope it is clear  . 

 

 

 

Find attached what I did 

 

 

 

 

 

 

 

 

 

 

 

 

 

0 Likes
Message 3 of 15

miroslav.pristov
Advocate
Advocate

thank you this is great, i ll follow your advice

0 Likes
Message 4 of 15

devitg
Advisor
Advisor

Miroslav , glad to know it can help you . Please show me how do you cope it.

 

As I´m not a drafter , but a LISP authodidactic , I star Lisping at 2000,    I ussually make it combining what ACAD can do,  with LISP can do. 

 

I often see Lisp that start from a white page. Asking for textsize, all-styles, all-type Why not to use  a base ?, just the way you would do if no LISP is at hand . 

 

We have to take advantage of each one.

 

Let some task to do by ACAD, others by AUTO-LISP , and last but not least by VL functions .

 

Last week I was asked to label Polilynes Length  , so I ask user to show me  how it made by "hand"  , so I take the length text  , make a copy by VLA-copy ,  change its textstring, by  the VLA-get-length,   and move where the user want to. 

 

 it's enough to see it clear , to see it  simple.  

 

 

 

 

 

 

 

0 Likes
Message 5 of 15

miroslav.pristov
Advocate
Advocate
(setq rast "50.50.5...585")

can someone please help me how to change this line that the "50.50.5...585" be a combination of input data and text.

 

50 is sum of input data (A+B)

5 is input data C

585 is code calculated data D

all points are text values

 

Thank you

0 Likes
Message 6 of 15

devitg
Advisor
Advisor
Please give me the way you get A B C D



--

Nombre: Gabriel
Apellido: CALÓS
SERVICIOS MECATRÓNICOS ®
DUCASSE 948
CÓRDOBA
(X5000FVF)
ARGENTINA
TEL 054-351-471-0256
CEL 0351-156-192177
devitg@gmail.com

"la victoria es propicia a los que se preparan"

AMAT VICTORIA CURAM
0 Likes
Message 7 of 15

miroslav.pristov
Advocate
Advocate
  (setq t7 (getpoint "\n First point A "))
  (setq t8 (getpoint "\n Second point B "))

  (setq a (getreal "\n Insert dimension a: "))
  (setq b (getreal "\n Insert dimension b: "))
  (setq c1 (getreal "\n Insert dimension c1: "))
  (setq c2 (cond ((getreal (strcat "\n Insert dimension c2 <" (rtos c1 2 0) ">: ")))
		 (c1)))
  (setq d (getreal "\n Insert dimension d: "))

  (setq ang (angle t7 t8)
	anp (+ ang (* pi 0.5)))
  (setq rast (distance t7 t8))

This is part of my code with input data. So as i mentioned, in example 50.50.5...585, the 50's represent the sum of a and b (a+b), 5 are d, and the 585 will be sum of rast,c1 and c2 (rast+c1+c2). Rast is distance berween two points.

 

I have a problem how to join variables and points and to make new mtext which member devitg explain me few messages before. 

 

You can write me a code, but i ll be very grateful if you explain me what you do in it. Thank you

0 Likes
Message 8 of 15

devitg
Advisor
Advisor

Guess it 

 

 

(Setq a 30)
(setq b 20)
(setq d 5 )
(setq rast 500)
(setq c1 80)
(setq c2 5)
(setq period ".")

it is solve so 

   

 

(setq text (strcat (rtos (+ a b)2 0) period (rtos (+ a b)2 0)
period (rtos d 2 0) period period period (rtos (+ rast c1 c2)2 0)))

 You can change the 0 value to set decimal part 

 

 

 

"50.50.5...585" 

 

 

0 Likes
Message 9 of 15

miroslav.pristov
Advocate
Advocate

Hello devitg,

 

You said that you would help me when i wrote the code if i had a problem. Now i have it. i wrote the code with your instructions and i have the problem with adding text on TA point, making TB point and line between TA and TB point. i must say i didnt understand your explanation of entmake and random 10 dxf code which shall be my TA point. In example code i defined TA point as point t17.

 

I ll attach the example file with more explanation of problem and the code i wrote. If you have time please take a look.

 

P.S. error i got is bad argument type: stringp 25.0

0 Likes
Message 10 of 15

devitg
Advisor
Advisor

Your entmake shall be seen as follow 

 

 

 

((-1 . <ENTITY NAME: -1370B8>)
(0 . "MTEXT")
(330 . <ENTITY NAME: -13A3F0>)
(5 . "6909")
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
(8 . "Layer1")
(100 . "AcDbMText")
(10 56437.8 -10184.6 0.0) ;51078.4
(40 . 40.0)
(41 . 304.152)
(46 . 0.0)
(71 . 1)
(72 . 5)
(1 . N)
(210 0.0 0.0 1.0)
(11 0.967607 0.252463 0.0) (42 . 282.576) (43 . 48.1364) (50 . 0.255225) (73 . 1) (44 . 1.0))

 

 

 

 

 

0 Likes
Message 11 of 15

miroslav.pristov
Advocate
Advocate

i cant load lisp at all ; error: extra cdrs in dotted pair on input

0 Likes
Message 12 of 15

devitg
Advisor
Advisor

It is not a lisp , you have to deal with DXF codes Values like it in red . 

 

What I show you is the ENTGET from the MTEXT you have at the DWG . Mtext has 2 values for insertion 10 and 11 , and it depeneds of text aligment mode.

 

 

 

 

 

0 Likes
Message 13 of 15

miroslav.pristov
Advocate
Advocate

hm. so you say i cant add this in my example lisp i attached before. it wont work?

0 Likes
Message 14 of 15

devitg
Advisor
Advisor

Erase your MTEXT sample , at the rigth , an run it 

 

 

(entmake 
(list 
  '(0 . "MTEXT")
  '(100 . "AcDbEntity")
  '(67 . 0)
  '(410 . "Model")
  '(8 . "Layer1")
  '(100 . "AcDbMText")
  (cons 10 (list 56437.8 -10184.6 0.0))  ;51078.4 
  '(40 . 40.0)
  '(41 . 304.152);Width 
  '(46 . 0.0)
  '(71 . 1)
  '(72 . 5)
  (cons 1   new-mtext)
  '(7 . "STANDARD")
  (cons 210  (list 0.0 0.0 1.0))
  (cons   11 (list 0.967607 0.252463 0.0))
  '(42 . 282.576)
  '(43 . 48.1364)
  '(50 . 0.255225); angle in radian 
  '(73 . 1)
  '(44 . 1.0))
)

See what happens 

0 Likes
Message 15 of 15

miroslav.pristov
Advocate
Advocate

Did it work for You. Maybe i dont know how to start it. I always got ; error: bad DXF group: (1). Is there a chance to make this work in my example lisp?

0 Likes