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

Polyline Dimension + lenght tag

10 REPLIES 10
Reply
Message 1 of 11
9009676
491 Views, 10 Replies

Polyline Dimension + lenght tag

Hi there!

 

At our work we prefabricate water pipes, for this we need to manually write down the dimension and lenght off the pipe (displayed trough the properties of the polyline). 

 

9009676_0-1726813079065.png

 

Is there any way to automate this?

 

For example get the diameter value from global width, and the length value from the polyline length?

The text needs to stay editable because some segments (all ending segments) need to be +500

 

It would save me LOADS of time

10 REPLIES 10
Message 2 of 11
-didier-
in reply to: 9009676

Bonjour @9009676 

 

Here in a very simple solution, if it suits you as a principle we will look at how to improve it.

 

Amicalement from France

Éternel débutant.. my site for learning : Programmer dans AutoCAD

Didier Aveline

EESignature

Message 3 of 11
9009676
in reply to: -didier-

Hi, 

 

i think this is about what im looking for, but it doesnt work. 

when it always says "100.0" and gives this error: 

9009676_0-1726837821240.png

wich is the correct diameter and lenght of the pline i selected.

 

1 more qeustion, is is possible to round the numbers off without a decimal?

Message 4 of 11
Kent1Cooper
in reply to: 9009676

That error looks like what could happen if the current Text Style is defined for a fixed height but the code assumes it's not [but I haven't examinned the code, and without a drawing file...].

 

EDIT:  Having examined the code, that seems to be the issue.  But I don't understand the intent:

(command "_text" "mc" pins "0.5" "100.0" {... the text content ....} )

With a fixed-height Text Style, the height is not requested, the rotation prompt is what gets answered with "0.5", the content is "100.0", and the intended content is treated as an attempted command.  That's what you're seeing.

But with a non-fixed-height Style, the 0.5 is the height, the rotation is 100, and the content is as intended.  So @-didier- , how are you getting zero-rotation Text out of it?

Kent Cooper, AIA
Message 5 of 11
-didier-
in reply to: 9009676

Hi @9009676 

 

On my screen, the result is :

 

2024-09-20_15-23-39.gif

Please try to type an _ (underscore) before the letters mp in my LSP.

 

Snag_a11e44e.png

For the decimals, what do you need ? Zero decimals ? How should the value be rounded ?

12.49 will be 13 or 12 ?

Amicalement

Éternel débutant.. my site for learning : Programmer dans AutoCAD

Didier Aveline

EESignature

Message 6 of 11
-didier-
in reply to: Kent1Cooper

Hi @Kent1Cooper 

 

Thank You.
I did not think to this parameter, I always give a zero value in my style for the height.

We have to think at ALL possibilities of AutoCAD and the different habit of different people.

 

how are you getting zero-rotation Text out of it?

Because my parameters are gradians for angles, 100 is the value (gradians) of x axis.

 

Then for @9009676 

If your text style has a height in its definition, the line must be :

(command "_text" "_mc" pins "0.0" (strcat "%%C"(rtos ep 2 2) " - " (rtos lon 2 2)))

 

Amicalement

Éternel débutant.. my site for learning : Programmer dans AutoCAD

Didier Aveline

EESignature

Message 7 of 11
sigmmadesigner
in reply to: -didier-

;demande de 9009676
;didier a
;version 00
 
 
It is possible to create a list and inform it before inserting it into the text with the distance
 
 
(defun c:wdialen ( / ent lon ep pins)
(setq BSTC PA (list ("500mm" "600mm" "700mm" "800mm" "900mm" "1000mm"  "1250mm" "1400mm" "1500mm"))
(setq BSTC PS (list ("500mm" "600mm" "700mm" "800mm" "900mm" "1000mm"  "1250mm" "1400mm" "1500mm"))
(setq BSRC (list ("500x500mm" "600x600mm" "700x700mm" "800x800mm" "900x900mm" "1000x1000mm"  "1250x1250mm" "1400x1400mm" "1500x1500mm"))
    (setq ent (vlax-ename->vla-object(car (entsel"\Select a  polyline ...\n"))))
    (setq lon (vlax-get-property ent 'length))
    (setq ep  (vlax-get-property ent 'ConstantWidth))
    (setq pins (vlax-curve-getpointatparam ent 0))
    (command "_text" "mc" pins "0.5" "100.0" (strcat "%%C"(rtos ep 2 2) " - " (rtos lon 2 2)))
    (command "_move" (entlast) "" pins pause)
    )
(prompt "type WDIALEN, Write Diameter Length")
(princ)
 
Message 8 of 11
pkenewell6347
in reply to: 9009676

@9009676 

 

I recommend you try Lee Mac's Quick Field program.

Try the "TEST2" example in the file, you can alter the field values, formatting and prefix to suit your needs. Then you have a field that will up date if the Polyline has been changed.

Message 9 of 11
-didier-
in reply to: sigmmadesigner

Hi @9009676 

 

Memorizing a list is possible, of course, but for which goal ?

If the length of the polyline is not included in the list, what should be written ?

The nearest value?

And in this case : Do I have to change the length of the polyline to be in accordance with what is written?
And from where do I cut or extend the polyline, from the beginning ? From the end ?

Maybe I misunderstood the case

Give examples in a DWG please.

 

Amicalement

 

Éternel débutant.. my site for learning : Programmer dans AutoCAD

Didier Aveline

EESignature

Message 10 of 11
9009676
in reply to: -didier-

This on screen is exactly what i need. i fixed my text height settingd and it works now! there should be 0 decimals! so, 16mm radius 1215mm lenght is displayed as Ø16 - 1215

Message 11 of 11
-didier-
in reply to: 9009676

Bonjour @9009676 

 

OK, then I wrote a new version, with some controls.

  1. If you select another type of entity than a polyline, you will receive a message and the program stop.
  2. If the selected polyline has different widths, you will receive a message and the program stop.
  3. If the current style of text has no height, it will be written with a 25 height, if there is a height in the style definition it will be written with the height in the style.
  4. It will always be written along the X axis, regardless of the definition of angular units.

I hope that these modifications will be useful for your use.

At your disposal if you wish to improve this code.

 

Amicalement

Éternel débutant.. my site for learning : Programmer dans AutoCAD

Didier Aveline

EESignature

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