OSArch Community

IFCPatch tool now available

  1. M

    @PeterPetersen if you know Python, it isn't that hard. Take a look in the .github/workflows folder and you can copy paste from how we ship other PyPI builds. It would also help if you could file a bug to track this to bring awareness to it. Maybe someone else can help contribute.

  2. J

    Hi I hope this is the right place to post this. I am attempting to upgrade a 2x3 to IFC 4 from a C# application. I have taken the simplest approach I can imagine by running the command from powershell, to verify I am running correctly. Once I have completed this I will add to my dll. I am receiving an error but can't make sense of why. Please see PowerShell commands and error below . I have also attached a screen shot of the directory I am running power shell from and the 2x3 file I am trying to upgrade.

    As I am working in C# I have mostly relied on Xbim. I have been unable to find any other resource to upgrade from 2x3 to IFC4. If there is another option for C# I would love to hear about it.

    Thank you,

    Jason

    
    Windows PowerShell
    
    Copyright (C) Microsoft Corporation. All rights reserved.
    
    
    Try the new cross-platform PowerShell https://aka.ms/pscore6
    
    
    PS D:\_AdvancedSteel\OneDrive_2023-10-09\JasonHolden\02SampleModel> python
    
    Python 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)] on win32
    
    Type "help", "copyright", "credits" or "license" for more information.
    
    >>> the_path_of_ifcpatch = "C:/Users/jason/AppData/Local/Programs/Python/Python39/Lib/site-packages/ifcpatch/"
    
    >>> import sys
    
    >>> sys.path.append(the_path_of_ifcpatch)
    
    >>> import ifcpatch
    
    >>> import lark
    
    >>> ifcpatch.execute({
    
    ...     "input": "nclous_IFCexport.ifc",
    
    ...     "output": "P0042_01-IFC4-Copy.ifc",
    
    ...     "recipe": "Migrate",
    
    ...     "log": "ifcpatch.log",
    
    ...     "arguments": [".IfcWall"],
    
    ... })
    
    Traceback (most recent call last):
    
      File "<stdin>", line 1, in <module>
    
      File "C:\Users\jason\AppData\Local\Programs\Python\Python39\lib\site-packages\ifcpatch\__init__.py", line 76, in execute
    
        patcher = recipe.Patcher(args["input"], args["file"], logger, *args["arguments"])
    
    KeyError: 'file'
    
    >>>
    

  3. M

    I'm not aware of a C# solution to upgrade models unfortunately. Using IfcPatch is a great idea, you can also ship it as a standalone executable.

    The error is because you're not calling IfcPatch correctly: you're missing the "file" setting. You should call it like this:

    
    import ifcpatch
    
    
    output = ifcpatch.execute({
    
        "input": "input.ifc",
    
        "file": ifcopenshell.open("input.ifc"),
    
        "recipe": "Migrate",
    
        "arguments": ["IFC4"],
    
    })
    
    ifcpatch.write(output, "output.ifc")
    

    See the documentation: https://blenderbim.org/docs-python/ifcpatch.html

    I've just realised that our examples for the actual recipes are missing the file argument too https://blenderbim.org/docs-python/autoapi/ifcpatch/recipes/Migrate/index.html which is a bug. It's now been fixed https://github.com/IfcOpenShell/IfcOpenShell/commit/640341715c40af9917475409dc093854cf708575

  4. J

    Thank you awesome. It works perfectly.

  5. Z

    I can't use ifcpatch

    It's giving an error when importing. What may be the problem?

  6. M

    Hi Zanoni, have you put the ifcpatch folder to python's site-packages folder? If yes, is it nested?

    You should have a folder structure like that on windows (or something similar on mac/linux):

  7. Z

    I tried to install via pip install ifcpatch but I couldn't.

    How do I download the ifcpatch folder?

    I'm just trying to shift the ifc model on the z axis. I tried using pure ifcopenshell but in each iteration the starting position of the next element is the ending position of the previous iteration. I tried to reset the initial position of the elements but it didn't work.

    import ifcopenshell

    def deslocar_elements(model_ifc, displacement_z):

    for element in model_ifc.by_type('IfcProduct'):
    
    
    
        initial_position = list(element.ObjectPlacement.RelativePlacement.Location.Coordinates)
    
    
    
    
        new_position = [initial_position[0], initial_position[1], initial_position[2] + displacement_z]
    
    
    
    
        element.ObjectPlacement.RelativePlacement.Location.Coordinates = new_position
    
    
    
        new_position = [initial_position[0], initial_position[1], initial_position[2] - displacement_z]

    file_ifc = "D:....\model.ifc"

    displacement_z = 20.0

    model_ifc = ifcopenshell.open(file_ifc)

    deslocar_elements(model_ifc, displacement_z)

    model_ifc.write("D:...\model_new.ifc")

  8. M
  9. Z

    @mcnill thanks! now it worked!

  10. G

    I am a noob in ifcopenshell and ifcpatch.

    My goal is to create individual ifc files for every prefabricated concrete element with accessories from an existing ifc file created with Tekla. The following code causes an error which i did not find on other forums. Any help or tips are appreciated.

    There are multiple IfcWall entities in my ifc file.

    Perhaps a little context... I work from Belgium, where we use a decimal comma in stead of a point. Maybe this could be important.

    output = ifcpatch.execute({
    
        "input": "S:file.ifc",
    
        "file": ifcopenshell.open("S:/file.ifc"),
    
        "recipe": "ExtractElements",
    
        "arguments": [".IfcWall"]
    
    })
    
    
     Traceback (most recent call last):
    
      File "S:\IFC\IfcOpenShell\Test ifcpatch ExtractElements.py", line 43, in <module>
    
        output = ifcpatch.execute({
    
      File "S:/Python/Lib/site-packages/ifcopenshell/ifcpatch\ifcpatch\__init__.py", line 79, in execute
    
        patcher.patch()
    
      File "S:/Python/Lib/site-packages/ifcopenshell/ifcpatch\ifcpatch\recipes\ExtractElements.py", line 64, in patch
    
        for element in ifcopenshell.util.selector.filter_elements(self.file, self.query):
    
      File "S:\Python\lib\site-packages\ifcopenshell\util\selector.py", line 263, in filter_elements
    
        transformer.transform(filter_elements_grammar.parse(query))
    
      File "S:\Python\lib\site-packages\lark\lark.py", line 658, in parse
    
        return self.parser.parse(text, start=start, on_error=on_error)
    
      File "S:\Python\lib\site-packages\lark\parser_frontends.py", line 104, in parse
    
        return self.parser.parse(stream, chosen_start, **kw)
    
      File "S:\Python\lib\site-packages\lark\parsers\earley.py", line 279, in parse
    
        to_scan = self._parse(lexer, columns, to_scan, start_symbol)
    
      File "S:\Python\lib\site-packages\lark\parsers\xearley.py", line 152, in _parse
    
        to_scan = scan(i, to_scan)
    
      File "S:\Python\lib\site-packages\lark\parsers\xearley.py", line 125, in scan
    
        raise UnexpectedCharacters(stream, i, text_line, text_column, {item.expect.name for item in to_scan},
    
    lark.exceptions.UnexpectedCharacters: No terminal matches ',' in the current parser context, at line 1 col 1
    
    
    
    ,IfcWall
    
    ^
    
    Expected one of: 
    
        * ESCAPED_STRING
    
        * BANG
    
        * __ANON_3
    
        * TYPE
    
        * __ANON_1
    
        * __ANON_0
    
        * SLASH
    
        * __ANON_4
    
        * LOCATION
    
        * CLASSIFICATION
    
        * __ANON_2
    
        * MATERIAL
  11. A

    @glennvnbc said:

    Is this a recent update issue?

    yes, you'll need to update ifcopenshell

  12. G

    @Massimo thanks for the respons

    when using ["IfcWall"] i get

      File "S:\IFC\IfcOpenShell\Test ifcpatch ExtractElements.py", line 44, in <module>
    
        output = ifcpatch.execute({
    
      File "S:\Python/Lib/site-packages/ifcopenshell/ifcpatch\ifcpatch\__init__.py", line 79, in execute
    
        patcher.patch()
    
      File "S:\Python/Lib/site-packages/ifcopenshell/ifcpatch\ifcpatch\recipes\ExtractElements.py", line 65, in patch
    
        self.add_element(element)
    
      File "S:\Python/Lib/site-packages/ifcopenshell/ifcpatch\ifcpatch\recipes\ExtractElements.py", line 70, in add_element
    
        new_element = self.append_asset(element)
    
      File "S:\Python/Lib/site-packages/ifcopenshell/ifcpatch\ifcpatch\recipes\ExtractElements.py", line 87, in append_asset
    
        return ifcopenshell.api.run(
    
      File "S:\Python\lib\site-packages\ifcopenshell\api\__init__.py", line 66, in run
    
        result = usecase_class(ifc_file, **settings).execute()
    
    TypeError: Usecase.__init__() got an unexpected keyword argument 'reuse_identities'

    I am using IfcOpenShell (0.7.0.231218) - latest version to date

    The documentation on blenderbim has the following information for class ifcopenshell.api.project.append_asset

    class ifcopenshell.api.project.append_asset.Usecase(file, library=None, element=None,reuse_identities=None)

    The current ifcopenshell\api\project\append_asset.py does not have a parameter "reuse_identities"

    def __init__(self, file, library=None, element=None):

    Ifcpatch ExtractElements calls api.project.append_asset with reuse_identities

    return ifcopenshell.api.run("project.append_asset", self.new, library=self.file, element=element, reuse_identities=self.reuse_identities)

    Is this a recent update issue?

  13. M

    @glennvnbc try with ["IfcWall"] without the dot

  1. Page 1
  2. 2

Login or Register to reply.