CADjam Posted April 7, 2009 Posted April 7, 2009 Hello All, After trawling the help file and several other CAD forums I still haven't been able to find an easy to use solution to my prob. First post newbie and all, I'd be grateful for anyone's advice... I have c.500 lines of various lengths, spaced at 10m intervals. I can select all of them and use the LIST command, escape out and use F2 to see properties of the lines, but the window only displays the properties of the last 20 or so - not the full 500. I could repeat this over and over for small groups of 20 lines or so, or indeed measure and note down the length of each line individually. As everyone always is(!), I'm after a quicker way by which I could view and perhaps export the lengths of all 500 lines from LtoR as I look at them on the screen (I was planning to merely copy and paste the contents of the LS window and go from there). Any help appreciated and I hope to be able to reciprocate at some point! Cheers. Quote
ReMark Posted April 7, 2009 Posted April 7, 2009 First. Welcome to the CADTutor forum CADjam. Second. Now I'm going tell you to take a hike. LOL Take a hike over to the website of Cadalyst magazine that is. You'll find them at www.cadalyst.com. Look for the CAD Tips tab at the top of the first web page and click on it. At the next page use the Search feature and type in the words line length. The search will bring up several Lisp routines submitted by readers. I think the one most applicable to your situation is the routine called Entity Length. It was written by Julio Monge and submitted 01-JUL-2006. It is tip number 2127 (entlen.lsp). Two more routines that you should check out are Length and Angle by Lynn Owen and Line Length by Bill Bratt. I trust that one of the three will suit your needs. You can reciprocate by reporting back on any or all that you try out and tell us what you think. Thank you. Quote
lpseifert Posted April 7, 2009 Posted April 7, 2009 quick and dirty... worked the one time I tested it (defun c:ll () (vl-load-com) (setq ss1 (ssget '((0 . "line"))); change "line" to "*line" if you want to include plines, splines sslen (sslength ss1) cnt 0) (if (findfile "c:\\linelengths.txt") (setq fn (open "c:\\linelengths.txt" "a")) (setq fn (open "c:\\linelengths.txt" "w")) ) (repeat sslen (setq entname (ssname ss1 cnt) obj (vlax-ename->vla-object entname) len (rtos (vlax-get-property obj 'length) 2 4) ;adjust 4 for decimal precision ) (write-line (strcat "Line# " (rtos(1+ cnt) 2 0) (chr 9) len) fn) (setq cnt (1+ cnt)) ) (write-line (chr 10) fn) (close fn) (startapp "notepad" "c:\\linelengths.txt") (princ) ) Quote
ReMark Posted April 7, 2009 Posted April 7, 2009 Dang. Is the guy above the best dude you ever met or what? Where else could you go to get such good service? AutoDesk? I DON'T THINK SO! 1 Quote
CADjam Posted April 7, 2009 Author Posted April 7, 2009 ReMark thanks for the instruction to take a hike! I got as far as the entlen LISP (which only produces a single output as the sum of all lines), before I spotted lpseifert's response. Works a treat - exactly what I'm after so thanks a plenty!! Quote
fuccaro Posted April 8, 2009 Posted April 8, 2009 There are more ways to skin a line. Here is my: http://www.cadtutor.net/forum/showthread.php?t=1697 Quote
m_shr Posted February 1, 2017 Posted February 1, 2017 thanks for your lisp:) For curved lines What should I do? Quote
ReMark Posted February 1, 2017 Posted February 1, 2017 thanks for your lisp:)For curved lines What should I do? By "curved lines" are you referring to arcs and splines? If so, see my response to the thread you started about the same subject. Quote
m_shr Posted February 1, 2017 Posted February 1, 2017 By "curved lines" are you referring to arcs and splines? yes. i run this lisp in autocad 2015 and appear this error. "error: bad argument type: lselsetp nil Cannot invoke (command) from *error* without prior call to (*push-error-using-command*). Converting (command) calls to (command-s) is recommended." Quote
ReMark Posted February 1, 2017 Posted February 1, 2017 Which lisp routine are you running? Is it the one shown above? Quote
m_shr Posted February 1, 2017 Posted February 1, 2017 quick and dirty... worked the one time I tested it (defun c:ll () (vl-load-com) (setq ss1 (ssget '((0 . "line"))); change "line" to "*line" if you want to include plines, splines sslen (sslength ss1) cnt 0) (if (findfile "c:\\linelengths.txt") (setq fn (open "c:\\linelengths.txt" "a")) (setq fn (open "c:\\linelengths.txt" "w")) ) (repeat sslen (setq entname (ssname ss1 cnt) obj (vlax-ename->vla-object entname) len (rtos (vlax-get-property obj 'length) 2 4) ;adjust 4 for decimal precision ) (write-line (strcat "Line# " (rtos(1+ cnt) 2 0) (chr 9) len) fn) (setq cnt (1+ cnt)) ) (write-line (chr 10) fn) (close fn) (startapp "notepad" "c:\\linelengths.txt") (princ) ) this lisp.this lisp run autocad 2014 correctly. Quote
ReMark Posted February 1, 2017 Posted February 1, 2017 So you're referring to Lee Mac's lisp routine? Quote
m_shr Posted February 1, 2017 Posted February 1, 2017 Which lisp routine are you running? Is it the one shown above? i run lisp in #3 topic. Quote
m_shr Posted February 1, 2017 Posted February 1, 2017 So you're referring to Lee Mac's lisp routine? No for windows 8.1 os. Quote
ReMark Posted February 1, 2017 Posted February 1, 2017 No for windows 8.1 os. I can't help you there. I'm running Windows 7. Everything works...nothing fails. I do not have access to a computer running both Windows 8.1 and AutoCAD so I am unable to test lisp routines under those conditions. Quote
BIGAL Posted February 2, 2017 Posted February 2, 2017 (edited) It may be something to do with "startapp". I am sure I did some stuff at home where I run Win 10 and use startapp no probs. Sorry not Win 8 ;change to test or delete line. ; (startapp "notepad" "c:\\linelengths.txt") Edited February 2, 2017 by BIGAL Quote
BIGAL Posted February 2, 2017 Posted February 2, 2017 Another example ; Code by Alan H jan 2017 ; make a table of objects in particular lengths (vl-load-com) (setvar 'ctab "Model") (setq doc (vla-get-activedocument (vlax-get-acad-object))) (setq curspace (vla-get-modelspace doc)) (defun AH:maketable ( / pt1 numrows numcolumns rowheight colwidth ) (setq pt1 (vlax-3d-point (getpoint "\nPick point for top left hand of table: "))) ; now do table (setq numrows 3) (setq numcolumns 2) (setq rowheight 0.3) (setq colwidth 1. (setq objtable (vla-addtable curspace pt1 numrows numcolumns rowheight colwidth)) (vla-settext objtable 0 0 "Heading 1") (vla-settext objtable 1 0 "Title 1") (vla-settext objtable 1 1 "Title 2") (setq objtable (vlax-ename->vla-object (entlast))) ) ; defun (defun AH:addlinetext ( / ) (if (= (vla-get-TextOverride obj) "") ; if text override has been done (RTOS (vla-get-Measurement obj) 2 2) (RTOS (vla-get-TextOverride obj) 2 2) ) ) (defun AH:addlinet (item1 item2 / obj) (setq rowcnt (vla-get-rows objtable)) (setq rowhgt (vla-getRowHeight objtable 2)) (vla-InsertRows objTable rowcnt rowhgt 1) (vla-settext objtable (- rowcnt 1) 0 item1) ; rows start at 0 (vla-settext objtable (- rowcnt 1) 1 item2) ) ; do a pick exist or add here (defun ah:obj-table ( / objtable obj rowcnt ans) (setq ans (getstring "New table or exist N or E")) (if (= "N" (strcase ans)) (AH:maketable) ; make a table then (setq objtable (vlax-ename->vla-object (car (entsel "Pick existing table")))) ;pick existing ) ; pick multiple objects and check type (while (/= (setq obj (vlax-ename->vla-object (car (entsel "Pick an entity")))) nil) (setq objname (vla-get-objectname obj)) (cond ((= objname "AcDbPolyline") (AH:addlinet "PLine length is" (rtos (vla-get-length obj) 2 2)) ) ((= objname "AcDbText") (AH:addlinet "Part is" (vla-get-textstring obj)) ) ((= objname "AcDbRotatedDimension")(AH:addlinet "Dim is" (AH:addlinetext)) ) ((= objname "AcDbLine") (AH:addlinet "Line length is" (rtos (vla-get-length obj) 2 2)) ) ) ) ) ; AH:obj-table (AH:obj-table) Quote
thebof2001 Posted June 4 Posted June 4 Hi, Im look On 07/04/2009 at 12:38, lpseifert said: quick and dirty... worked the one time I tested it (defun c:ll () (vl-load-com) (setq ss1 (ssget '((0 . "line"))); change "line" to "*line" if you want to include plines, splines sslen (sslength ss1) cnt 0) (if (findfile "c:\\linelengths.txt") (setq fn (open "c:\\linelengths.txt" "a")) (setq fn (open "c:\\linelengths.txt" "w")) ) (repeat sslen (setq entname (ssname ss1 cnt) obj (vlax-ename->vla-object entname) len (rtos (vlax-get-property obj 'length) 2 4) ;adjust 4 for decimal precision ) (write-line (strcat "Line# " (rtos(1+ cnt) 2 0) (chr 9) len) fn) (setq cnt (1+ cnt)) ) (write-line (chr 10) fn) (close fn) (startapp "notepad" "c:\\linelengths.txt") (princ) ) Hi, Im unable to get this to work, what is the command to type in autocad?? I tried line lengths?? I want to get the individual lengths of multiple lines at the same time. Thanks in advance Quote
BIGAL Posted June 5 Posted June 5 (edited) For Plines & LINES. Very crude but matches the request. (defun c:listlens ( / ss x obj) (setq ss (ssget '((0 . "LINE,LWPOLYLINE")))) (if (= ss nil) (progn (alert "No lines selected will now exit try again")(exit) ) (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) (princ (strcat "\n" (rtos (vlax-get obj 'Length) 2 2))) ) ) ) (c:listlens) For code above by Rhebof2001just appload or drag and drop onto cad then type "LL" Just me needs a please select or add new file name. Edited June 5 by BIGAL 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.