ksobon / archilab

this is archi-lab.net dynamo repo
69 stars 19 forks source link

UnhideElements doesn't work, but HideElements does given the same inputs. #71

Closed Tyree closed 2 years ago

Tyree commented 2 years ago

I’m setting up a Revit Dynamo script that will hide (or unhide) all instances of a family type. The script is simple, it gets all the instances, makes a list of the corresponding view owners for each instance and then uses the archi-lab View.HideElements to hide them. That part works. Now I’m testing the UNHIDE option and nothing happens. I get a Traceback saying AttributeError: 'List[ElementId]' object has no attribute 'length'

Not sure what is going on behind the scenes, but using it the same way as HideElements does NOT work.

Any help is appreciated! Thanks!

ksobon commented 2 years ago

@Tyree could you please post sample files (Revit + Dynamo). I don't have a way to regenerate these errors. The error states that there are no items in a list. That means there is nothing to be un-hidden. Without sample files, I cannot say anything else.

Tyree commented 2 years ago

Hello, Konrad. Thanks for the reply! I also sent you a message on the Dynamo forum. I'll copy that here: So, I’m not a python programmer. I work in PHP and javascript mostly. But, I changed if ids.length > 0: in your UnhideElements function to if ids.Count > 0: and then everything works. I’m sure you had some scenario that made you change the code to length, but it would seem in some cases you need it to be count. Not sure how best to remedy that.

From my minimal coding background, wouldn’t you use count to check for existence or population of the ids object rather than length? I thought length was only for strings and such, not objects or arrays.

Again, I am a novice in all respects to this. So, please don’t take my observations as criticism! :-)

Thanks for your time!!!

ksobon commented 2 years ago

@Tyree it depends on the object/language. So in C# lists have "Count" but in Python lists have "length". It sounds like a mistake on my part since we would be measuring the length of the .NET list.

Something that your comment made me realize. It looks like you are using an outdated package. I no longer support Hide and UnHide nodes that were written in Python. They were transferred to C# a while ago. Please update:

image

Tyree commented 2 years ago

If I'm using Revit 2021, do I just get the latest 2021 version? 2021.25.2721

ksobon commented 2 years ago

@Tyree yes, so the last two digits in that string refer to Revit version. Looks like you got the right one.

Tyree commented 2 years ago

@ksobon I installed that version and got the same problem with the unhide, but when double-clicked the node to check the code, it still says Python. When I edit the Python script to use count instead of length (what worked before), I still get the same error only it says AttributeError: 'List[ElementId]' object has no attribute 'count'.

ksobon commented 2 years ago

image

LAST TWO digits refer to supported Revit version. First four is just the year that we are currently in.

Tyree commented 2 years ago

Excellent. Got the latest version on there and it works. Thanks! Are all Dynamo package versions like that? I've wondered how one would know which version to install.