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]
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
@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):
Comments
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):
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")
You can download the ifcopenshell repo from Github:
https://github.com/IfcOpenShell/IfcOpenShell
I guess you need to clone the repo or download a zip-archive (green "code" button).
Ifcpatch is located in the src subfolder.
https://github.com/IfcOpenShell/IfcOpenShell/tree/v0.7.0/src/ifcpatch
@mcnill thanks! now it worked!
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.
@glennvnbc try with ["IfcWall"] without the dot
@Massimo thanks for the respons
when using ["IfcWall"] i get
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?
yes, you'll need to update ifcopenshell