Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Reply
Message 1 of 3
sachinkhartude
250 Views, 2 Replies

WireLength

Hi

Anyone help me
I want to calculate, let say wire length given in the attached screen snap

Code which can add the lengths of line segment, circle segments, ellipse segments, spline

Thanks
Sachin
2 REPLIES 2
Message 2 of 3

Sachin,

Try this

Warning
When there two or more entites lies on each other the length can be wrong calculated.


Cheers
Harrie Message was edited by: zeha
Message 3 of 3
BillZ
in reply to: sachinkhartude

This was posted here not too long ago:

;;Re: How can I get the total length of several lines?
;; LENGTH.LSP Copyright 2003, Tony Tanzillo
;;
;; Provided for private use only, reproduction or
;; redistribution expressly prohibited.
;;
;; Adds LENGTH command to AutoCAD which when used, will report
;; the total length of all selected 2D curves (including lines,
;; polylines, arcs, splines, and elliptical curves).
;;
;; Does not add length of CIRCLES.

(defun C:LENGTH ( / ss len i)
(vl-load-com)
(setq ss (ssget '((0 . "LINE,ARC,SPLINE,ELLIPSE,POLYLINE,LWPOLYLINE")))
len 0.0
)
(repeat (setq i (sslength ss))
(setq len (+ len (getlength (ssname ss (setq i (1- i))))))
)
(write-line (strcat "\nTotal length = " (rtos len)))
(princ)
)

;---;

(defun getLength (ename / acurve len)
(setq ACurve (vlax-ename->vla-object ename))
(setq len 0.0)
(vl-catch-all-apply
'(lambda ()
(setq len
(vlax-curve-getDistAtParam
ACurve
(vlax-curve-getEndParam ACurve)
)
)
)
)
len
)


Bill

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

Post to forums  

Autodesk Design & Make Report

”Boost