Extract/list line properties - urgent!

Hi,

We've hit a pretty big problem with some in-house software we were using to parse DXF data. We therefore need to find a quick fix. This involves being able to list the StartX, EndX, StartY and EndY properties of a load of lines on a specific layer. We then need to output these as a CSV file, so we need to list like this:

startX, endX, startY, endY startX, endX, startY, endY

If necessary, we could just have this dumped to the text window and we could save it off using notepad. however, we've got to do this for quite a lot of different blocks, so it would be good if it could actually save the text file... I have no idea if this is possible though?

So in summary, we need to list and output the startX, endX, startY and endY values for a number of lines. We need to do this across a number of blocks too.

Any help would be greatly appreciated and would save me from going crazy with stress!!

Many thanks in advance,

AT

Reply to
Andrew Thelwell
Loading thread data ...

HiHo; here is a lisp tip from Cadalyst the will give you a suggestion for extracting the X and Y coordinate from selected lines. ................................................................. ;Tip1442: ADDLINES.LSP Length of Lines (c)1998, Travis Knapp

;routine to get the sum of the lengths of all selected "LINES" (defun c:addlines (/ ss1 total count n1 n2 pnt10 pnt11 dist total) (graphscr) (prompt "\nSelect the Lines to be Added together:") (setq ss1 (ssget (list (cons 0 "line")))) (setq total 0) (setq count (sslength ss1)) (while (/= count 0) (setq N1 (ssname ss1 0)) (setq N2 (entget N1)) (setq pnt10 (cdr (assoc 10 N2))) (setq pnt11 (cdr (assoc 11 N2))) (setq dist (distance pnt10 pnt11)) (setq total (+ dist total)) (ssdel n1 ss1) (setq count (1- count)) );end while (prompt " Length of Lines Equal : ") (princ (rtos total 2 4)) (terpri) (princ) ); end program ..................................................................... Take a look at (cdr (assoc 10 N2)) and (cdr (assoc 11 N2)) Hope this helps.

Reply to
bestafor

Here is a modified version of the cadalyst addlines code. This should do what you're after but it does not look inside blocks. I dont have time to write something up for blocks but to include lines from inside blocks you would need to write something that looks inside the block definition for the lines and then finds each instance of the block in the drawing and adds the x and y value of insertion point to the x and y values inside the block.

(defun c:extractlines (/ ss1 count n1 n2 outfile start_x end_x start_y end_y) (graphscr) (setq filter_layer "strucad_01") ; Change this to the layer you want to output ;(prompt "\nSelect the Lines to be Added together:") ;(setq ss1 (ssget (list (cons 0 "line")))) ; Select lines Manually (does not filter by layer) (setq ss1 (ssget "X" (list (cons 0 "line")(cons 8 filter_layer)))) ; Automatically select ALL lines on ths specified layer (setq count (sslength ss1)) (setq outfile (open "c:\\temp\\lines.txt" "w")) (while (/= count 0) (setq N1 (ssname ss1 0)) (setq N2 (entget N1)) (setq start_x (rtos (cadr (assoc 10 N2)))) (setq end_x (rtos (caddr (assoc 10 N2)))) (setq start_y (rtos (cadr (assoc 11 N2)))) (setq end_y (rtos (caddr (assoc 11 N2)))) (princ (strcat "\nLine: " start_x ", " end_x ", " start_y ", " end_y )) (write-line (strcat start_x ", " end_x ", " start_y ", " end_y ) outfile) (ssdel n1 ss1) (setq count (1- count)) );end while (close outfile) (terpri) (princ) ); end program

Reply to
Michael Everson

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.