Revit API & python relations

Hi sajo

We know it’s overwhelming, but you are more likely to get quick responses if you break these questions down into separate posts/subjects.

In any case, I will try to touch on some of the points:

What does the first four similar lines of every script do…?

See comments below

import clr  
# imports Common Language Runtime library .This will serve as a bridge between python and the .NET wold
# See this: http://ironpython.net/documentation/dotnet/dotnet.html    
clr.AddReference('ProtoGeometry') 
# Loads the Protogeometry dll (.net assembly) so Python can use it
from Autodesk.DesignScript.Geometry import *
# Imports Geometry Classes from the DesignScript assembly (Protogeometry)
# this gives you access to Dynamos built in Geometry classes and more.
dataEnteringNode = IN
#The inputs to this node will be stored as a list in the IN variables.
# you don't actually need this. go ahead and delete it, nothing will change/
# The data you plug into the inputs will come as the IN variable

b. why should i import revit modules when I open and work on a console inside revit?

The python script runs inside a scripting engine, embedded into Dynamo, which has it’s own context, so tou still need to load the references you will need to use, and you need a “handle” for the revit/document instance so you can refer to it.

c.What exactly do i do when starting a transaction?

Read this:

And This:
http://help.autodesk.com/view/RVT/2015/ENU/?guid=GUID-C946A4BA-2E70-4467-91A0-1B6BA69DBFBE
In fact, you should read the entire Developer’s Guide if you are planning on diving deeper into the API:
http://help.autodesk.com/view/RVT/2015/ENU/?guid=GUID-F0A122E0-E556-4D0D-9D0F-7E72A9315A42

a.Where can I find the list of modules Pre built inside API…?

You can download the Full api doc from the official SDK (google revit API SDK), or use revitapidocs.com

b.can u explain how to read data from Revit ,for instance if i need to script
to increase door width if <3’(say parameter name ‘W’)

You should post a separate post for this

9 Likes