Kangal
November 17, 2018, 1:13pm
1
Hi all,
I do not want to take the schedules one by one, but take all my schedules in once in my Python script.
can someone help me please with the script.
Preformatted text
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
#Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
from System.Collections.Generic import *
#Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
refschedule = UnwrapElement(IN[0])
gg = UnwrapElement(IN[1])
refdefinition = refschedule.Definition
lol = refdefinition
TransactionManager.Instance.EnsureInTransaction(doc)
refdefinition.IsItemized = gg
TransactionManager.Instance.TransactionTaskDone()
OUT = refdefinition
Preformatted text
Thank you in advance.
Regards
Kangal
The best solution would probably be to nest the python in a custom node
Kangal
November 17, 2018, 3:04pm
4
Hi Jonathan,
You already know how my company thinks about Custom Node
In January I have an appointment to tell how important Custom nodes are.
I need help until then. Can you help me please
Regards
Kangal
I’m not at a computer till tomorrow, but try to look into ‘‘for loops’’ in python and give it a shot it is not as scary as it seems
Kangal
November 17, 2018, 3:22pm
7
Hi,
I am now behind the PC and try different things in Python.
in January I will also receive a course on Pyton with revitAPI
Hope to see your reaction tomorrow.
Regards
Kangal
Kulkul
November 18, 2018, 4:35am
8
Hi @Kangal @Jonathan.Olesen
How about creating a script with any list structure
import clr
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
ProcessLists = lambda function, lists: [ProcessLists(function, item) if isinstance(item, list) else function(item) for item in lists]
ApplyFunction = lambda func, objs: ProcessLists(func, objs) if isinstance(objs, list) else [func(objs)]
def Unwrap(item):
return UnwrapElement(item)
if isinstance(IN[0], list):
schedule = ProcessLists(Unwrap, IN[0])
else:
schedule = Unwrap(IN[0])
itemize = IN[1]
def task(schedule):
definition = schedule.Definition
result = definition
TransactionManager.Instance.EnsureInTransaction(doc)
result.IsItemized = itemize
TransactionManager.Instance.TransactionTaskDone()
return result
OUT = ApplyFunction(task,schedule)
9 Likes
For those who do not know, what is the concern?
Kangal
November 18, 2018, 7:41am
10
Hi Jacob,
My company does not want to use a custom node.
it can be shared between different branches without having to download the package.
I’m talking with IT-department how we can arrange / download parts in advance without bothering the users.
The goal is that de users use the script in DynamoPayer, without downloading anythng.
Regards
Kangal
Kangal
November 18, 2018, 7:57am
11
Hi Kulkul,
This is awesome, it works fine!
Thank you
1 Like
kennyb6
November 19, 2018, 1:19am
12
As a novice in python this was really cool to see. The lambda function and its recursion is all new to me. Thanks for sharing!
1 Like