Get CADLink Name from ImportInstance - Python

Hello!

I am attempting to extract the CADLink Name from an import instance, I’m working on this now to then merge it into another Python node. I’ve found a way to get the CadLink type from an import instance, and I’ve gotten the name from a cad link type in separate python nodes, but when I combine the two into methods, I run into this error. Let me know if more information is needed.
Thanks,

ele isn’t a list so you can’t loop it.

names.append(ele.Name)

It works in Case-1.
It works in Case-2 when you get elements in 2a and supply it to 2b
But it fails in Case-3 when you combine 2b and 2b in a single script.

Is this the problem @patrick_podeyn?

1 Like

Yes, that is the problem. They work separately and connected together, but when you do it as one python node I can’t figure out why it doesn’t work.

What if you try

Element.Name.__get__(link)

Or

elem.get_Parameter(Built-in parameter.ALL_MODEL_TYPE_NAME).AsString()

3 Likes

@SeanP Works like a charm.

Any idea why elem.Name is not working?

3 Likes

Yes, it’s a known limitation of class inheritance conflicts in IP.

2 Likes

Works like a charm as well. So reading this, it’s pretty straightforward in understanding how it works. You get the elements name, but I’m not sure what the __get__ does or what else I can do with this for future uses? Is this another method for getting information about the data?

The second method makes sense also as we are getting a built-in parameter relating to the element, which I would assume almost all Revit elements have that parameter value All_Model_Type_Name" then reading it as a string.

Are these methods ones we should utilize only if the someElement.Name method doesn’t produce the results we want? or should we always try to utilize one of the two methods you illustrated?

Many thanks again for the solution!

1 Like

I am glad to hear it is working!

Here is some lite reading on the get and set descriptors for python:
Descriptor HowTo Guide — IronPython 2.7.2b1 documentation (ironpython-test.readthedocs.io)

I will say that I have gone to almost exclusively using one of these two methods (typically the BIP) just do I don’t have to fight or figure out which ones will and won’t work. Most often the Types are the ones with the most issues from what I’ve experienced.

1 Like

I appreciate it, Sean! This is pretty exciting as I am now able to consolidate a huge chunk of my graph into a few python nodes.

1 Like