Jump to content

Using Excel As Data Source (for label sheets)


Recommended Posts

Hi all,

 

So on another thread, I was pointed to a couple methods to extracting text from a drawing. Now, I want to use that CSV or Excel file as a data source, but I don't want to use an AutoCAD table.

 

The CSV is basically one column and hundreds of rows. The application here is printing a bunch of labels. I'd like to use AutoCAD as I have paper space control over the layout. Excel isn't very good at that.

 

The labels I am printing to are letter sheets with a 6x7 grid of labels.

 

I'd like to set up AutoCAD so that on my model space, I can lay out field placeholders, and then the data source populates them.

 

I will have multiple sheets. Even if the placeholder text requires me to have the column row number somewhere, I have LSPs that can help increment those.

 

So the first label placeholder might be something like A1 (for column A, row 1).

 

There are some where the label will have the same value repeated, and I'd just copy the placeholder.

 

Any ideas? If I should be going about this a different way, let me know.

Link to comment
Share on other sites

Have a look at Getexel.lsp pretty sure it uses the A1 in its code. You can also do a "what is max row" so a repeat function would know how many to do.

 

For you grid its a simple double repeat

(repeat ( + ymany 1)
(repeat ( + xmany 1)
....
)
...
)

Link to comment
Share on other sites

I don't exactly have coordinates for layout. I kind of need to make a template for these sheets of labels, and drop DTXT elements in properly aligned to some object so they are centered. I believe I kind of need it to replace DTXT on click or when I say go.

Link to comment
Share on other sites

If you have just one column in excel then it makes it easy, your trying to do labels so a page is filled in say by rows down a column then next row and so on.

 

Have a look at this grid label example I think I posted at Theswamp but it shows you how to make a grid using a double repeat. I will see if I can find time on holidays right now and going fishing more important than work and coding. Pick a start point pick to right, pick point above you should see something.

 

(setq pt1 (getpoint "Pick 1st point cnr"))
(setq x1 (car pt1))
(setq y1 (cadr pt1))
(setq x 1)
(setq y 1)
(setq d1 (GETDIST PT1 "2nd point X"))
(setq d2  (getdist PT1 "2ND PT y"))
;(SETQ Xmany (GETINT "How many in x direction"))
;(setq ymany (getint "How many in Y direction"))
(setq ansx "A00")
(setq ansy "B00")
(setq ymany 7)
(setq xmany 6)
(repeat ( + ymany 1)
(repeat ( + xmany 1)
(setq  pt (list x1 y1))
(command "text" pt "1" "" (strcat ansx (rtos x 2 0) ansy (rtos  y  2 0)))
(setq x1 (+ x1 d1))
(setq  x (+  x 1))
)
(setq   x 1)
(setq  x1(car pt1))
(setq  y1 (+ y1 d2))
(setq Y (+ y 1))
)

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