Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Display a polylines length as MText

Larrycoal35
Explorer
Explorer

Display a polylines length as MText

Larrycoal35
Explorer
Explorer

I'm not sure if there is a better method out there currently but I'm hoping someone knows of a quicker easier method for this.

 

So, I have a drawing with a bunch of a different polylines of various lengths, I need a callout that displays the length of the each individual line.

 

I know I can look at the polylines properties to find the length and enter that into some MText manually but I would like a more automatic method because theres 200+ lines.

 

I'm also aware of the an objects field that I can insert into some MText which will display the length automatically but you have to reenter the field for each line separately and entering a field has good number more steps than just checking the length manually and typing it in. Although I do like the idea of using a field for this since it automatically updates the measurement when any changes are made to the poly line.

 

Any creative ideas on how to achieve this would be greatly appreciated, thanks!

 

 

 

0 Likes
Reply
389 Views
4 Replies
Replies (4)

pendean
Community Legend
Community Legend

@Larrycoal35 wrote:

...Although I do like the idea of using a field for this since it automatically updates the measurement when any changes are made to the poly line....


https://www.lee-mac.com/quickfield.html 

https://www.lee-mac.com/lengthfield.html

and if you need totals

https://www.lee-mac.com/totallengthandarea.html

0 Likes

ChicagoLooper
Mentor
Mentor

Hi @Larrycoal35 

If it were me, it would export (MAPEXPORT command) the line work to shapefile (or SDF) to get the line length.

 

During the export process get the some 'Properties' of the line. In particular, you want to acquire the length of each line as it's shown in the Properties Palette. Once the shapefile is exported you options.

 

OPTION 1:

Add the shapefile to your drawing as a Feature Data Object (FDO) then, using the shapefiles database file (dbf) make length labels for each line. Next, use MAPLABEL2ANN to 'capture' those shapefile labels and convert them to mtext entities. At this point the shapefile can be turned OFF, it's no longer needed. You still have your original linework sitting in modelspace and you'll also have the new mtext labels you just created that display length.

 

 

OPTION 2: 

Use MAPIMPORT command to import the the shapefile. The MapImport procedure will automatically convert the shapefile to plain vanilla AutoCAD line work. No shapefile is added to the drawing because it has been converted from ESRI objects to Autodesk objects.. During the import, 'create Object Data' so the line work will be smart objects, not dumb objects. Next, add the layer hosting the newly imported data to the Map Task Pane. Then using the Map Task Pane, create labels for length from the Object Data you captured earlier during the MapImport procedure. These labels will be plain vanilla mtext entities.

 

If you share your drawing (or a sample of your line work) more info can be provided.

 

Chicagolooper

EESignature

0 Likes

O_Eckmann
Mentor
Mentor

Hi @Larrycoal35 ,

 

You can use annotation template to do the job.

 

Here is the syntax to limit number of decimals. Last number specify number of decimals

For 0 decimal

 (rtos .LENGTH 2 0)

For 2 decimals

 (rtos .LENGTH 2 2)

 

There is just 1 problem with this method : for curved polylignes, label is written in the midlle of virtual link from 1st point to last point, which can be far away.

 

Olivier Eckmann

EESignature

АлексЮстасу
Advisor
Advisor

Hi, @Larrycoal35

 

Try variant - XDLabel.
The XDLABEL_CREATE command will create inscriptions of the desired object property for the specified objects. For example, "Length 2D".
In the first XDLABEL_CREATE window double click on the "Length 2D" property. In the second window select NEAR -- CENTER and other required inscription parameters. You don't have to select anything to try it out. Ok - return to the first window. Select the name of the inscription parameters and Ok.
Appropriate inscriptions will be created and their content will be saved in the XData field "XDT_Label_Create_...".

 

If the shape and position of the objects change, the inscriptions can be updated accordingly with the command XDLABEL_UPDATE.

 

XDLabel is originally designed to create inscriptions from the fields of XData objects. Therefore, it is better to first attach XData objects with the necessary fields for data (lengths, areas, object type designation, etc.). It is easier to do this with our XDTOOLS tools.
But automatic creation of XData "XDT_Label_Create_..." is also provided.

 

We did our experimental XDLabel project trying to replicate the general features of Map 3D styles and annotations. A slight disadvantage of annotations or style labels is that they are not regular AutoCAD elements, but Map 3D objects, meaning that such labels would be proxy objects in other AutoCADs.
XDLabel inscriptions are common AutoCAD primitives.
It is probably not difficult to make a variant of XDLabel based not on XData, but on Map 3D Object Data.

 


-- Alexander, private person, pacifist, english only with translator 🙂 --

Object-modeling _ odclass-odedit.com _ Help

0 Likes