Jozi68 Posted July 21, 2009 Posted July 21, 2009 Hi all, I need a simple vb.net routine that will give me the total length of all SELECTED lines, arcs and polylines (all in 2D). Please don't give me lisp, it is greek to me. I am also new at vb.net (coming from vb6). thanx, Jozi68 Quote
Patrick_35 Posted July 22, 2009 Posted July 22, 2009 Hi As you have no answer in vb, I suggest you this lisp (defun c:tot(/ di ent n pt1 pt2 sel) (vl-load-com) (if (ssget '((0 . "LINE,POLYLINE,LWPOLYLINE,ARC,CIRCLE,ELLIPSE,SPLINE,MLINE,REGION,MPOLYGON"))) (progn (setq di 0) (vlax-for ent (setq sel (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)))) (cond ((member (vla-get-objectname ent) '("AcDbLine" "AcDb3dPolyline" "AcDbPolyline")) (setq di (+ di (vla-get-length ent))) ) ((eq (vla-get-objectname ent) "AcDbArc") (setq di (+ di (vla-get-arclength ent))) ) ((eq (vla-get-objectname ent) "AcDbCircle") (setq di (+ di (vla-get-circumference ent))) ) ((member (vla-get-objectname ent) '("AcDbSpline" "AcDbEllipse")) (setq di (+ di (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent)))) ) ((eq (vla-get-objectname ent) "AcDbMline") (setq n 0 pt2 nil) (while (nth n (setq lst (vlax-get ent 'Coordinates))) (setq pt1 (list (nth n lst)(nth (1+ n) lst)(nth (+ n 2) lst))) (and pt2 (setq di (+ di (distance pt1 pt2))) ) (setq pt2 pt1 n (+ n 3) ) ) ) ((member (vla-get-objectname ent) '("AcDbMPolygon" "AcDbRegion")) (setq di (+ di (vla-get-perimeter ent))) ) ) ) (if (eq (vla-get-count sel) 1) (alert (strcat "The length of the object is : " (rtos di))) (alert (strcat "The total length of " (itoa (vla-get-count sel)) " objects is : " (rtos di))) ) (vla-delete sel) ) ) (princ) ) @+ Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.