J
by Johannes990 on 30 Dec 2022, edited 31 Dec 2022
#
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?
M
by Massimo on 30 Dec 2022
#
+1 votes
Hi @Johannes990 , have you tried to follow this example?
https://blenderbim.org/docs-python/ifcopenshell-python/code_examples.html#copy-an-entity-instance
There are 3 ways to copy class, you could try with all these three...
Also, are you sure that the wall with psets is the first also in the file "gopen"? Maybe when you added the wall it went to the end of the list...
T
by theoryshaw on 31 Dec 2022
#
+2 votes
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())
J
by Johannes990 on 31 Dec 2022
#
+1 votes
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.