Jump to content

Text, Polylines and Blocks Count + Export to excel compatible file


johnnatan

Recommended Posts

Goof afternoon,

 

I have never programmed in AutoLisp, so I have no idea on how to extract the following data from any drawing:

 

1. Text: My idea is to have in my drawing some details callouts and I want the AutoCad to actually count all the texts, and to provide me a list of the texts included and the number of ocurrences. My final objective is to grab this exported file, read it using excel and to create a simple subroutine with a material list (also in excel) and crossreference them , in order to get a detailed MTO (material take off). For example, if I labeled my power receptables as REC1 (480V), netweork connection points as REC2 and standard receptables as REC3 (120V), I want AutoCAD to prepare a list of all the different text labels used (in this case REC1, REC2 and REC3) and to give me a count of the ocurrences. With that file exported in a format that excel can understand I will create my own subroutines.

 

2. Polylines: My idea is the following: I want to create a kind of smart cable routing drawing. I will assign to each polyline a tag, and I need Autcad to provide a list of tags with the polyline associated per tag distance, in order to have a good estimate of cable length to buy. So if I have three conduits tagged as C1, C2 and C3, associated to different polylines (let's suppose a mtext justified to the center aligned to the center point of the polyline) and I want to have a file that excel can understand where I can see: C1 with X ft, C2 with Y ft and C3 with Z ft, for example.

 

3. Blocks: I need a subroutine that would allow me to count different blocks and provide an excel file with the quantities. The goal is somewhat similar to point 1.

 

My former company had some old subroutines that I couldnt copy, and my new job does not have any of these handy tools and everything needs to be done on foot, if you know what I mean.

 

Any help is appreciated.

 

Thank you,

Link to comment
Share on other sites

No 1 is pretty easy you can search for text and make a list of it then just sort it, you walk through the list adding them up once the name is different write the answer to a CSV file. REC1,42 REC2,23 REC3,12.

 

(setq ss (ssget (list (cons 0 "Text")))) 
;or 
(setq fil (getstring "\Enter search string REC* etc"))
(setq ss (ssget (list (cons 0 "Text")(cons 1 fil)))) 

 

No 2 maybe look at xdata or just a block with attributes that are linked via a field to the length of the pline, again you can pick certain blocks.

 

(setq fil (getstring "\Enter search blkname etc"))
(setq ss (ssget (list (cons 0 "Insert")(cons 2 fil))))
; retrieve attributes and write out to csv C1,23 C2,34

 

No 3 look at 2 above.

 

All of these are here at Cadtutor try searching "ssget text" "attributes to csv" "total blocks" I just dont have these routines readily available or would have posted. I am sure others will.

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...