I do a lot of Inventor work, but my customers often want the drawings in AutoCAD format. Generally I just use the Inventor "save as" -> AutoCAD.dwg option, create the files and send them. However, the format (look and feel) of the files are rather boring. I want to write a lisp routine to Automate the process of making the dwg files look more appealing.
I want to do this with lisp, but it's been a loooong time since I used lisp, and even then, my lisp skills were somewhat limited. So,.. I have written myself a "project brief" which is below, and now I am ready to start my lisp project. However, I find myself staring at the brief and thinking "OK, where do I start." The concern is not so much the basic lisp functionality which I am sure will come back to me rather quickly, but more the bigger picture. Does anyone have any advice / guideline to offer as to how to approach this task. Programming is kind of a hobby thing, so I don't really want a coded solution, I would really like to code this myself, but some ideas, about how to break the problem down into more manageable chucks would be a big help. Of course any coding advice / tips are always welcome as well.
Thanks
;; Once a drawing is saved from Autodesk Inventor to AutoCAD,
;; the drawing needs to have certain changes done within the
;; AutoCAD environment before sending the ACAD file to the
;; customer. Here is a list of the changes:
;; 1.) All blocks need to be exploded
;; 2.) Any attributes within blocks need to be converted to
;; text (i.e. attribute values must not be lost)
;; 3.) The standard exported layers from Inventor need to be
;; assigned new colours (colours can be hardcoded in the
;; lisp file)
;; 4.) The drawing must be "saved as" AutoCAD version 2000.
;; As well as DXF AutoCAD version 12.
;; #########################################################
;; ADDITIONAL COMMENTS
;; The lisp routine for doing this must be loaded into the
;; AutoCAD session / environment at all times.
;; Apart from calling the routine from the AutoCAD command
;; prompt, there should be no further user interaction. (i.e.
;; no dialog boxes or further prompts). Any changes after this
;; can be added later.
;; All Inventor drawings will be exported to AutoCAD in
;; modelspace, so there is no need to be concerned with
;; paperspace issues.
;; When drawings are "savedas" from Inventor, each drawing sheet
;; is saved as its own dwg file.
;; The routine must collect all the drawings exported in one batch
;; and put them all into one AutoCAD dwg file.
;; Consideration need to be given to issues like when the blocks
;; are exploded, they also need to be purged, so that when the
;; drawings are "merged" there must be no block name clash.
;; Also positioning of the drawings needs to be considered
;; so that if there are multiple drawings that are merged they need
;; to be arranged in such a way to use the least amount of graphics
;; window and also have the sheet numbers follow in a logical fashion.
I believe reading Chapter 2 of my book "AutoCAD expert's Visual LISP" could help. It deals with the basics of a Visual LISP project, from the start up to compiling and demandloading. I have shared a PDF of this chapter here.
More information on the book can be found in my blog lispexpert.blogspot.com. If interested, the book can be bought at the CreateSpace e-store.
By the way, I used to teach Inventor VBA at the University a few years ago. You can see some of my class materials at http://www.togores.net/inventor-01/autodeskinventor. They're in Spanish, as this was a Spanish University but I suppose the code can be readily understood...
I find that going through & doing what you need done manually first, writing down your steps/commands (which you kind of have already) then just jump in and make the automated lisp. I start with geting the lisp to work by manually loading & running it at the command prompt. Then try automating the loading/running without user intervention.
For the attributes conversion there was a lisp from the express tools called BURST that explodes & keeps attribute values. (I think it will also explode regular blocks).
You might want to purge your drawing after exploding blocks to get rid of them & their layers (change current layer to 0 or something you want to keep).
The rest shouldn't be too hard.
Good Luck,
Rick