Jump to content

Text & polyline data to csv


Kape01

Recommended Posts

Hi All,

 

Firstly thanks to all contribute on this forum.  I'm a complete newbie to lisp.  Dipped my toe into the world of lisp for the first time a few days ago and wow! 🤯  Definitely something I am now trying to learn.  If someone could help with below would be greatly appreciated. 

 

I have drawings which have to manually enter the properties of each individual segment into excel file.   I use the attached boundary lisp to create a boundary around the segments (all drawings are always drawn with lines) and the rectcsv to export the data.  A colleague of mine came across the rectcsv lisp on this forum (by Jonathan Handojo), which is very close to what I need.  Is it possible to get the X axis length to always appear in the width column and the Y axis length in the height column?  Is it also possible to extract more data to csv such as:

 

  • the layer of the label 
  • the number
  • the second height (H2)?  As this gets its own boundary not sure if its possible, if not I can add another label number and filter/ sort the data in excel.

 

I have attached sample drawing & csv file of what I am trying to achieve.  

 

Thank you in advance.

 

 

sample.dwg sample.csv rectcsv.lsp BoundaryMultSel.lsp

Link to comment
Share on other sites

For me start again just use ssget Label?????? text,  find each text do a bpoly and get bounding box, this gives X & Y lengths, delete bpoly do next. Way less code. Code would be use text insert point, then bpoly. make a list of the results and do a sort on say layer then label number, export list to csv. 

 

Need some time doing paying work at moment.

Link to comment
Share on other sites

Sorry if this is dumb question, just want to check to make sure I understand correct.  I assume this method allows to select multiple segments at once using crossing window or would an internal point of each segment need to picked individually?

Link to comment
Share on other sites

The idea is pick say the text on a layer then make a selection set of all the text, loop through this getting insert pt of text use bpoly command to make a polygon you can get co-ords and the height & width. Ok only problem one of your text is off the rectang so no answer. 

 

The second issue is the H2 you would need to remove the middle line and run code again, could do an append to the csv file make it a second function but it uses same text.

 

Here is a start as an example 

; https://www.cadtutor.net/forum/topic/70959-text-polyline-data-to-csv/
; test for get area inside a closed shape via text inside 
; By Alan Aug 2020

(defun c:test ( / ent ent2 lay ss ins txt obj)
(setq ent (entsel "\nPick Text for layer"))
(setq lay (cdr (assoc 8 (entget (car ent)))))
(setq ss (ssget (list (cons 8 lay)(cons 0 "Text"))))
(repeat (setq x (sslength ss))
(setq ent2 (entget (ssname ss (setq x (- x 1)))))
(setq ins (cdr (assoc 10 ent2)))
(setq txt (cdr (assoc 1 ent2)))
(command "bpoly" ins "")
(setq obj (vlax-ename->vla-object (entlast)))
(princ (strcat "\nArea is " (rtos (vla-get-area obj) 2 3) " Label is " txt))
(command "erase" (entlast) "")
)
)
(c:test)

 

Link to comment
Share on other sites

Thanks BIGAL.  Ignore the text outside the segment, I can relocate all text to the inside. I thought the H2 would be an issue, unfortunately I cant remove the line.  Will just another label and can do the rest in excel.  Will try and put something using the method you have suggested.  Thanks.

 

Capture.PNG

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...