gbXML Import Fail - "Optional String has no attribute 'upper'

very simple gbxml import is failing with the following error message. “1. Solution exception:‘OptionalString’ object has no attribute ‘upper’”
The error happens when it tries to convert the construction name into upper case. Line 308 of the script.

    if vers < 27:
        constructionCollection[str(c.name().upper())] = getHBConstruction(c, materials)

I added a print statement to check c.name() content and the type and I got back the following:

The model is imported from C:\Users\vel84628\Documents\test\TestOPexported.xml

> 2013 External Window
> <type ‘OptionalString’>
Runtime error (MissingMemberException): ‘OptionalString’ object has no attribute ‘upper’
Traceback:
line 310, in script

This means it finds the construction “2013 External Window”, and then it is not able to convert it to upper case because it is an OptionalString type instead of String…

So I changed the line 308 to:

constructionCollection[str(c.name()).upper()] = getHBConstruction(c, materials)

in this way .upper is applied to str(c.name()) instead of c.name(), which might be the reason the str() funtion is there in the first place. So this worked, but then it keeps finding the same problem throughout the script and other related scripts.

Any ideas on how to solve this? Am I missing something or is this a bug?

TestOPexported.xml (121.5 KB)
simpleimport_Model_from_gbXML.gh (463.0 KB)

I exported the gbxml from Openstudio.
Im using openstudio 2.5, HB and LB where updated on last release. Rhino 5.

P.S. I tried importing one file with no constructions or materials and it worked. Maybe the problem actually is a bug?

It is a bug. change the line to:

constructionCollection[str(c.name()).upper()] = getHBConstruction(c, materials)

and it should work. .upper() should be after the parenthesis.

update: Never mind! I should have read your post more carefully. It seems you have already addressed the issue on your side. Let me see if I can resolve the issue on my side.

thanks mostapha.
Same problem in line 157 of getOSSurfaceConstructionName . I commented out # to line 351 and 375 of the XMLTOHB. That solved it.

line 351 and 375:

construction, missingCcount = getOSSurfaceConstructionName(s, constructionCollection, missingCcount)

This should do it:

Update your installation and it should work fine. I could import your file on my machine.

1 Like