Revit API & python relations

#1

Hey ,guys I am having difficulty in understanding two important thing on the scripts written on this forum…
1.
a.What does the first four similar lines of every script do…?
b. why should i import revit modules when I open and work on a console inside revit?
c.What exactly do i do when starting a transaction? (it is obvious that you r
gng to R/W something…? so y r we strting a transc.)

a.Where can I find the list of modules Pre built inside API…?
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’)

if W<=3’ :
W=3’
return W
(code for understanding only :stuck_out_tongue: :stuck_out_tongue: )
Now problem is what come before this code and after this code…i.e how to make Revit understand that there is a parameter inside the door family and i wanna access it…!

thanks,

0 Likes

#2

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

Python Nodes Basics
Python Nodes Basics
Exception in random numbering node
#3

hey thanks for the reply ,that was enough
but iam having trouble relating them to what i need do u have any document specifying like the img below (## just an Example…!)

I mainly require scripts to call elements on the ribbion( used often).,
also if there is any tool that could show the scripts as i progress working on revit ,it can help me a lot to start learning to script…!
also posting this seperately on genral page so that others too can have a look…!
once again thanks for your replies, was useful…!

0 Likes