I gratefully use the Python scripts from Thomas Mahon to read the data of my schedules.
But I can not read the list of schedules. It must be one by one.
I received an advice to us node List.Map, but I don’t no how.
Can someone help me please.
If you know how to code in Python, add a loop to the Python script in order to iterate through your list of schedules
If you don’t know how to code in Python, create a Dynamo custom node, containing only the Python Script (select your script, then right-click, create custom node). Then double-click on the new custom node, and replace what will be written in the input block of the custom node by “ScheduleView”.
Thanks for your reply.
unfortunately I can not code in Python.
making a custom node is also not an option, because my company does not want to use a custom node.
Well, if you cannot apply either options, you’ll pass a pretty rough time while using Dynamo.
Not even sure this works or is optimal, but it is the best I can do. You can also try contacting @Thomas_Mahon.
#Copyright 2016. All rights reserved. Bimorph Consultancy LTD, 5 St Johns Lane, London EC1M 4BH www.bimorph.co.uk
#Written by Thomas Mahon @Thomas__Mahon info@bimorph.co.uk
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
#
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
schedules = IN[0]
result = []
for i in range(len(schedules)):
schedule = UnwrapElement(schedules[i])
# "Start" the transaction
TransactionManager.Instance.EnsureInTransaction(doc)
#count the number of rows and columns in the schedule
table = schedule.GetTableData().GetSectionData(SectionType.Body)
nRows = table.NumberOfRows
nColumns = table.NumberOfColumns
#Collect all of data from the schedule
dataListRow = []
for row in range(nRows): #Iterate through the rows. The second row is always a blank space
dataListColumn = []
for column in range(nColumns): #Iterate through the columns
dataListColumn.Add( TableView.GetCellText(schedule, SectionType.Body, row, column) )
dataListRow.Add( dataListColumn );
# "End" the transaction
TransactionManager.Instance.TransactionTaskDone()
result.append(dataListRow)
OUT = result
This is the exact reason why you HAVE to use custom nodes at some point … This solution only work for THIS particular problem…
#Copyright 2016. All rights reserved. Bimorph Consultancy LTD, 5 St Johns Lane, London EC1M 4BH www.bimorph.co.uk
#Written by Thomas Mahon @Thomas__Mahon info@bimorph.co.uk
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
#
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
list_schedules = IN[0]
result = []
for schedules in list_schedules :
mini_result = []
for schedule in schedules :
schedule = UnwrapElement(schedule)
# "Start" the transaction
TransactionManager.Instance.EnsureInTransaction(doc)
#count the number of rows and columns in the schedule
table = schedule.GetTableData().GetSectionData(SectionType.Body)
nRows = table.NumberOfRows
nColumns = table.NumberOfColumns
#Collect all of data from the schedule
dataListRow = []
for row in range(nRows): #Iterate through the rows. The second row is always a blank space
dataListColumn = []
for column in range(nColumns): #Iterate through the columns
dataListColumn.Add( TableView.GetCellText(schedule, SectionType.Body, row, column) )
dataListRow.Add( dataListColumn );
# "End" the transaction
TransactionManager.Instance.TransactionTaskDone()
mini_result.append(dataListRow)
result.append(mini_result)
OUT = result
Guess the original code with the list.map (or list.combine) using list levels would works as well but agree, if you’re not allowed to use custom nodes or is able to modify the simplest parts of a python script you’re gonna have a hard time in the land of Dynamo…
I don’t think that List.Map and List.Combine actually work with Python Script, as Python scripts cannot be passed as functions I tried before with no success.
Good luck was not enough Couldn’t wait till tomorrow to try my ideas…
Custom nodes will be the way to go, and if it has to do with sharing the nodes internally you could create a “company-package” containing the custom nodes used in the company
A side-note is that is was possible to pass functions, and I’m guessing using python nodes as functions back in Dynamo 0.6.3 but the functionality disappeared in the migration to 0.7.x…
There is a promise in there that it, as Arnold would say, be back… But so far no cigar.
Implementing that in @mellouze adaption of @Thomas_Mahon script it would look something like this, but it could probably be modified so that you keep your list structure in the output
#Copyright 2016. All rights reserved. Bimorph Consultancy LTD, 5 St Johns Lane, London EC1M 4BH www.bimorph.co.uk
#Written by Thomas Mahon @Thomas__Mahon info@bimorph.co.uk
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
#
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
result = []
x = []
def rec(_lists):
for _list in _lists:
if isinstance(_list,list):
c = rec(_list)
else:
x.append(_list)
return x
schedules = rec(IN[0])
for i in range(len(schedules)):
schedule = UnwrapElement(schedules[i])
# "Start" the transaction
TransactionManager.Instance.EnsureInTransaction(doc)
#count the number of rows and columns in the schedule
table = schedule.GetTableData().GetSectionData(SectionType.Body)
nRows = table.NumberOfRows
nColumns = table.NumberOfColumns
#Collect all of data from the schedule
dataListRow = []
for row in range(nRows): #Iterate through the rows. The second row is always a blank space
dataListColumn = []
for column in range(nColumns): #Iterate through the columns
dataListColumn.Add( TableView.GetCellText(schedule, SectionType.Body, row, column) )
dataListRow.Add( dataListColumn );
# "End" the transaction
TransactionManager.Instance.TransactionTaskDone()
result.append(dataListRow)
OUT = result;
Is there a way to make Dynamo quicker to respond reading schedules data?
I tried this python script for dynamo and bimorph node schedule get data and it never finish to run for a list of 35 schedules with many parameters in each, computer running without success, memory RAM used over 6GB. Literally I waited 5 hours and Dynamo still running.