OSArch Community

Copy Pset Property Value to another Pset

  1. M

    Hi All

    Im still trying to figure out how i can copy a Pset property value from one Pset, into another. i'm closer than i was a few weeks ago, and have started looking at how i can do this with code.

    The code below, adds a new Pset & Property and value, to all "IfcPile" classes. which is great.

    what i cant figure out is how do i find all current Psets and properties for all "IfcPile"

    and how can i take an existing Pset and property value and copy that value into a newly created Pset.

    this is all i have so far, i have managed to add a new Pset and property value, to all IfcPiles, which for me is a massive step. i just cant find any examples on how to take existing data and copy somewhere else.

    `import ifcopenshell

    import ifcopenshell.api

    ifc = ifcopenshell.open('C:\Users\jenso\Documents\IDS_IFC Blender BIM Test\Pile with compliant Psets only.ifc')

    element = ifc.by_type("IfcPile") [0]

    pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Pset_NEWPropertySet")

    ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"PileDiameter": (Value), })

    How do i read a current Pset called "Pset Properties" for all ("IFCpiles"), and find a propert called "Diamater",

    and then add all Diameter values, into the "Pset_NewPropertySet" property = "PileDiamter"

    so take a property value from one Pset into another Pset`

    Grateful for any advice and really grateful if anyone have give a code example.

    What I'm trying to do is make good/compliant poor .Ifc file, starting with "IfcPile".

  2. B

    You can use ifcopenshell.util.element.get_pset and search by name. The data is read as a python dictionary, which you can then assign to the newly created pset. Try the code below:

    
    import ifcopenshell
    
    ifc = ifcopenshell.open('C:\Users\jenso\Documents\IDS_IFC Blender BIM Test\Pile with compliant Psets only.ifc')
    
    all_ifc_piles =  ifc.by_type("IfcPile")
    
    for element in all_ifc_piles:
    
        pset = ifcopenshell.util.element.get_pset(element, "Pset Properties")
    
        diameter = pset['Diameter']
    
        pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Pset_NewPropertySet")
    
        ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"PileDiameter": diameter})    
    
  3. M

    @bruno_perdigao thank you so much, that's work perfectly and just what i needed

    Much appreciated

Login or Register to reply.