Lots of work, lots of travel – so this blog went silent for a while but not for long anymore…
Achievements of the past couple of days/weeks:
Small stuff, cleanup work and trying to remoce custom node dependencies from my daily work Dynamo graphs. I foud myself too many times in odd places with my admittedly badly maintained tracel companion laptop missing packages so I just got rid of custom nodes for my two most often used nodes.
And here we have the first one:
ElemNamesToExcelNoCustomNodes – Using the Element Type selector we write stuff out to Excel
The fancy stuff is that we construct the Excel file name based on the file name and the Excel sheet name based on the Type.. but that is optional
The only “custom”thing here is this small Python script:
And that looks like this:
#Copyright(c) 2015, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net
import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *
#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN
def ClearList(_list):
out = []
for _list1 in _list:
if _list1 is None:
continue
if isinstance(_list1, list):
_list1 = ClearList(_list1)
if not _list1:
continue
out.append(_list1)
return out
#Assign your output to the OUT variable
OUT = ClearList(IN[0])
BTW – ©Konrad K Soborn
So that writes the stuff out to Excel…
Using Dimension Type it produces a list like this in Excel..
Sure now we can use Reg exps in Excel to rename stuff..
The Excel now looks like this:
So now we hae this we need to suck that back into our Revit file – the Dynamo graph for that:
Custom nodes that needed to be amended were:
So – from left to right the code is:
# Copyright(c) 2015, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net
# Import DocumentManager
import clr
clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
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
try:
errorReport = None
doc = DocumentManager.Instance.CurrentDBDocument
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 = doc
else:
OUT = errorReport
Next one – middle one:
test = []
for i in IN[0]:
test.append(int(i))
OUT = test
Then – on the right we have:
import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *
clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
clr.AddReference(“RevitAPI”)
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
nameElems = []
for i in IN[0]:
nameElems.append(UnwrapElement(i))
values = IN[1]
TransactionManager.Instance.EnsureInTransaction(doc)
for i, j in zip(nameElems, values):
i.Name = j
TransactionManager.Instance.TransactionTaskDone()
#Assign your output to the OUT variable.
OUT = nameElems
And that is it – result:
Life is good..
Pingback: Weekly Roundup – 2017.06 | The BIMsider
Pingback: Weekly Roundup – 2017.06 | The BIMsider - Revit news