Hi peeps
Trying to filter out only objects that are not curently owned by others in a shared project. But i get this error. Im vaguely familiar with coding. This is not my code, i got it from a colleague. Thanks to whoever made it.
Any tips to what the problem may be here?
import clr
clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference(“RevitAPI”)
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference(‘System.Core’)
from System.Collections.Generic import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
def ToList(x):
if isinstance(x,list):
return UnwrapElement(x)
else:
return [UnwrapElement(x)]
elem = ToList(IN[0])
iDs = [el.Id for el in elem]
Ids = ListElementId
try: checkedout_el = WorksharingUtils.CheckoutElements(doc,Ids)
except Exception,er: checkedout_el = str(er)
OUT = checkedout_el
import System
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference('System')
from System.Collections.Generic import List
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
def ToList(x):
if isinstance(x,list):
return UnwrapElement(x)
else:
return [UnwrapElement(x)]
elem = ToList(IN[0])
iDs = [el.Id for el in elem]
Ids = ListElementId
try: checkedout_el = WorksharingUtils.CheckoutElements(doc,Ids)
except Exception,er: checkedout_el = str(er)
OUT = checkedout_el
I changed the libraries! i took the framing from:
https://primer.dynamobim.org/10_Custom-Nodes/10-6_Python-Templates.html
I did not find the error. ListElementId is not difined…
…hmmm
Hi, thanks for replying.
Are you saying you got it to work by doing that? Or that you did not find what is causing the error?
My best guess was that a elemt was missing some info, but it did not work with any element. So my guess is there something maybe missing in the code.
Any help appreciated, getting this working would really help me out.
No, i was not able to solve it. there is variable not defined.
My thoughts as well. Hope there is a big brain in here up for the challenge
Thanks for having look at it
@Ivarandersenjobb try it like that:
Ids = List[ElementId]()
for el in elem:
Ids.Add(el.Id)
1 Like
import System
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference('System')
from System.Collections.Generic import List
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
def ToList(x):
if isinstance(x,list):
return UnwrapElement(x)
else:
return [UnwrapElement(x)]
elem = ToList(IN[0])
iDs = [el.Id for el in elem]
Ids = List[ElementId]()
for el in elem:
Ids.Add(el.Id)
try: checkedout_el = WorksharingUtils.CheckoutElements(doc,Ids)
except Exception,er: checkedout_el = str(er)
OUT = checkedout_el
It runs!
Thank you for the effort!
I tried you exact code. Didn’t run here.
May i be missing something in my set-up?
The instalation is just 2 months old. I have just run my usual 3-4 scripts. Not changed anything. Only have 4-5 packages installed.
Revit 2021.1.4
Dynamo core 2.5.1.8786
Dynamo Revit 2.6.1.8850
The file im working on is started in Revit 2018.
Its a BIM360 project.
May i be missing a Python dependancy/package more on a “system-level”?
Whats your imput?
it should be Elements!
my run was with Furniture family instances
@Ivarandersenjobb remove line 35 from your code: iDs = [el.Id for el in elem]
1 Like
Worked, kinda. The error moved to line 39
Any further ideas?
whats your imput? values or elements?
Object has no Id. Sounds like the imput is not correct!
import System
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference('System')
from System.Collections.Generic import List
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
def ToList(x):
if isinstance(x,list):
return UnwrapElement(x)
else:
return [UnwrapElement(x)]
elem = ToList(IN[0])
Ids = List[ElementId]()
for el in elem:
Ids.Add(el.Id)
try: checkedout_el = WorksharingUtils.CheckoutElements(doc,Ids)
except Exception,er: checkedout_el = str(er)
OUT = checkedout_el
Python lists cannot be divided into separate lists based on characters that appear in the values of a list. This is unlike strings which values can be separated into a list. The AttributeError is an exception thrown when an object does not have the attribute you tried to access. The ‘list’ object has no attribute ‘split’ and you’re trying to call python split() function on the whole list of lines, and you can’t split a list of strings, only a string. So, you need to split each line, not the whole thing.
To solve the above problem, you need to iterate over the strings in the list to get individual strings; then, you can call the split() function.