ifcopenshell: assign object

Hello.
I am trying to assign various elements to an element assembly. My function call looks like this:
ifcopenshell.api.run("aggregate.assign_object", model, relating_object=Rost, products=elements),
where Rost is an instance of IfcElementAssembly and elements is a list of the elements i would like to bundle into the assembly.
It yields the following error: TypeError: Usecase.init() got an unexpected keyword argument 'products'
First, I am a bit confused as in the source code the argument products is included:
def assign_object(
file: ifcopenshell.file,
products: list[ifcopenshell.entity_instance],
relating_object: ifcopenshell.entity_instance,
)
Can anyone help me spot the mistake?

Second, while I'm at it, I'm also a bit confused as to what the correct usage of the API is. I've seen the syntax used above with api.run("aggregate.assign_object", ...) as well as api.aggregate.assign_object(...). Considering the source code, the latter seems correct to me but I always get a "module is not callable" error.

What is the correct way to use the API?

Thanks in advance

Comments

  • edited August 2024

    not sure if this helps but you can call api functions without run
    please check the relelevant updated page

    however, I tested the function and it's working (I have two walls in the basic model)

    import ifcopenshell
    from ifcopenshell.api import aggregate
    from blenderbim import tool
    model = tool.Ifc.get()
    walllst = model.by_type("IfcWall")
    wall1 = walllst[0]
    wall2 = walllst[1]
    aggregate.assign_object(model, products = [wall1], relating_object = wall2)
    

    I used wall1.Decomposes and wall2.IsDecomposedBy to check the aggregation and it's ok
    PS it's the first time I use this module.. ;)

  • thank you!

Sign In or Register to comment.