I have a basic list of guids to iterate over and get the related object, append to another list, then use in a function as one of the arguments. Here is my script:
import fme
import fmeobjects
import uuid
import time
import tempfile
import ifcopenshell
class FeatureProcessor(object):
def input(self, feature):
create_guid = lambda: ifcopenshell.guid.compress(uuid.uuid1().hex)
# Obtain references to master file
filename = FME_MacroValues['OUTPUT_FILE_PATH']
ifcfile = ifcopenshell.open(filename)
owner_history = ifcfile.by_type("IfcOwnerHistory")[0]
building_storey = ifcfile.by_guid(feature.getAttribute('storey_guid'))
guids = feature.getAttribute('_guids{}._guid')
guids = [ifcfile.by_guid(x) for x in guids]
# Relate the wall to the building storey
ifcfile.createIfcRelContainedInSpatialStructure(create_guid(), owner_history, "Building Storey Container", None, guids, building_storey)
for i, x in enumerate(guids):
objects = feature.setAttribute('_guids{%d}._guid' % i, x)
# Write the contents of the file to disk
ifcfile.write(filename)
self.pyoutput(feature)
def close(self):
pass
Here is the list:
Error message:
Python Exception <TypeError>: Could not convert attribute value to a supported attribute type.
Traceback (most recent call last):
File "<string>", line 36, in input
TypeError: Could not convert attribute value to a supported attribute type.
Error encountered while calling method `input'
Python_IFCRELCONTAINEDINSPATIALSTRUCTURE (PythonFactory): PythonFactory failed to process feature
What really helped me was this presentation. I was able to populate the ifc function, but could not correctly output a feature attribute to look at. So close! Any insight is appreciated.
Thanks,
Loren