Dynamo from a command line - revisited

Can anyone tell me if Dynamo can be run from a command line yet that will hook REVIT?
I read this thread : Dynamo Command Line Interface? ,but it has been awhile since then and was wondering if there was any change yet?

My first thought is why would you want to do this?

My second suggestion would be to possibly post the issue to GitHub. You might get more feedback there than here. Just my opinion.

Why? Because I want to run a couple of dynamo graphs against 700 REVIT files!

2 Likes

Do you want to modify those files or collect some data ?

Collecting data only.

Here’s one possible way of doing that through dynamo : the key element here is @john_pierson Document.BackgroundOpen (Rhythm package)

code for getting all elements of category in background opened files:

#inspired by Konrad Sobon's Get All Elements From Linked Model

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# Import RevitAPI
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

import System

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN

_linkDoc = IN[0]
_category = IN[1]
result = []

for l in _linkDoc:

	errorReport = None
	filter = ElementCategoryFilter(System.Enum.ToObject(BuiltInCategory, _category.Id))
	result.append(FilteredElementCollector(l).WherePasses(filter).WhereElementIsNotElementType().ToElements())



OUT = result

I’m not sure how this will go with 700 files though! :slight_smile: I’d be interested to know…

4 Likes

You might also check out Andreas Dieckmann’s Dynamo Automation tools:

“DynamoAutomation is a package for the Dynamo visual programming environment. It allows Dynamo users to batch process multiple Revit models by driving Revit (and the Dynamo addin) from the outside using the Dynamo sandbox, each time using the same Dynamo workflow, e.g. process an entire folder of models. This opens up a lot of possibilities for achieving a higher degree of automation in labour-intensive areas such as quality control and enforcement of company or project standards.”

2 Likes

Mostafa,
I am getting and EOF error when I copy/paste the code for the get all elements from linked model node and no output connection from it?

Also, can I get more than one category by adding other lines to the Python script from string node? For instance, I want Project Information, Areas and Rooms ?

Zach,
Doesn’t look like Andy’s Automation Tools works with REVIT 2017 and the latest version of Dynamo…too bad looks really kewl!

@Dave_Vaughn

the node python code from string needs a string. So you must add " att the beggining and end of the code.
Yes you can get more than one category . You can get all elements on the file if you want.

ok…got it I believe!

The quotes are important, they make the content of the code block a string: " code " ;

to get all elements in documents replace this loop :

for l in _linkDoc:

	errorReport = None
	filter = ElementCategoryFilter(System.Enum.ToObject(BuiltInCategory, _category.Id))
	result.append(FilteredElementCollector(l).WherePasses(filter).WhereElementIsNotElementType().ToElements()) 

with this loop :

for l in _linkDoc:

	result.append([i for i in FilteredElementCollector(l).WhereElementIsNotElementType()])

Very interesting. A couple of questions; What are the limitations of using this method?

(EDIT:- ok I see, only collecting data)