Mystogan Posted June 28, 2018 Share Posted June 28, 2018 Hi to all, I've been searching all over the net, where I can get a lisp that can give total length not perimeter length. I tried LeeMac and turvill, they both have same result and it is a perimeter length. The scenario, I have closed polyline that form rectangle shape. This rectangle shape is look like a CABLE TRAY and definitely it is a cable tray that electrical section use to route their cable. I need to measure the total length, If I'm going to measure it one by one this will consume a lot of time for me to get the total length.And those object is more than 100 different route and size(width). Hope you can help me Thank you in advance Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 28, 2018 Share Posted June 28, 2018 Did you try the this "weeks post" about 2 days ago this was answered. Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted June 28, 2018 Share Posted June 28, 2018 If I understand the OP correctly he wants the length of the cable tray, not the outline. This is different from the recent post BIGAL seems to refer to. Quote Link to comment Share on other sites More sharing options...
Mystogan Posted June 29, 2018 Author Share Posted June 29, 2018 Yes sir what I need is the length of the cable tray not the perimeter length Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 29, 2018 Share Posted June 29, 2018 Understand now if the cable tray is a known width and a rectangle then you can get the 4 pts of the pline look at length 2 sides subtract the width side and add the other side for a total. You could add also more rules about the width say multiples of. so pt1 pt2 pt3 pt4 len1 pt1-pt2 len2=pt2-pt3 if len1=width skip else add. Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted June 29, 2018 Share Posted June 29, 2018 The main issue is indeed determining which side of the rectangle represents the width: 150x300 -> L=300 or L=150? Another issue: What should happen if trays with different width are selected: 150x300 150x2000 300x2000 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 29, 2018 Share Posted June 29, 2018 Roy_043 I did mention the possibility of various widths in my post and checking for that. I had a further think about this and jumping in to quickly with code we are going about it the wrong way, forget a pline rectang, what should be used is either a block drawn 1x1 in size and scaled in X & Y then its easy to add all the x's, or use a dynamic block, again you can retrieve all the x values and add them up. A dynamic block allows repeat patterns in the block. Going much further it makes sense pick two points, insert multiple trays as they have a maximum length and add the odd last one. Ok I made a block called 200tray it is 200x1 in size inserted and used properties to change its x scale. Made a few of them. Ten minutes all up including coding. (defun AHtray ( / ss len tot) (setq tot 0.0) (setq ss (ssget (list(cons 0 "INsert")))) (repeat (setq x (sslength ss)) (setq len (vla-get-xscalefactor(vlax-ename->vla-object(ssname ss (setq x (- x 1)))))) (setq tot (+ tot len)) ) (alert (strcat "tray length is " (rtos tot 2 2))) (princ) ) (ahtray) Next is to add the start end point max size etc add some error checking but no dwg or rules to compare to. Reminds me of next next step do a table of how many full size and all the odd ones so you have a parts list. Ah yes that other thing that I keep trying to find time to do, uses summing up block attributes. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 29, 2018 Share Posted June 29, 2018 Hi, Just an idea - if the Cable tray is a dynamic block ( which is supposed to be in my believes in this case ) then you can get the lengths of those trays via collecting the distance parameter(s) from the selected block references quite very easily and precisely otherwise can't judge on the outputs if they are just closed rectangles or with L letter shapes as I am a ware of such work. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 29, 2018 Share Posted June 29, 2018 I agree with you Tharwat rethink the whole approach. Straights, L's, Tee's. If I can find it I posted here cabletray.lsp and cabletray2.lsp which was to do with drawing cable trays to a specific style. Remember now tee with radius or chamfer. I am sure a google will reveal cable tray lisp's. The block to table I am working on allows you to select multiple blocks it adds up how many are the same by name and attributes so get a complete list of say a block of multiple sizes. Tharwat would this be useful for your drainage software creating quantities ? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 29, 2018 Share Posted June 29, 2018 ........ Remember now tee with radius or chamfer. I think the measurements supposed to be taken from the center line of those trays regardless of the shape of the tray. The block to table I am working on allows you to select multiple blocks it adds up how many are the same by name and attributes so get a complete list of say a block of multiple sizes. Tharwat would this be useful for your drainage software creating quantities ? Thank you BIGAL, I already wrote one a long time ago which is DRBOM and can be found HERE Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 29, 2018 Share Posted June 29, 2018 I should have looked 1st. Did a google and lots of stuff popped up and like your great drainage option better than reinventing the wheel. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 29, 2018 Share Posted June 29, 2018 I should have looked 1st. No worries at all. Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted July 1, 2018 Share Posted July 1, 2018 (edited) One solution would be to simply add the longest sides of selected polylines. The code only checks if the polylines are closed and have 4 segments that are all straight. (defun KGA_Conv_Pickset_To_EnameList (ss / i ret) (if ss (repeat (setq i (sslength ss)) (setq ret (cons (ssname ss (setq i (1- i))) ret)) ) ) ) (defun CableTrayLength_MaxSide (enm / ptLst) (setq ptLst (vl-remove nil (mapcar '(lambda (sub) (if (= 10 (car sub)) (cdr sub))) (entget enm) ) ) ) (apply 'max (mapcar 'distance ptLst (cons (last ptLst) ptLst) ) ) ) (defun c:CableTrayLength ( / res ss) (if (setq ss (ssget '( (0 . "LWPOLYLINE") (90 . 4) (-4 . "&=") (70 . 1) (-4 . "<NOT") (-4 . "<>") (42 . 0.0) (-4 . "NOT>") ) ) ) (progn (setq res (apply '+ (mapcar 'CableTrayLength_MaxSide (KGA_Conv_Pickset_To_EnameList ss))) ) (princ (strcat "\nTotal length of longest sides is: " (rtos res) ) ) ) ) (princ) ) Edited July 2, 2018 by Roy_043 Added final (princ) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted July 1, 2018 Share Posted July 1, 2018 Roy_043 only problem I had to cut a 300 wide cable tray a 100 mm long to fill a gap. I think its time mystogan stepped in. Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted July 2, 2018 Share Posted July 2, 2018 @BIGAL: Yup, as already discussed, that would be an issue. Quote Link to comment Share on other sites More sharing options...
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.