DB.BuiltInParameter.DPartAreaComputed value not accessible

Hello,
I’m creating tool that will compute center of gravity of wood framed modular construction made mostly with Structural Framing elements as frame and Parts as sheathing. Unfortunately while testing it in different projects I have encountered weird issue.

When I’m trying to get area of part with"

    cummulative_parts_area = 0
    for item in parts:
        item_host = str(item.LookupParameter("FM HostMemberSortMark").AsString())
        part_layer = str(item.LookupParameter("Framing Member Mark").AsString())
        if 'ssw' in item_host.lower():
            removable_parts.append(item)
            if part_layer.lower() == 'w1':
                print(item.Id)
                print(item.Category.Name)
                part_area = item.get_Parameter(DB.BuiltInParameter.DPART_AREA_COMPUTED).AsDouble()
                cummulative_parts_area += part_area

I receive AttributeError: ‘NoneType’ object has no attribute ‘AsDouble’. Even though RevitLookup and parameters are showing those values. Here’s the picture with this issue:

What is more interesting DB.BuiltInParameter.DPART_VOLUME_COMPUTED is accessed correctly.

Have you ever get simmilar issues? I’d appreciate your help.

Regenereating document didn’t work so for now I’ll just encapsulate with try: ... except ... but I’d preferer more consistent solution.

@MarcinTalipski ,

be aware internal units are imperial. try to implement units. f.e. like this:

# ✂ Functions
def convert_f_to_m(value):
	return DB.UnitUtils.Convert(value,UnitTypeId.Feet,UnitTypeId.Meters)

def convert_m_to_f(value):
	return DB.UnitUtils.Convert(value,UnitTypeId.Meters,UnitTypeId.Feet)

Thank you @andreasd811 I’ll note this. As swaping feets to milimeters is just multiplying value by 304.8 I didn’t put much thoughts to this.

Seems like I haven’t checked correctly those parameters in original post, actually there are no parameters Area and Thickness in this element. Even when I’ve reseted shape those are not calculated.

Looks like it’s Revit problem.

Can you show snip from revitlookup for this parameter?

Looks like I have lied to my self checking those parameters or I’ve selected wrong part. Currently those parts don’t have Area and Thickness parameters.

Also I have found culprit. Those parts were merged and thus Revit graciously decided that I won’t need Area parameter and deleted it.

1 Like