Hello guys,
when I use only one level and apply that method, it works but if I connect a list of levels like that:
for level in levels:
level.Maximize3DExtents()
# Phython-Standard- und DesignScript-Bibliotheken laden
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitAPI","RevitServices")
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
level = UnwrapElement(IN[0])
TransactionManager.Instance.EnsureInTransaction(doc)
level.Maximize3DExtents()
TransactionManager.Instance.TransactionTaskDone()
Dynamo does not respond and I have to close Revit via TaskManager. Why is it like that?
I did not try with try and except. Maybe that can work but still weird.
Daan
November 25, 2021, 7:34pm
3
Hi @Deniz_Maral ,
Whenever I have some Python code that doesn’t work with a list of lists I create a Custom node and set that custom node to @L2 .
1 Like
Hello @Daan ,
I also thought about it but we can’t create Custom Nodes for tools that we would use once.
What I also realized that via Transaction(doc) it can’t be applied…
Can you show the full code for multiple levels?
Hello @Nick_Boyts ,
# Phython-Standard- und DesignScript-Bibliotheken laden
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitAPI","RevitServices")
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
levels = UnwrapElement(IN[0])
TransactionManager.Instance.EnsureInTransaction(doc)
for level in levels:
level.Maximize3DExtents()
TransactionManager.Instance.TransactionTaskDone()
Seems right to me. Make sure you don’t have any elements way out in space that are causing your levels to blow up.
It is not the case. I don’t have any object, that is far away or something like that. The transaction can not be done somehow when I do it over looping.
Also you can use Transaction Class from API… It gives an error.
Your code worked for me in 2020. Have you tried in a blank project? I’m guessing there’s something going on in your model that it’s getting stuck on.
EDIT: Are you running in Manual mode? I get stuck in a loop if I try to run in Automatic.
1 Like
I tried it in automatic mode. Let me try in manual mode.
Edit: That’s it! It was because of automatic mode! Thanks @Nick_Boyts !