Get polyline length total by layer in table

Get polyline length total by layer in table

paliwal222
Advocate Advocate
12,022 Views
27 Replies
Message 1 of 28

Get polyline length total by layer in table

paliwal222
Advocate
Advocate

Dear all,

Need a lisp  or lisp customization for total length of polyline by layer and color display also.

here i attached a  drawing and lisp also.

I will very thankful for getting help.

0 Likes
Accepted solutions (1)
12,023 Views
27 Replies
Replies (27)
Message 2 of 28

CADaSchtroumpf
Advisor
Advisor
Accepted solution

Hi,

Your lisp modified for length

Message 3 of 28

paliwal222
Advocate
Advocate
Dear Sir Bruno.
Thanks a lot for all this.
Thanks Very much.

0 Likes
Message 4 of 28

trunghieu.218
Participant
Participant

@CADaSchtroumpf 

hi,
Can you add 1 more column to count like in the picture?

the table uses Tahoma font and can scale when inserting if possible.
Thanks!

LENGTH BY LAYERWISE WITH COLOR.png

0 Likes
Message 5 of 28

Automohan
Advocate
Advocate

To add one more column - change this

(setq Area_table (vlax-invoke (vlax-get (vla-get-ActiveLayout (vla-get-activedocument (vlax-get-acad-object))) 'Block )
'Addtable (getpoint "\nPick point for Table:") 2 4 1500 7000 ) )

For new column title Count - change this

(list '(0 "Category") '(1 "Total Length") '(2 "Count") '(3 "Colour"))

& change this

(vla-SetCellBackgroundColor Area_table crow 3 clr)

for the count of polylines vs layers i was working

 

"Save Energy"
Did you find this reply helpful? If so please use the Accept as Solution
Message 6 of 28

trunghieu.218
Participant
Participant

I followed your instructions, the result only added 1 column without the number of objects.

2023-03-15_201014.png

 

0 Likes
Message 7 of 28

CADaSchtroumpf
Advisor
Advisor

 

@trunghieu.218 

To get the results, you have to do a little more, try with this

Message 8 of 28

trunghieu.218
Participant
Participant

This is exactly what I needed, Thank you so much.

I have a question is it possible to choose the font for the table, for example Tahoma font?

0 Likes
Message 9 of 28

Automohan
Advocate
Advocate

Create a new table style with Tahoma font style as shown in below image & set to current

You have change all the three data, title & header font style to Tahoma & run the lisp

Table setting.png

"Save Energy"
Did you find this reply helpful? If so please use the Accept as Solution
Message 10 of 28

trunghieu.218
Participant
Participant

Thank you for your reply, I mean to change the font in this lisp.

0 Likes
Message 11 of 28

CADaSchtroumpf
Advisor
Advisor

@trunghieu.218  a écrit :

Thank you for your reply, I mean to change the font in this lisp.


I hope that is good

0 Likes
Message 12 of 28

trunghieu.218
Participant
Participant

This is awesome, thanks again for your help

0 Likes
Message 13 of 28

Automohan
Advocate
Advocate

I was trying to create 2 fonts at the same time, but error appears help to fix !

(defun c:my_font_style ( / nw_style pr val )
(if (null (tblsearch "STYLE" "Bradley Hand ITC,Calibri"))
              (setq nw_style (vla-add (vla-get-textstyles (vla-get-ActiveDocument (vlax-get-acad-object))) "Bradley Hand ITC,Calibri"))
              (mapcar '(lambda (pr val) (vlax-put nw_style pr val))
              (list 'FontFile 'Height 'ObliqueAngle 'Width 'TextGenerationFlag)
              (list (strcat (getenv "windir") "\\fonts\\Bradley Hand ITC,Calibri.ttf") 0.0 0.0 1.0 0.0))) (princ))

my_font_style ; error: Automation Error. Calling method SetObjectId of interface IAcadBaseObject failed

"Save Energy"
Did you find this reply helpful? If so please use the Accept as Solution
0 Likes
Message 14 of 28

CADaSchtroumpf
Advisor
Advisor

I will write it like this:

(defun c:my_font_style ( / nw_style)
  (mapcar
    '(lambda (x)
      (cond
        ((null (tblsearch "STYLE" x))
          (setq nw_style (vla-add (vla-get-textstyles (vla-get-ActiveDocument (vlax-get-acad-object))) x))
          (mapcar '(lambda (pr val) (vlax-put nw_style pr val))
            (list 'FontFile 'Height 'ObliqueAngle 'Width 'TextGenerationFlag)
            (list (strcat (getenv "windir") "\\fonts\\" (if (eq x "Calibri") "Calibri.ttf" "BRADHITC.ttf")) 0.0 0.0 1.0 0.0)
          )
        )
      )
    )
    '("Bradley Hand ITC" "Calibri")
  )
  (princ)
)

In your previous code, pay attention to the (if which can require a (progn if several actions are required, otherwise only the first action is validated if the condition is true, the next one is executed if the condition is false.
Some fonts do not have the same name in description with the name of the file itself...

Message 15 of 28

Automohan
Advocate
Advocate

This is awesome, thanks for your help

"Save Energy"
Did you find this reply helpful? If so please use the Accept as Solution
0 Likes
Message 16 of 28

Automohan
Advocate
Advocate

Same method I was trying for dimstyles

(defun c:my_dim_style ( / nw_style)
  (mapcar '(lambda (x)
      (cond ((null (tblsearch "STYLE" x))
         (setq nw_style (vla-add (vla-get-dimstyles (vla-get-ActiveDocument (vlax-get-acad-object))) x))
         (mapcar '(lambda (pr val) (vlax-put nw_style pr val))

; Need to complete

(princ))

 

"Save Energy"
Did you find this reply helpful? If so please use the Accept as Solution
0 Likes
Message 17 of 28

Sea-Haven
Mentor
Mentor

Making a dim style can be short or real long, depends on how intricate you want to get.

 

(entmake
(list
(cons 0 "DIMSTYLE")
(cons 100 "AcDbSymbolTableRecord")
(cons 100 "AcDbDimStyleTableRecord")
(cons 2 styname) ;Dim style name
(cons 70 0)
(cons 40 1) ;DIMSCALE-sets the overall scale factor applied to all dimensions
(cons 41 2.0) ;DIMASZ-sets the size of the arrow/tick
(cons 46 2) ;DIMDLE-sets the distance the dimension line extends beyond the extension line
(cons 140 Text_Height) ;DIMTXT-specifies the height of the text in the dim
(cons 340 (tblobjname "style" yourtextstyle)); DIMTXSTY
)
)

Sorry dont know where I got this.

(entmake
(list
(cons 0 "DIMSTYLE")
(cons 100 "AcDbSymbolTableRecord")
(cons 100 "AcDbDimStyleTableRecord")
(cons 2 Dim_Name) ;Dim style name
(cons 70 0) ; Standard flag
(cons 3 " [m]"); DIMPOST
(cons 4 ""); DIMAPOST
(cons 5 DIMBLK-Name) ;DIMBLK-Name of block instead of default arrowhead
(cons 6 DIMBLK-Name);(cons 6 "ClosedFilled"); DIMBLK1
(cons 7 "");(cons 7 DIMBLK-Name); DIMBLK2
(cons 170 0) ;DIMALT-turns off alternate units
(cons 40 dimscale) ;DIMSCALE-sets the overall scale factor applied to all dimensions
(cons 41 Arrow_Size) ;DIMASZ-sets the size of the arrow/tick
(cons 42 Extension_Line_Origin_Offset); DIMEXO
(cons 43 Dimension_Line_Spacing); DIMDLI
(cons 44 Extension_Above_Dimension_Line) ;DIMEXE-specifies how far to extend the extention line beyound the dim line
(cons 45 0.0); DIMRND
(cons 46 0) ;DIMDLE-sets the distance the dimension line extends beyond the extension line
(cons 47 0.0); DIMTP
(cons 48 0.0); DIMTM
(cons 71 0); DIMTOL
(cons 72 0); DIMLIM
(cons 73 0) ;DIMTIH-controls the position of dimension text inside extention lines ;METTE IL TESTO DI QUOTA ORIZZONTALE
(cons 74 0) ;DIMTOH-controls the position of dimension text outside extention lines
(cons 75 1); DIMSE1 ;1 sopprime la linea di estensione, 0 la lascia
(cons 76 1); DIMSE2 ;1 sopprime la linea di estensione, 0 la lascia
(cons 77 1) ;DIMTAD-controls the vertical position of text in relation to the dim line
(cons 78 3) ;DIMZIN-controls the suppression of zeros
(cons 79 1); DIMAZIN
(cons 140 Text_Height) ;DIMTXT-specifies the height of the text in the dim
(cons 141 Center_Mark_Size); DIMCEN
(cons 142 0.0); DIMTSZ
(cons 143 0.5) ;DIMALTF-controls the scale factor for alt. units
(cons 144 quote_scale); DIMLFAC ;scala di quota
(cons 145 0.0); DIMTVP
(cons 146 0.64); DIMTFAC
(cons 147 Gap_From_dimension_Line_to_Text) ;DIMGAP-sets the distance from around the dim text
(cons 170 0); DIMALT
(cons 171 2) ;DIMALTD-controls the decimal places for units
(cons 172 0) ;DIMTOFL-forces a line inside extension lines
(cons 173 1); DIMSAH
(cons 174 0); DIMTIX
(cons 175 0); DIMSOXD
(cons 176 256); DIMCLRD
(cons 177 256); DIMCLRE
(cons 178 256); DIMCLRT color of text 
(cons 179 0); DIMADEC
(cons 270 2) ;DIMUNIT-sets the units format for all dims ;2 decimale ; 4architettonico
(cons 271 Decimal_Places) ;DIMDEC-sets the number of decimal places of primary units
(cons 272 Tolerance_Decimal_places); DIMTDEC
(cons 273 2) ;DIMALTU-sets the units for alt. units
(cons 275 0) ;DIMAUNIT-sets the angular format for angular dims
(cons 276 1); DIMFRAC
(cons 277 2); DIMLUNIT ;2 decimale ; 4architettonico
(cons 278 0); DIMDSEP
(cons 279 Text_Movement); DIMTMOVE
(cons 280 0) ;DIMJUST-controls the horizontal positioning of dim text
(cons 281 -1); DIMSD1
(cons 282 -1); DIMSD2
(cons 283 1); DIMTOLJ
(cons 284 3); DIMTZIN
(cons 285 1); DIMALTZ
(cons 286 0) ;DIMALTTZ-Toggles the suppression in tolerance values
;(cons 287 0); DIMFIT
;(cons 288 0); DIMUPT
;(cons 289 0); DIMATFIT
(cons 340 (tblobjname "style" "Estilo_Cotas")); DIMTXSTY
;(cons 341 (cdr (assoc 330 (entget (tblobjname "block" "."))))); DIMLDRBLK 
;(cons 342 (cdr (assoc 330 (entget(tblobjname "block" "_Oblique"))))); DIMBLK must setvar dimblk 1st 
;(cons 343 (cdr (assoc 330 (entget(tblobjname "block" "_Oblique"))))); DIMBLK1
;(cons 344 (cdr (assoc 330 (entget(tblobjname "block" "_Oblique"))))); DIMBLK2
;(cons 371 -2); DIMLWD
;(cons 372 -2); DIMLWE
)
)
0 Likes
Message 18 of 28

eeedeiva
Community Visitor
Community Visitor

This very useful, thank you so much but I need one step, can you modify this lisp with only selection of unlock polyline

0 Likes
Message 19 of 28

symoin
Enthusiast
Enthusiast

is it possible to get the area of closed polylines in sqm, and length if polyline is not closed.

Something like an extra column for closed polylines (polygons).

0 Likes
Message 20 of 28

caominhnguyen85
Explorer
Explorer

Hi Bro , could you help to create that lisp similar but it not need to total length ? I mean the result just Layer - length - qty 

0 Likes