Python - WallType - can't get the walltype Name

I am trying to iterate through walls with a python script, some of the walls need to be manipulated according to the wallType (set location line to exterior, moved outwards etc.)
For some reason I am getting an error when I am trying to get the wallType Name property, I looked up the API ref - and could not see an issue with my code - can anyone help ?

1 Like

Would you be able to post the .DYN file along with the full code? If not, would you be able to provide a stripped down version which replicates your error?

hello
it’s a limitation of Ironpython
try to use
walltyp = walls[0].WallType
outputname = Element.Name.GetValue(walltyp)

or

walltyp = walls[0].WallType
outputname = walltyp.get_Parameter(BuiltInParameter.SYMBOL_NAME_PARAM)

5 Likes

Hey @c.poupin , thanks, that is brilliant.
Out of curiosity, is this an issue of multiple inheritance ?
When I look at the Revit API docs it looks linear to me. How can you tell it is multiple inheritance ?

image

Thanks again , Jonathan (thank you too @cgartland for reaching out)

I correct myself, this is not quite a multi-inheritance problem
WallType Property Name is Inherited from ElementType


and there is no getter in ElementType Property Name

more information here with same problem with Room Class

but in C# there is no problem
https://forums.autodesk.com/t5/revit-api-forum/get-name-of-walltype-from-elementid-of-getvalidtypes/td-p/5254317
but it is beyond my knowledge, if someone can possibly provide more details on this subject

3 Likes

I would suggest you do something as shown in the image, and i have attached the code below as well.

This works by getting the wall types, then converts it into a Dynamo element via the “ToDSType” method then getting its name :slight_smile:

#Created By Brendan Cassidy

import clr
# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

#Checks if input is list, if not makes its a list
if isinstance(IN[0],list):
	wallsinput=UnwrapElement(IN[0])
else:
	wallsinput=[UnwrapElement(IN[0])]
		
output=[]

for wall in wallsinput:
	#Gets wall type
	wallType = wall.WallType
	
	#Converts it to a Dynamo Element then gets its name
	wallName = wallType.ToDSType(False).Name
	
	#Outputs the wall type and its name
	output.append([wallType,wallName])
OUT = output
5 Likes

Hi @c.poupin ,
I now realize I saw that there’s no get function for ElementType.Name property and did not give it too much thought .I’ts odd , I wonder if there’s a reason for this.
Thanks again , Jonathan

Thanks @Brendan_Cassidy , I did not need the name outside the python - it’s a part of manipulations that happens inside the python script and need to be set according to the wall type.

I was only giving a output to show that it is the name that is outputted, you can utilize the line with "wallName = " with what ever you was trying to use it for.

Just follow the same process i did when you have the Walltype element.

1 Like