AutoCAD to Blender

DWG is a closed format, they don’t want anyone else to be able to open it. That said I think Bentley realesed an OS library for accessing dwg files.
Archicad, ProgeCAD, Intellicad, Vectorworks, Microstation to name just a few that can read and write DWG. Maybe not the very latest AutoCAD version but only one or two versions behind.

Autodesk offer a free download called TrueConvert that will convert any release of DWG including 2007 to any other DWG or DXF version.

Ever heard of the OpenDWG Alliance even AutoDesk are using it I believe for some minor product or other.

I think Bentley realesed an OS library for accessing dwg files. Still I think DXF is your best bet

Yes I have, that was what I was talking about. And yes I do still thing dxf is a better option. The best option would be for Autocad to support exporting into some widely available format, but Autodesk seems to be against sharing in general.

BTW whats with the attitude? And what exactly did you contribute to this thread by sharing it?

gurus,
being an architect and interested in 3d modelling too…was using the same old steps from cad modelling to max rendering. now i use blender:D . i am now going to buy a fully licensed archicad 10 software which also does the job of max in itself ( lightworks rendering engine) and also can import as 3ds…plus this is cheaper than autocad and max put together and has a gr8 library too…check it out!
chela69

I’ve never heard of such a thing. Not that I’m an expert by any means. How is it possible to automate Autocad with Python? Sounds very interesting since I use Autocad extensively in my work. I use autolisp inside Autocad to do my automation.

On another note I downloaded Accutrans3D (mentioned in the BlenderArt Mag and this thread) and the initial tests I’ve done converting an Autocad .dxf file to a .dxf that Blender can import looks very promising. The only cleanup I had to do was to make each entity a part of the same object. When imported each line and arc was brought in as a seperate object in Blender which is not necessarily a bad thing depending on your import situation. It was only a small step to join them together as a single object.

Has anyone else given this program a try for their imports to Blender?

Getting 3d DXF’s as well as 2d plans works quite well with
http://www.coin3d.org/lib/dime

it comes with a test tool - dxf2vrml

Running this on a dxf produces a VRML 1.0 File Blender can import.

If sombody wants to build a cygwin dxf2vrml.exe (Im on linux here), Its trivial to do a python script to automate the conversion and loading.

BlendDee: Checkout Python Win32. AutoCAD has had a COM interface probably since they added vba. There are several tricky parts, and it seems AutoDesk did some odd things which break compatability, but once you get going you can do just about anything.

In older versions of win32 you had to manually cast AutoCAD objects to be the right thing. i.e. if you did mycirc = acad.ActiveDocument.ModelSpace.AddCircle you would get back a generic object with no radius/center/whatever. You then had to tell Python what it was supposed to be. In recent versions though casting seems to be automatic :slight_smile:

As for AutoDesk’s bad COM compatability - with the help of a few other people I have created a modified version of the Python build script which generates the COM wrapper for Acad. All you need to do is temporarily replace the bundled build.py with this Acad specific version, call makepy and you will get a functioning Python wrapper.

My current largest script is called project_mirror.py - takes a local and remote directory and a ftp login and password, then recursively walks the directory tree and uploads every file, then using the list of files it found and some rules for what is really a drawing it plots every drawing to pdf and uploads those to the same ftp. It also keeps a list of the file modified dates of files it has seen and only updates files that have changed.

You can even write new Acad commands if you want, all you need is a little Lisp. I just made a function named CallPy that takes a script name as an argument, then tries to run the script from a shared location on our server. The only problem is that it uses the Acad shell command to run it, so you always get a dos window :rolleyes:

I’ve been planning to release the modified version and do some tutorials on scripting Acad, but I haven’t had time :frowning:

Thanks for the reply Kitsu.
Sorry to the Thread for the break from Blender issues and a short focus on Autocad and Python.

I hope that the next “blender summer of code” will address this.

a working set of import and export scripts for autocad would make blender a very powerful tool for archetect vis…

Right now I must use truespace 6.2 (not free), and the DWG importer and exporter scripts (also not free).

if a bunch of semi-literate hacks like “caligari inc.” can make this, then anyone can :slight_smile:

Someone should start a “Bounty project” like ubuntu, where professionals can leave requests+Donations.
I bet we could get a great set of tools if there was a bit of $$$ involved.

I was just playing with QCad… bah bah bah… I imported my DXF file’s into blender via OOo, I used it to export the DXF to SVG and then imported it into blender (use the Old proofed OBJ method). You end up with a bezier curve that you can convert to mesh (you should detach poly shapes from curves to change DefResoLU first) & you should know the rest. Easy Peasy! :wink:

PS. I think you can also use Dia to conver DXF to SVG, not sure tho (dont have it installed at the mo).

Edit: I made a tut since this seems to be quite frequently asked…(hope it helps)

That inhuman act of removing the 3ds export function from autocad 2007 is really a big problem… it was by far the easiest way. (they kept 3ds import, since most of the furniture models you find on the net are 3ds… smart guys). Now, who has never searched for some designer’s piece of furniture on the net and only found .max file (which no other 3d program than 3ds max can import)? Max is Autodesk too. We architects are a bit too addicted to Autodesk product, and this causes us big headaches when we want to use other software, like cool blender, who can import almost any 3d format around, except proprietary-protected-by-evil-lawyers-autodesk-formats…

I currently use dxf too (method: http://blenderartists.org/forum/showthread.php?p=610531#post610531), but i agree it’s not a very confortable solution, just a provisory one…

As an addendum: I checked out Stani’s dxf lib again the other day. I didn’t realize that it was for export only >:|

I haven’t found anything else as promissing. If I get the openDWG I’m sure I could write a pyrex wrapper for it, but I don’t have time right now. Also I would only be able to compile on windows. Maybe this is a job for someone at the development forums?

why dosnt sombody set up a project to get a good python DWG or DXF importer?
just do the basics first, get lines working and then some text

DXF could be done where the 1st milestone was to match port blenders importer, then we could work on text, line color, and debugging.

Because all us Python programmers are irascibly lazy :stuck_out_tongue:

Actually it sounds like a fine idea to me. How do you want to do it? Pure Python, or a wrapper around some existing c code base?
In my searches I checked out the PythonCAD projects source. It looks like they have basic support for several dwg fomats and good access to R12/13 IIRC.

If you want to code it from scratch I don’t think it will happen. The dwg is a extreemly hairy binary format with multiple different versions. I think we could do basic dxf fairly easily from scratch. Also Stani hints that his code could be modified to import as well as export.

At the moment I don’t really have any time to devote to this, but in several months I may be looking for a fun coding project :slight_smile:

Kitsu,

Which do you prefer in AutoCAD - VBA or AutoLisp? I would be interested in doing it on the AutoCAD side, either as an obj or stl export. I do a lot of cam from my 3d models no matter where I make them. I really like Blender for most. I know basic VB and a little common lisp. The python interface to AutoCAD is also interesting, since I am doing more python work because of Blender.

Rob

Yeah, I thought about writing an exproter for AutoCAD. Like I said though - you don’t have any meaningful access to solids from vba/COM. I have no idea what solids look like from lisp, but they probably look the same as from dxf.

One thing I havent bothered to check is - what happens when you explode a solid? I’m hoping it gets converted to a surface, but I have a feeling it just tells you you can’t explode solids :frowning:

Anyway this would only be useful to people with access to AutoCAD. Creating an importer for Blender would be a more general and user friendly solution. Now that I’ve thought about it a little more - it shouldn’t be that hard to use PythonCAD’s code to import lines directly from a dwg file…

Does anyone know if pythonCad has 3d access? - from what I saw it looks 2d only

IIRC its dwg libs do for dwg v12/13. I don’t think the program itself has any 3d capabilities.

y little tutorial for autocad to blender sorry my bad english

http://www.kino3d.com/mediawiki/index.php/(ingoenius)_Da_Autocad_a_Blender_-WIP-

I think DWG format is an horrible thing to work on. It’s undocumented, very strange and difficult to understand and it changes all the time, not mentionning the worst part, it’s something like “private property” and jealously kept secret… Actually, DXF format is a kind of plain-text version of DWG. All you can save in a DWG you can save in a DXF. The only problem is that you get enormous files (easily over 50Mb for a corresponding 5Mb dwg). DXF format upgrades together with DWG (2000, 2004, 2007,…), and the latest version (2007) supports all the latest Autocad entities and features. By looking at the DXF format reference (included in the Autocad help), I have the impression they rewrite the entire thing at each release, which is not very motivating for writing an importer… The day I’ll be good enough in python to try, we’ll be at DXF2376…
The blender importer we have now only reads DXF12 (prior to DXF14, which is prior to DXF2000), and can’t read 3d objects (actually there wasn’t much 3d in autocad 12…). If we had a recent one, I guess the problem of importing from Autocad would be solved.

I’ll have a look to the 2007 DXF code reference, just to see… but it would be a big piece for me and my very limited programming talents.

Have they changed formats again recently? The latest AutoCAD I have available to me here is 2005, and it uses the 2004 file format. Also for dxf I think the files are fairly backwards compatable (i.e. if we build a dxf2004 importer we could use it on dxf < 2004 too). I did some moderatly complex lisp stuff over the last couple of days. Now I’m thinking I might give this a shot.
Oooo, parsers and tree type data structures :slight_smile:
Ahh, numeric constant translation tables :smiley:
yeah, I’m definatly going to give this a shot!