I’ve tagged this with DataShapes but I guess it’s actually part of a bigger problem I’m having - filtering a category list.
In the image below you’ll see the setup I currently have - basically I want the user to be able to select a series of categories and the then the script aquire data about them. Trouble is I can’t get the All Elements of Category node to work with anything other than the OOTB Category node.
Any thoughts or ideas on how this can be done or where I’m going wrong?
@MarkDT This is not working with me. the category is not being passed.
(Couldn’t find a version of ByName that takes arguments of type (System.Object))
& what if i want to pass a string from data shapes ?
Which category collector node are you using earlier in your graph? The error says you are passing through the system object (ie. the category) rather than the categories name (a string). If you keep as is just put a code block in between with e.Name in and it should be fine.
Not sure what you mean with you question about strings? If you explain a little more I can help.
@Mohammadz@Keith_Wilkinson1 it looks like the Category output from the UI.MultipleInputForm is a Revit API object and that would explain why the Category.ByName and All Elements of Category fails since it only accepts Revit elements wrapped in the Dynamo Revit.Elements class.
Using a code block will only work if the object is from this class. As its not, you’ll get the same error. The solution is slightly more involved; use Python to access the Revit API and then call the name property:
#Copyright 2017. 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 Package: bimorphNodes
#GitHub: https://github.com/ThomasMahon/bimorphNodes/
#Follow: facebook.com/bimorphBIM | linkedin.com/company/bimorph-bim | @bimorphBIM
import clr
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
cat = UnwrapElement(IN[0])
names = []
for c in cat:
names.append( c.Name )
OUT = names
@Thomas_Mahon@MarkDT what Thomas said is absolutely correct and works, and what Mark said also does actually. Thanks guys
The only difference is that we are using different nodes to collect the categories.
-( Categories list ’ Data Shapes ’ ) which seems to be a Revit API Object just like Thomas explained.
-( Categories.all ) which i assume reads the categories directly.
@Keith_Wilkinson1 replace categories.list with categories.all & Mark’s Solution would work OR keep your node & use Thomas’s Python Script. also, keep an eye on how they are both connected to the keys & values
@Thomas_Mahon. I’ll look at this when I’’ back in front of a computer - I’ll need to ask more about the wrapping to see if I can get my head around that.
Thanks @Thomas_Mahon I got this working using your code although I can’t claim to really understand it but I’ve no real experience with Python except at a very simple level… It’s on my list to learn more about.
Hi @Keith_Wilkinson1 ,
All the answers you got on this thread are great. I just wanted to give some extra input:
what UI.MultipleInputForm ++ will output is whatever you feed the “value” input of UI.DropDown Data.
The categories list was added to serve a workflow to batch add shared parameters to a project, it gives Autodesk.Revit.DB objects .
You can also use it this way (the reason the nodes are orange is that some categories won’t be retreived by their name, the rest works) :
Dynamo has its own namespace and classes for Revit elements (Revit.Elements). This is how it interops with Revit / RevitAPI objects. It’s basically a wrapper class which extends the API classes with new properties and behaviours. However, if you want to call RevitAPI methods or properties on these objects it wont work since they’re from a different namespace and class.
Hence, you need to unwrap Dynamo Revit objects using the UnwrapElement() method to expose their Revit API object and then you can work with the API directly. Similarly, in cases where you create RevitAPI elements in a Python script you should wrap them using the ToDSType() method to convert them to Dynamo Revit elements that are then compatible with the library of Dynamo Revit nodes. To avoid confusion, the UnwrapElement() in my python example is redundant since the input objects are already raw RevitAPI objects.
You can read detailed information about the interaction between Revit and Dynamo using IronPython here: