See the top rated post in this thread. Click here

Results 1 to 5 of 5

Thread: Python

  1. #1
    Active Member
    Join Date
    2004-08
    Posts
    50
    Login to Give a bone
    1

    Default Python

    I've run across some old threads (mostly by GuyR) mentioning python for Revit. Is it possible to use python for Revit programming? How exactly would one go about that?

    -mjm

  2. #2
    100 Club
    Join Date
    2004-02
    Location
    Brookline, MA
    Posts
    186
    Login to Give a bone
    1

    Default Re: Python

    I haven't had a chance to really test it - but I suspect that you'd have to do something like this:

    0. First, we're talking about "IronPython" the one that works with .NET. Install the framework.

    1. Have a C# or VB.NET application that implemented the IExternalCommand interface.

    I don't think Python can do this, so I think you'd need a wrapper, which then called Python...

    2. Call a function in a python script, passing in the Application object.

    You can find some of these examples on the web - it looks like you're Creating an Instance of the python engine, creating a module, then reading the contents of a PY file into the module. You can then call a method in the Python class, and hopefully pass the Application object.

    It's all going to be a little tricky, especially using the IronPython CLR classes to dynamically reference the Autodesk.Revit library.

    I don't know when I'll get enough time to try it out - I hope someone does and posts a sample project here!

    -Matt

  3. #3
    AUGI Addict
    Join Date
    2003-11
    Location
    New Zealand
    Posts
    1,116
    Login to Give a bone
    1

    Default Re: Python

    Michael,

    As I've talked about before I've had a python binding working for Revit since the first version of the API (V8 ). The first versions used CPython which opened Revit to the huge number of python libraries that exists on the web. With Microsoft getting behind IronPython and Revit moving to .NET2 I ported the effort to IronPython.

    My initial reason for doing this was to try and open the API to a wider audience, the casual programmer. However, I quickly came to appreciate 2 huge issues.

    1.. While python is easy to read and write, to create anything of substance requires a lot of knowledge using .NET and winForms. So python didn't really help .
    2.. A good intellisense editor was needed for writing scripts, unless you had VStudio standard and above, or a photographic memory .

    Last year MS started rewriting IronPython using an 'intermediate' layer called the DLR. This will make it easier creating dynamic languages for .NET. However, the hosting and embedding solution is changing a lot. I haven't tried porting to the current IP2 alpha. And as of today there has been no mention from MS on what if any editing solutions will be supported for the DLR.

    Given most casual programmers are going to be using VStudio express there hasn't been much point releasing this work. I'd just be having to support a less than usable solution. Late last year I became aware of an editing solution for IP1.1 which might solve 2 above. Sometime in the next month I'll have a look at it and if it's workable I'll release my code for all.

    HTH,

    Guy

  4. #4
    I could stop if I wanted to Nic M.'s Avatar
    Join Date
    2001-11
    Location
    Antwerp, Belgium
    Posts
    480
    Login to Give a bone
    1

    Default Re: Python

    There seems some evolution in this
    http://code.google.com/p/revitpythonshell/

    also Jermy mentioned it on his blog "the building Coder"

  5. #5
    I could stop if I wanted to TroyGates's Avatar
    Join Date
    2015-08
    Location
    Irvine, CA
    Posts
    281
    Login to Give a bone
    1

    Default Re: Python

    This looks very promising. Its a python interrupter that allows you to run python scripts against your Revit model/database. I could see this used for a lot of different types of analysis and model discovery applications.

Similar Threads

  1. CP319-2: Python Hype: Introduction to Python Programming with Autodesk Maya
    By Autodesk University in forum Customization and Programming
    Replies: 0
    Last Post: 2013-05-05, 01:36 PM
  2. Revit and Python
    By MikeJarosz in forum Revit Architecture - General
    Replies: 1
    Last Post: 2011-12-23, 09:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •