OSArch Community

ifcopenshell copy entities with additioanl pset from one model to another

  1. J

    HI all,

    goal

    copy entities with additional pset from one model to another

    process

    i have tried to copy entities using the following:

    wall_copy_class = ifcopenshell.api.run("root.copy_class", model, product = wall)

    then when passed this wall_copy_class in the following

    psets = ifcopenshell.util.element.get_psets(wall_copy_class)

    I was able to see my additional pset(LCA)

    then I created a new model and used the .add() to place geometry, as well wall_copy_class. then use .write()

    Here some picture

    why am I not able to move as well the additional PSET information?

  2. M
  3. T

    I could be wrong, but maybe you have to add the inverse entities of the wall_copy_class object?

    
    import ifcopenshell
    
    import ifcopenshell.geom
    
    import sys
    
    import ifcopenshell.api
    
    
    model = ifcopenshell.open(r"C:\Users\Owner\Desktop\untitled.ifc")
    
    wall = model.by_type("ifcwall")
    
    g = ifcopenshell.file(schema=model.schema)
    
    
    projmod = model.by_type("IfcProject")[0]
    
    wallfromModel = wall[0]
    
    
    g.add(projmod)
    
    
    wall_copy_class = ifcopenshell.api.run("root.copy_class", model, product = wall[0])
    
    
    g.add(wall_copy_class)
    
    
    for x in model.get_inverse(wall_copy_class):
    
        g.add(x)
    
    
    
    
    g.write(r"C:\Users\Owner\Desktop\new.ifc")
    
    gopen = ifcopenshell.open(r"C:\Users\Owner\Desktop\new.ifc")
    
    gopenwall = gopen.by_type("ifcwall")[0]
    
    gopenpsets = ifcopenshell.util.element.get_psets(gopenwall)
    
    wallfromModelpsets = ifcopenshell.util.element.get_psets(wallfromModel)
    
    
    
    
    #print(model.to_string())
    
    #print(g.to_string())
    
    #print(gopen.to_string())
    
  4. J

    Hi both ... first of all, thanks for spending time reading my code and rev. Next time I will make it more readable and as well copy/paste-able ( I will help you to help me :) )

    @Massimo , yes I had only one object.

    @theoryshaw, it works well... I was able to get what I needed thank you.

Login or Register to reply.