@steven-g wrote:
But if you want to try creating a macro you could look at using the lengthen command with the percentage option (use 100%) this updates the perimeter variable to read the length of the selected object, and you can then read that variable using diesel. It's doubtful this will help but it is a way to read length information from objects if you enjoy a challenge.
Thankyou Steven, I had no idea that value was stored in a variable. I wish I had known earlier.
Challenge accepted!
Is this what you had in mind? (Tested on LT2013)
*^C^C$m=$(if,$(or,$(eq,$(getenv,pgm_c),0),$(eq,$(getenv,pgm_c),)),_select;"""$m=$(if,$(getvar,cmdactive),\)"""$(if,$(and,$(getvar,menuecho),5),,^p)menuecho;3;$(if,$(and,$(getvar,menuecho),4),^p)_setenv;pgm_c;5)$(if,$(eq,$(getenv,pgm_c),5),_setenv;pgm_pickfirst;$(getvar,pickfirst);;pgm_selectsimilarmode;$(getvar,selectsimilarmode);;pgm_expert;$(getvar,expert);;pgm_clayer;$(getvar,clayer);;pgm_c;10)$(if,$(eq,$(getenv,pgm_c),10),"_setenv;pgm_c;0;_expert;5;_-block;@selset@;0,0;previous;;oops;;_-bedit;@selset@;_zoom;_extents;_-layer;_thaw;`@selset`@;_unlock;`@selset`@;_make;@selset@;;_setenv;pgm_c;15")$(if,$(eq,$(getenv,pgm_c),15),_setenv;pgm_c;0;_selectsimilarmode;0;_pickfirst;1;setenv;pgm_totlen;0;;pgm_c;20)$(if,$(eq,$(getenv,pgm_c),20),"_setenv;pgm_c;0;_line;_none;0,0;_none;10,0;;_selectsimilar;last;;_chprop;_layer;@selset@;;_erase;_last;;_setenv;pgm_c;21")$(if,$(eq,$(getenv,pgm_c),21),"_setenv;pgm_c;0;_pline;_none;0,0;_none;10,0;;_selectsimilar;last;;_chprop;_layer;@selset@;;_erase;_last;;_setenv;pgm_c;22")$(if,$(eq,$(getenv,pgm_c),22),"_setenv;pgm_c;0;_3dpoly;_none;0,0;_none;10,0;;_selectsimilar;last;;_chprop;_layer;@selset@;;_erase;_last;;_setenv;pgm_c;23")$(if,$(eq,$(getenv,pgm_c),23),"_setenv;pgm_c;0;^r_spline;_none;0,0;_none;10,0;;_selectsimilar;last;;_chprop;_layer;@selset@;;_erase;_last;;_setenv;pgm_c;24")$(if,$(eq,$(getenv,pgm_c),24),"_setenv;pgm_c;0;_circle;_none;5,5;5;_selectsimilar;last;;_chprop;_layer;@selset@;;_erase;_last;;_setenv;pgm_c;25")$(if,$(eq,$(getenv,pgm_c),25),"_setenv;pgm_c;0;_arc;_none;0,0;_none;5,5;_none;10,0;_selectsimilar;last;;_chprop;_layer;@selset@;;_erase;_last;;_setenv;pgm_c;26")$(if,$(eq,$(getenv,pgm_c),26),"_setenv;pgm_c;0;_ellipse;_none;0,5;_none;10,5;_none;5,10;_selectsimilar;last;;_chprop;_layer;@selset@;;_erase;_last;;_setenv;pgm_c;30")$(if,$(eq,$(getenv,pgm_c),30),_setenv;pgm_c;0;_selectsimilarmode;$(getenv,pgm_selectsimilarmode);_pickfirst;$(getenv,pgm_pickfirst);_-layer;_off;*;_on;`@selset`@;;expert;$(getenv,pgm_expert);_setenv;pgm_c;loop)$(if,$(eq,$(getenv,pgm_c),loop),_select;_single;_last;"""$m=$(if,$(getvar,cmdactive),^c_setenv;pgm_c;0;_bsave;_bclose;_layerp;;;_-purge;_blocks;`@selset`@;_no;;_layers;`@selset`@;_no;_menuecho;0;_getenv;pgm_msg;$,_setenv;pgm_c;100)""")$(if,$(eq,$(getenv,pgm_c),100),_setenv;pgm_c;0;_lengthen;last;_percent;100;;_erase;_last;;"""$m=_setenv;pgm_totlen;$(+,$(getenv,pgm_totlen),$(getvar,perimeter));;pgm_c;110""")$(if,$(eq,$(getenv,pgm_c),110),_setenv;pgm_msg;""""""""""Total length: $(rtos,$(getenv,pgm_totlen))"""""""""";;pgm_c;loop)
@Anonymous
This macro should do what you are looking for:
Simply select the linear objects (lines, polylines, 3dpolylines, splines, arcs, circles or ellipses) you wish to add up the lengths of and the macro will loop through them and give you the total at the end. The macro filters out any non-linear objects such as text, dimensions, hatches etc. in order to avoid it crashing when it uses the lengthen command to set the perimeter variable. However, I recommend you set up filters to help you select only the objects you want, such as lines on particular layers or polylines with certain widths and colours, for example. The total is displayed in the format determined by your current unit settings.
When pasting the code into the CUI editor, I suggest you open the long string editor in the macro field to make sure it's all copied and check that there are no spaces or returns at the end of the code.
@Johneng Thankyou for recommending my spreadsheet. I'm glad you found it useful.