Revision Properties node - utilizing python code

Hello,

I’m attempting to use Konrad’s archi-lab node called Revision Properties. My dynamo (dynamo 1.2/Revit2015) doesn’t see the node when I install the package.

Per http://archi-lab.net/revisions-on-sheet-w-dynamo/

It’s supposed to be used as so:

There is code provided on how to use the node, yet I cannot figure out how I would use the code. Obviously, by inserting the code into a custom python script I get errors and the naming of the inputs and outputs does not match.

How would you go about creating this node?

It looks like it is python code:

# Copyright(c) 2015, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net

import clr
# Import Element wrapper extension methods
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

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

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

def ProcessList(_func, _list):
	return map( lambda x: ProcessList(_func, x) if type(x)==list else _func(x), _list )

def UnwrapNestedList(e):
	return UnwrapElement(e)
def GetSequence(e):
	return e.SequenceNumber
def GetDate(e):
	return e.RevisionDate
def GetIssuedTo(e):
	return e.IssuedTo
def GetIssuedBy(e):
	return e.IssuedBy
def GetIssued(e):
	return e.Issued
def GetDescription(e):
	return e.Description

if isinstance(IN[0], list):
	revs = ProcessList(UnwrapNestedList, IN[0])
else:
	revs = [UnwrapElement(IN[0])]

try:
	errorReport = None
	sequence = ProcessList(GetSequence, revs)
	date = ProcessList(GetDate, revs)
	description = ProcessList(GetDescription, revs)
	issued = ProcessList(GetIssued, revs)
	issuedTo = ProcessList(GetIssuedTo, revs)
	issuedBy = ProcessList(GetIssuedBy, revs)
except:
	# if error accurs anywhere in the process catch it
	import traceback
	errorReport = traceback.format_exc()

#Assign your output to the OUT variable
if errorReport == None:
	OUT = [sequence, date, description, issued, issuedTo, issuedBy]
else:
OUT = errorReport

Based on the error you’re seeing, it seems your list of Revisions might contain nulls somehow, but I’m not sure what would cause the Sheet.Revisions node to throw nulls. Try using List.Clean before connecting to the Python script to see if that allows the script to work.

As for getting the outputs, you can set up a Code Block like so (the labels aren’t necessary in the code block, I just put them for clarity. In a custom node you would connect an Output for each with the label):

1 Like

You’re a genius! Thank you so much, it’s working.

I guess I should have known that noneType means the object isn’t an object and is null. Thank you awilliams!

Quick question if I can bother you once more though please. How do you add a return in the code block, to have multiple outputs?

You’re welcome!

You should be able to just add a hard return with the enter key the same way you’d start a new line in a text editor. You just need to have the semicolon at the end of each command, so in this case each line. There is info on DesignScript syntax in the Dynamo primer, and some DesignScript guides on the Learn page of this site (towards the bottom under “Resources & Curricula”) if you’d like to learn more. Here is the code block I’d used in the image I’d attached above:

sequence = x[0];
date = x[1];
description = x[2];
issued = x[3];
issuedTo = x[4];
issuedBy = x[5];
1 Like

Oh I see, I definitely need to read the primer and go through the learn page. I wasn’t aware of its existence.

I see, it’s the other enter key on the keyboard… In IDE’s and regular text editors I’ve never had that problem hmm. Thank you so much!