I have decided to delve into the world of Dynamo and for my first script I am attempting to delete all of the unwanted line styles in a shared revit template.
I started by utilizing the “Delete-Imported-Line-Patterns-Using-Dynamo” script created by Konrad Sobon and modifying it to work for line styles instead of line patterns. All seemed to be working well until reaching the actual delete node. This node required a python script, which was provided. I inserted the python script but it failed to execute completely. I am thinking this is because the script was written to delete line patterns and not line styles.
Here is my Dynamo script -
The error message I receive -
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 35, in
AttributeError: ‘List[object]’ object has no attribute ‘Id’
If someone could point me in the right direction so that I might get this code to work I would appreciate it.
Should I provide a copy of the python script for better understanding?
You’ll find that error message pop up quite often when you are not handling lists correctly or not at all. Usually this is resolved by looping through the items in a list and performing the function for each…
Could you copy and paste the code here so we can have a look?
The script looks ok. Doesn’t handle single items though. I think the problem is you have a list of more than one level. Try flattening your list first before plugging it into the script. You can use the list.flatten node
I can’t see the names of any of your nodes in the script image you uploaded earlier. Could you just do a snippet instead and add some watch nodes to see what your data is doing in different places of your graph - no need to do the whole thing, just one of the runs as it looks like you have copied/pasted the same thing a few times.
The error is saying that you need to pass an Element, not a string. It appears you are passing just the name of the element and not the element itself. Elements are shown in watch nodes (or in node drop downs) with an ElementId next to it in green.
I’ve never used that LineStyle node before, but the “All LS Names” port you are using doesn’t give you the Elements, just the name. This is great for how you are using it until the filter by bool node where you really want to filter the Elements. I am assuming the “All Linestyles” port are the Elements and are in the same order as the All LS Names.
I think only one little change is needed and it is to wire the OUT port “All Linestyles” into the filter by Bool’s “List” IN port.