Hello all,
Just wanted to share a Python node from my upcoming AU London Python for Beginners class in a few weeks. You guys may find it useful!

Results in Revit:

It should be pretty easy to set the rest of the options using this
Just wanted to share a Python node from my upcoming AU London Python for Beginners class in a few weeks. You guys may find it useful!
Code:
[COLOR=#75715e]"""[/COLOR] [COLOR=#75715e]IMPORTING MANAGERS[/COLOR] [COLOR=#75715e]"""[/COLOR] __author__ = [COLOR=#e6db74]'Sol Amour - [email protected]'[/COLOR] __twitter__ = [COLOR=#e6db74]'@solamour'[/COLOR] __copyright__ = [COLOR=#e6db74]'designtech.io 2018'[/COLOR] __version__ = [COLOR=#e6db74]'1.0.0'[/COLOR] [COLOR=#75715e]# Importing Reference Modules[/COLOR] [COLOR=#f92672][B]import[/B][/COLOR] clr [COLOR=#75715e]# CLR ( Common Language Runtime Module )[/COLOR] clr.[COLOR=#ffffff][B]AddReference[/B][/COLOR]([COLOR=#e6db74]"RevitServices"[/COLOR]) [COLOR=#75715e]# Adding the RevitServices.dll special Dynamo module to deal with Revit[/COLOR] [COLOR=#f92672][B]import[/B][/COLOR] RevitServices [COLOR=#75715e]# Importing RevitServices[/COLOR] [COLOR=#f92672][B]from[/B][/COLOR] RevitServices.Persistence [COLOR=#f92672][B]import[/B][/COLOR] DocumentManager [COLOR=#75715e]# From RevitServices import the Document Manager[/COLOR] [COLOR=#f92672][B]from[/B][/COLOR] RevitServices.Transactions [COLOR=#f92672][B]import[/B][/COLOR] TransactionManager [COLOR=#75715e]# From RevitServices import the Transaction Manager[/COLOR] [COLOR=#75715e]# Here we give the Revit Document a nickname of 'doc' which allows us to simply call 'doc' later without having to type the long namespace name [/COLOR] doc = DocumentManager.Instance.CurrentDBDocument [COLOR=#75715e]# The input ports [/COLOR] dimensions = [COLOR=#ffffff][B]UnwrapElement[/B][/COLOR](IN[[COLOR=#ae81ff]0[/COLOR]]) [COLOR=#75715e]# Here we 'unwrap' our Dynamo objects. Dynamo and Revit Elements are different - Dynamo has wrapped them up in order to manipulate them so for us to use them in the actual Revit Project we need to unwrap them so that we can talk to the Revit API[/COLOR] text = IN[[COLOR=#ae81ff]1[/COLOR]] [COLOR=#75715e]# As this input is simply text we do not need to unwrap it[/COLOR] [COLOR=#75715e]# Wrapping the body of our code inside of Transactions. This allows us to effect the Revit Project ( Document ).[/COLOR] TransactionManager.Instance.[COLOR=#ffffff][B]EnsureInTransaction[/B][/COLOR](doc) [COLOR=#75715e]# We have to be inside of a Transaction to manipulate the Revit Project so we use the Dynamo Specific transaction wrapper ( A special way to use the Transaction Class ) to ensure we are in a transaction. This way, if anything goes wrong inside of our script the Manager will ensure nothing breaks, that any partial changes made are reverted and that our Revit file is cleaned up before progressing[/COLOR] [COLOR=#75715e]# We generate an empty catchment list to append (add to) our results[/COLOR] results = [] [COLOR=#75715e]# We then run a For Loop across every single element that is coming into our 'dimensions' input node[/COLOR] [COLOR=#f92672][B]for[/B][/COLOR] dim [COLOR=#f92672][B]in[/B][/COLOR] dimensions: [COLOR=#75715e]# For every single dimension inside of our input list called 'dimensioins', do the following...[/COLOR] dim.Above = [COLOR=#ffffff][B]str[/B][/COLOR](text) [COLOR=#75715e]# Set the property called 'Above' ( Which refers to the Text Field entitled 'Above' inside of the Dimensions editor ) to our chosen text from our second input port[/COLOR] results.[COLOR=#ffffff][B]append[/B][/COLOR](dim) [COLOR=#75715e]# Then simply append ( add ) this dimension to our empty catchment list 'results'[/COLOR] TransactionManager.Instance.[COLOR=#ffffff][B]TransactionTaskDone[/B][/COLOR]() [COLOR=#75715e]# After we have our script body finish executing, we want to close our Transaction. So we once again use the wrapper to close the Transaction using the 'TransactionTaskDone()' method[/COLOR] [COLOR=#75715e]# The output port, showcasing the Revit Documents Saved Name[/COLOR] OUT = results
It should be pretty easy to set the rest of the options using this

Comment