Jump to content

Excel VBA - Autocad


prophici

Recommended Posts

Do you guys know of any good Autocad-Excel-VBA Developers that could right me a program/script or whatnot?

 

Basically I would like to type it part numbers of individual components into a excel sheet, and then somehow import that into AutoCad where I could get AutoCAD to generate a drawing based off the information of the excel sheet. I have most of the blocks in AutoCad drawn, so maybe it would be something where the excel sheet just puts the CAD blocks together to make an assembly drawing? Not sure.

Link to comment
Share on other sites

If you can post some examples or give a bit more detail, there are plenty of people here that can help you

Link to comment
Share on other sites

Like Steven there is just a huge amount of free code out there, there are different ways to do what you want.

 

Use a macro in excel to write a script of the required autocad commands.

 

Use concatenate in excel to write a line/s which you copy to the Autocad command line.

 

Write a csv file of the info and use a lisp/vba/.net to do the Autocad commands. Use something like getexcel.lsp to directly read the cells in excel then do the Autocad commands.

 

From what you have asked it may be easiest using excel.

An example A1=1 B1=2 c1=3 ie a circle is required at 1,2 with radius =3

E1=CONCATENATE("circle ",A1,",",B1," ",C1)

Just copy E1 and paste to command line.

insert example

E1=CONCATENATE("Insert ",A1," ",B1,",",C1," 1 1 0 ",D1) a1=blockname b1,c1 scale scale rotate attribute ... add if more attributes.

 

You can have multiple rows so copy numerous inserts in 1 go.

Link to comment
Share on other sites

Hey guys, sorry for the delayed response. I can't get into great detail on a public forum (Interested folks can send me a message and I can go into more detail there).

 

The general gist is that I work for a company that makes components, normally our customers buy these components separately and puts them together themselves. I helped to start a group within that component-making company that will go ahead and put together those individual components and the sell that single assembled unit to our customers. Currently we use Autocad to make drawings that give the factory an idea of how to put the components together and which components to use (since we make thousands of different components). I have drawings already of most of these components, and currently we make each drawing manually.

 

Each component already has a established part number that we use to identify which components go into a assembly. I was wondering if you could use excel (perhaps by entering the part numbers into a worksheet or something) with a list of these component part numbers and somehow import that data into Autocad where it would automatically generate a drawing based off the information in the excel sheet. Assuming it could pull the current component drawings somehow.

 

I do not know much about VBA or LISP, I was never a good drafter, and was hoping I could pay someone to write this program/macro/script/etc. for me.

 

Let me know what you guys think.

Link to comment
Share on other sites

I have done it for you no charge look at this screen dump, yes you could build a way of put in an assembly name and it populates all the part numbers. Just copy column F sections for each part, oops x y for assembly 1234-60 should have a x of say 20. You could just save each group of inserts in a script ie 1234-60.scr then just do just that Script 1234-50

 

(alert "assembly 1234-50\nloaded by using SCRIPT command")
Insert 1234-56 10,10 1 1 0 
Insert 1234-57 10,20 1 1 0 
Insert 1234-58 10,30 1 1 0 
Insert 1234-89 10,40 1 1 0 
Insert 1234-99 10,50 1 1 0 

Screen Shot 05-24-17 at 01.56 PM.PNG

Link to comment
Share on other sites

Are all the details created by the blocks?

One detail in one file or many details in one file?

The structure of the files? Shared folder where many files? Or there are internal folders?

Link to comment
Share on other sites

I wrote an Excel/VBA program to create an AutoCAD script (.scr) given a list of file names (column B) to be used to construct a drawing. The program looks in cell B3 and generates an -insert statement for each part listed. The program stops when it encounters a blank cell in column B.

 

Just click the Write Script button when you are done specifying the part (drawing) names and their location and angle.

 

I don't know if you also want the program to determine the x,y location based on the part used. That type of information could be defined on a separate worksheet to allow you to easily change the rules. The Excel vlookup command could be used to define the rules or it could be done with additional VBA code.

 

s1.JPG

 

A sample line of the script file looks like this:

-insert C:\SomeFolder\CAD-Projects\1234-A 50,110 1 1 0

 

The program does no error checking and assumes the referenced parts exist and are in the same folder as the Excel file.

 

CreateScript.zip

 

Lee

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