Tharwat Posted September 26, 2013 Posted September 26, 2013 (I assume stepping through with entnext could work to find others?). I am sorry to say it does not work also expect for 3Dpolyline . Try this Vanilla code to get the length of Straight LWpolyline ONLY . (defun length_LW (e / lst d) ;; Author : Tharwat Al Shoufi ;; ;; To get the length of Straight LWpolyline ;; (foreach x (entget e) (if (eq (car x) 10) (setq lst (cons (cdr x) lst)) ) ) (setq d 0.) (while (and lst (not (eq (length lst) 1)) ) (setq d (+ d (distance (car lst) (cadr lst))) lst (cdr lst) ) ) d ) Usage ... (length_LW (car (entsel "\n Select LWpolyline :"))) Quote
CheSyn Posted September 26, 2013 Posted September 26, 2013 @CheSyn (distance l1 l2) does not work with polylines, lines only. Please see the revised code on this page: (if (= "LINE" (cdr (assoc 0 lx)) ) (setq l1 (cdr (assoc 10 lx)) l2 (cdr (assoc 11 lx)) ld (rtos (distance l1 l2) 2 0) ) (setq l1 (cdr (assoc 10 lx)) l2 (cdr (assoc 10 (reverse lx))) ld (rtos (distance l1 l2) 2 0) ) ) I used this to differentiate between lines and polylines (only works for a polyline with 2 vertices). Quote
cmscardoso Posted September 26, 2013 Author Posted September 26, 2013 Well, just to make things a bit more difficult/interesting is it possible to, in the same drawing, and with an addtional block do this: a) get length of the line b) insert length of the line in the METROS_TOTAL attribute of the IDENTIFICACAO_CABO block c) In another block (CARIMBO-DTE) that has the same insert point of the line and IDENTIFICACAO_CABO block, check one attribute (namely TIPO_ACESSO), and check if it has an "A", an "S" or na "F" and, according to that attribute, fill as follow: .:. If it has an "A" - Additionally to put total length of the line in the attribute METROS_TOTAL of the IDENTIFICACAO_CABO block, insert it too in attribute METROS_AEREO .:. If it has an "S" - Additionally to put total length of the line in the attribute METROS_TOTAL of the IDENTIFICACAO_CABO block, insert it too in attribute METROS_CONDUTA .:. If it has an "F" - Additionally to put total length of the line in the attribute METROS_TOTAL of the IDENTIFICACAO_CABO block, insert it too in attribute METROS_FACHADA And now, what i think that is the most difficult task... In the same IDENTIFICACAO_CABO block, the text has always the same length - 02fc/01fa/21m - the first 10 digits are inserted manually, but the next 2 digits, are the length inserted in the field METROS_TOTAL. Is it possible to get that METROS_TOTAL value and insert it after the 10 digits and add a final "m" in the end. Example: XXXX/XXXX/"METROS_TOTAL VALUE"m Basically (or not lol), like the attached drawing :twisted: Thanks in advanceLineLength2BlockAttribute.dxf Quote
CheSyn Posted September 26, 2013 Posted September 26, 2013 I am sorry to say it does not work also expect for 3Dpolyline . Try this Vanilla code to get the length of Straight LWpolyline ONLY . Interesting, I'll study the code you posted. Quote
gS7 Posted September 27, 2013 Posted September 27, 2013 Simply to get LINE,POLYLINE,LWPOLYLINE Length (setq s (car (entsel))) (setq d (vlax-curve-getdistatparam s (vlax-curve-getendparam s))) (princ d) Quote
cmscardoso Posted September 30, 2013 Author Posted September 30, 2013 Well, just to make things a bit more difficult/interesting is it possible to, in the same drawing, and with an addtional block do this: a) get length of the line b) insert length of the line in the METROS_TOTAL attribute of the IDENTIFICACAO_CABO block c) In another block (CARIMBO-DTE) that has the same insert point of the line and IDENTIFICACAO_CABO block, check one attribute (namely TIPO_ACESSO), and check if it has an "A", an "S" or na "F" and, according to that attribute, fill as follow: .:. If it has an "A" - Additionally to put total length of the line in the attribute METROS_TOTAL of the IDENTIFICACAO_CABO block, insert it too in attribute METROS_AEREO .:. If it has an "S" - Additionally to put total length of the line in the attribute METROS_TOTAL of the IDENTIFICACAO_CABO block, insert it too in attribute METROS_CONDUTA .:. If it has an "F" - Additionally to put total length of the line in the attribute METROS_TOTAL of the IDENTIFICACAO_CABO block, insert it too in attribute METROS_FACHADA And now, what i think that is the most difficult task... In the same IDENTIFICACAO_CABO block, the text has always the same length - 02fc/01fa/21m - the first 10 digits are inserted manually, but the next 2 digits, are the length inserted in the field METROS_TOTAL. Is it possible to get that METROS_TOTAL value and insert it after the 10 digits and add a final "m" in the end. Example: XXXX/XXXX/"METROS_TOTAL VALUE"m Basically (or not lol), like the attached drawing :twisted: Thanks in advance [ATTACH]44181[/ATTACH] Can anyone help please? 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.