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

Create a text from a propertie

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
caioribeirodaniel
401 Views, 6 Replies

Create a text from a propertie

caioribeirodaniel
Participant
Participant

Hi all,

 

I need to create a text from a propertie of the line (propertie name from OD group) and integrate it on a lsp file.

 

I've this lsp file that do half of the job:

 

(defun C:LTR (/ lin lindata txt txtdata end1 end2 ang mid)
(setvar 'cmdecho 0)
(while
(not
(and
(setq lin (car (entsel "\n Select LINE with Correct Angle: ")))
(if lin (setq lindata (entget lin)))
(= (cdr (assoc 0 lindata)) "LINE")
); end and
); end not
(prompt "\nNothing selected, or not a Line -- try again.")
); end while
(redraw lin 3)
(while
(not
(and
(setq txt (car (entsel "\n Select TEXT to center on and align with Line: ")))
(if txt (setq txtdata (entget txt)))
(= (cdr (assoc 0 txtdata)) "TEXT")
(= (cdr (assoc 70 (tblsearch "layer" (cdr (assoc 8 txtdata))))) 0); unlocked Layer
); end and
); end not
(prompt "\nNothing selected, or not Text, or on a locked Layer -- try again.")
); end while
(setq
end1 (cdr (assoc 10 lindata))
end2 (cdr (assoc 11 lindata))
ang (angle end1 end2)
mid (mapcar '/ (mapcar '+ end1 end2) '(2 2 2))
); end setq
(if (< (/ pi 2) ang (* pi 1.5)) (setq ang (+ ang pi))); Text in more upright direction
(setq
txtdata (subst (cons 50 ang) (assoc 50 txtdata) txtdata); rotation
txtdata (subst '(72 . 1) (assoc 72 txtdata) txtdata); justification Center
txtdata (subst '(73 . 0) (assoc 73 txtdata) txtdata); justification [0 for plain Center, 1 for Bottom Center]
); end setq
(entmod txtdata)
(command; avoids need to calculate (assoc 10) value for (subst)
"_.move" txt ""
(cdr (assoc 11 txtdata)); original insertion point
(polar mid (+ ang (/ pi 2)) (getvar 'dimscale)); new insertion point
); end command
(redraw lin 4)
(setvar 'cmdecho 1)
(princ)
); end defun

 

But I need that the text used was generated from the line.

0 Likes

Create a text from a propertie

Hi all,

 

I need to create a text from a propertie of the line (propertie name from OD group) and integrate it on a lsp file.

 

I've this lsp file that do half of the job:

 

(defun C:LTR (/ lin lindata txt txtdata end1 end2 ang mid)
(setvar 'cmdecho 0)
(while
(not
(and
(setq lin (car (entsel "\n Select LINE with Correct Angle: ")))
(if lin (setq lindata (entget lin)))
(= (cdr (assoc 0 lindata)) "LINE")
); end and
); end not
(prompt "\nNothing selected, or not a Line -- try again.")
); end while
(redraw lin 3)
(while
(not
(and
(setq txt (car (entsel "\n Select TEXT to center on and align with Line: ")))
(if txt (setq txtdata (entget txt)))
(= (cdr (assoc 0 txtdata)) "TEXT")
(= (cdr (assoc 70 (tblsearch "layer" (cdr (assoc 8 txtdata))))) 0); unlocked Layer
); end and
); end not
(prompt "\nNothing selected, or not Text, or on a locked Layer -- try again.")
); end while
(setq
end1 (cdr (assoc 10 lindata))
end2 (cdr (assoc 11 lindata))
ang (angle end1 end2)
mid (mapcar '/ (mapcar '+ end1 end2) '(2 2 2))
); end setq
(if (< (/ pi 2) ang (* pi 1.5)) (setq ang (+ ang pi))); Text in more upright direction
(setq
txtdata (subst (cons 50 ang) (assoc 50 txtdata) txtdata); rotation
txtdata (subst '(72 . 1) (assoc 72 txtdata) txtdata); justification Center
txtdata (subst '(73 . 0) (assoc 73 txtdata) txtdata); justification [0 for plain Center, 1 for Bottom Center]
); end setq
(entmod txtdata)
(command; avoids need to calculate (assoc 10) value for (subst)
"_.move" txt ""
(cdr (assoc 11 txtdata)); original insertion point
(polar mid (+ ang (/ pi 2)) (getvar 'dimscale)); new insertion point
); end command
(redraw lin 4)
(setvar 'cmdecho 1)
(princ)
); end defun

 

But I need that the text used was generated from the line.

6 REPLIES 6
Message 2 of 7

ВeekeeCZ
Consultant
Consultant

Post dwg with the example of such attributed line and desired output.

0 Likes

Post dwg with the example of such attributed line and desired output.

Message 3 of 7

caioribeirodaniel
Participant
Participant

Here is an example.

I need to generate a text with the attribute name of the red lines on click, with the same situations as the line.

The red lines without this attribute dont need to do nothing. Actually i'm using and setting the command MAPANNTEMPLATE and MAPANNINSERT but a lot of texts came desconfigured and I don't all texts, because that, the generation on click will save me.

0 Likes

Here is an example.

I need to generate a text with the attribute name of the red lines on click, with the same situations as the line.

The red lines without this attribute dont need to do nothing. Actually i'm using and setting the command MAPANNTEMPLATE and MAPANNINSERT but a lot of texts came desconfigured and I don't all texts, because that, the generation on click will save me.

Message 4 of 7

CADaSchtroumpf
Advisor
Advisor

Hi,

After have loaded the two lisp.

Select ONE polyline by grips what have a the table "Santa_Cruz_do_Capibaribe_"

In line command write the command : sel_by_od

Choose the table "Santa_Cruz_do_Capibaribe_"

and for the name, change the name finded by "*" (jocker)

The fonction must select 706 polylines with grips what have the table "Santa_Cruz_do_Capibaribe_" and a different name.

 

Then in line command write the command : OD2Label_Side

Select the field name.

Give for exemple an heigth of text at 3.5 units, and job is finish...

0 Likes

Hi,

After have loaded the two lisp.

Select ONE polyline by grips what have a the table "Santa_Cruz_do_Capibaribe_"

In line command write the command : sel_by_od

Choose the table "Santa_Cruz_do_Capibaribe_"

and for the name, change the name finded by "*" (jocker)

The fonction must select 706 polylines with grips what have the table "Santa_Cruz_do_Capibaribe_" and a different name.

 

Then in line command write the command : OD2Label_Side

Select the field name.

Give for exemple an heigth of text at 3.5 units, and job is finish...

Message 5 of 7

caioribeirodaniel
Participant
Participant

Thank you! This will help me a lot.

Has a way to make the appears seven metters perpendicular from the origin line and/or set his height in seven metters?

0 Likes

Thank you! This will help me a lot.

Has a way to make the appears seven metters perpendicular from the origin line and/or set his height in seven metters?

Message 6 of 7

CADaSchtroumpf
Advisor
Advisor
Accepted solution

I introduced a write offset in the code (Déport pour l'écriture? <0.0>:)

0 Likes

I introduced a write offset in the code (Déport pour l'écriture? <0.0>:)

Message 7 of 7

caioribeirodaniel
Participant
Participant
Thanks!
0 Likes

Thanks!

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report