Ifcopenshell-api geometry.edit_object_placement

Hey there :-)
I tried to add a new transformation matrix to a specific wall in my ifc file and the wall moved perfectly. My Problem is, that all inherit placements like the placements of the windows in this wall were not updated, so my windows are not in the wall anymore.
Can somebody help me?

Comments

  • From memory, the edit_object_placement API call actually does reposition all inherited placements. However, this causes a nasty side effect in the case of your situation when you have a window in your wall. Would you like to help modify the API call so that it can selectively determine when to cascade down to inherited placements and when not to?

  • I would love to help, but I want to be honest. I don‘t think that my skills are good enough to help.
    I read an old post of you that it should update the inherited Placements, but I don‘t know why it does not work for my ifc file. Do you have an idea?

  • Is it possible that my window is not related to the wall?
    I created the ifc file with revit

  • It is precisely because it is updating the inherited placements that you are getting the behaviour you're seeing. What you want is not to update the inherited placements, so that the inherited objects (e.g. windows) move with the wall.

    I think it is likely that the window is related to the wall.

    I'll see if I can find some time.

  • Ooooh okay, now I understand the issue. Thank you so much! I would ne so thankful of you could help me out. Thank you so much.

  • Thank you for your help, but the changes did nothing with the windows. They stayed where they were, while the wall moved… :-(

  • Here is my code...maybe there is something wrong with it?
    ifc_file = ifcopenshell.open("TEST.ifc")

    part = ifc_file.by_guid("14PxOZgPT4uuPubh3cNuTR")
    old_matrix = ifcopenshell.util.placement.get_local_placement(part.ObjectPlacement)

    matrix = mathutils.Matrix(old_matrix)

    loc, rot, sca = matrix.decompose()
    print (loc, rot, sca)

    translation = mathutils.Matrix([[0, 0, 0, 0], [0, 0, 0, 0.5], [0,0,0,0], [0,0,0,0]])

    new_matrix = matrix + translation

    ifcopenshell.api.run("geometry.edit_object_placement", ifc_file, product=part, matrix=new_matrix, should_cascade=False)
    ifc_file.write("Test1.ifc")

  • Can you share your file? If it is private, send to dion@thinkmoult.com

  • edited July 2021

    I made an easy test file...here it is... I tried your settings also with other files, but the result was the same.

  • new_matrix = translation @ old_matrix

  • @stephen_l said:
    new_matrix = translation @ old_matrix

    Thank you for your help, but this is not the issue. I wanted to add the new translation to the old matrix this way, because whe wall moved 50cm in y-direction.

  • edited July 2021

    Use
    new_matrix = old_matrix @ translation
    then, so translation occurs in old_matrix space.
    Was mainly referering to syntax issue, where a "+" operator in matrix operations is not valid in blender's matrix context.

  • @herzdame2608 sorry, I didn't look carefully at the code and didn't test at all when I committed that. See this fix: https://github.com/IfcOpenShell/IfcOpenShell/commit/edd737aa5db13883cf63c5764e6b5555d058ac65

    I renamed the parameter to should_transform_children which makes more sense than should_cascade. So in your case, you want to set it to True. Hope it helps.

    herzdame2608
  • edited July 2021

    This is awesome! It works perfectly fine. Thank you so much for your help!!!

Sign In or Register to comment.