Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BlenderBim - Export ifc from selection - Feature request #4316

Open
Tudjack opened this issue Feb 13, 2024 · 14 comments
Open

BlenderBim - Export ifc from selection - Feature request #4316

Tudjack opened this issue Feb 13, 2024 · 14 comments

Comments

@Tudjack
Copy link

Tudjack commented Feb 13, 2024

It would be nice to have a feature to be able to extract selected objects to an output ifc.
Similar to "ExtractElements" recipe from Ifc Patch but for specific selected objects, not for a full subset of elements.

@theoryshaw
Copy link
Member

You might know this already. The following is one way to do it...

2024-02-13_10-55-06_blenderBlenderblender.mp4

@Tudjack
Copy link
Author

Tudjack commented Feb 13, 2024

Wow! Thanks!
I would have never found this out.
Anyway, a separate button which does all the above would be less counterintuitive. Just a suggestion.
But thanks a lot for this method, I will definitely try it out!

@Tudjack
Copy link
Author

Tudjack commented Feb 13, 2024

Unfortunately I am receiving the following error:

Python: Traceback (most recent call last):
File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\blenderbim\bim\module\project\operator.py", line 734, in execute
ifc_importer.execute()
File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\blenderbim\bim\import_ifc.py", line 240, in execute
self.create_collections()
File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\blenderbim\bim\import_ifc.py", line 1515, in create_collections
self.create_aggregate_and_nest_collections()
File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\blenderbim\bim\import_ifc.py", line 1559, in create_aggregate_and_nest_collections
elif element.IsNestedBy:
File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\blenderbim\libs\site\packages\ifcopenshell\entity_instance.py", line 191, in getattr
raise AttributeError(
AttributeError: entity instance of type 'IFC2X3.IfcReinforcingBar' has no attribute 'IsNestedBy'. Did you mean: 'IsDefinedBy'?

@theoryshaw
Copy link
Member

Can you share the file, or a parred-down version of it, if sensitive?

@theoryshaw
Copy link
Member

Btw, i think i was incorrect in thinking you could create a new file...
https://community.osarch.org/discussion/1968/how-to-create-a-new-ifc-file-with-just-a-few-select-objects-from-another-ifc-file#latest

I just tested, and it doesn't seem to work, like i thought it would. Sorry for the misinformation.

@Tudjack
Copy link
Author

Tudjack commented Feb 13, 2024

Unfortunately I can't share the file, it's under a very strict NDA.
It's a large file as well, thousands of reinforcing bars and couplers.
Just want to find a way to create a "mini ifc" out of a few selected bars.

@Tudjack
Copy link
Author

Tudjack commented Feb 13, 2024

the only way I managed to extract the bars I want in a separate ifc was to delete all other elements not in my selection.
And it basically took me the whole day. It's incredibly slow, sometimes Blender crashes as well. Did not expect deleting ifc elements to cause heavy CPU processing.

@theoryshaw
Copy link
Member

Did not expect deleting ifc elements to cause heavy CPU processing.

yes, unfortunately, this is a known issue.

@Moult
Copy link
Contributor

Moult commented Feb 13, 2024

Have you tried using the ExtractElements parch recipe? I think it does what you're asking (although the graphical integration isn't as slick as it could be)

@Tudjack
Copy link
Author

Tudjack commented Feb 14, 2024

I tried it pasting the GlobaID of one element into the Query, but I don't know how to paste in multiple GuID's.
I don't know how to write the arguments for this.

@Tudjack
Copy link
Author

Tudjack commented Feb 14, 2024

Little update. It actually works, just pasting the Guid's separated by commas. The problem I faced was actually for some elements which give me an error when trying to export. It's something with this ifc file.

I will paste the error here:

Python: Traceback (most recent call last):
  File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\blenderbim\bim\module\patch\operator.py", line 93, in execute
    output = ifcpatch.execute(
  File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\blenderbim\libs\site\packages\ifcpatch\__init__.py", line 79, in execute
    patcher.patch()
  File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\blenderbim\libs\site\packages\ifcpatch\recipes\ExtractElements.py", line 63, in patch
    self.add_element(element)
  File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\blenderbim\libs\site\packages\ifcpatch\recipes\ExtractElements.py", line 68, in add_element
    new_element = self.append_asset(element)
  File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\blenderbim\libs\site\packages\ifcpatch\recipes\ExtractElements.py", line 85, in append_asset
    return ifcopenshell.api.run("project.append_asset", self.new, library=self.file, element=element)
  File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\blenderbim\libs\site\packages\ifcopenshell\api\__init__.py", line 66, in run
    result = usecase_class(ifc_file, **settings).execute()
  File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\blenderbim\libs\site\packages\ifcopenshell\api\project\append_asset.py", line 98, in execute
    return self.append_product()
  File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\blenderbim\libs\site\packages\ifcopenshell\api\project\append_asset.py", line 169, in append_product
    ifcopenshell.api.run(
  File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\blenderbim\libs\site\packages\ifcopenshell\api\__init__.py", line 66, in run
    result = usecase_class(ifc_file, **settings).execute()
  File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\blenderbim\libs\site\packages\ifcopenshell\api\type\assign_type.py", line 213, in execute
    "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
  File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\blenderbim\libs\site\packages\ifcopenshell\api\__init__.py", line 66, in run
    result = usecase_class(ifc_file, **settings).execute()
  File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\blenderbim\libs\site\packages\ifcopenshell\api\owner\create_owner_history.py", line 109, in execute
    return self.file.create_entity(
  File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\blenderbim\libs\site\packages\ifcopenshell\file.py", line 337, in create_entity
    e[idx] = arg
  File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\blenderbim\libs\site\packages\ifcopenshell\entity_instance.py", line 263, in __setitem__
    self.wrapped_data.setArgumentAsNull(idx)
  File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\blenderbim\libs\site\packages\ifcopenshell\ifcopenshell_wrapper.py", line 4940, in setArgumentAsNull
    return _ifcopenshell_wrapper.entity_instance_setArgumentAsNull(self, i)
RuntimeError: Attribute not set

@Andrej730
Copy link
Contributor

Little update. It actually works, just pasting the Guid's separated by commas. The problem I faced was actually for some elements which give me an error when trying to export. It's something with this ifc file.

This error looks like file has some invalid ifc - it seems like it doesn't have either IfcApplication or IfcPersonAndOrganization to initialize IfcOwnerHistory.

As for the original feature request, it can indeed be done by generating query listing selected guids in Search section and then use it for ExtractElements IfcPatch recipe. I'm not sure if we should add special "extract from selection" button to this recipe UI since then it would make sense copying the entire Search UI there.

@Tudjack
Copy link
Author

Tudjack commented Mar 28, 2024

For the moment I coded my own plugin which does this. It's quite basic, stores the guids from selection as a string delimited by commas and pasted it into the IfcPatch recipe. I needed something then. It worked, but as I said that particular ifc had some issues.
I wonder why does it have to have either IfcApplication or IfcPersonAndOrganizaton set? Why does it need IfcOwnerHistory?

@Andrej730
Copy link
Contributor

I wonder why does it have to have either IfcApplication or IfcPersonAndOrganizaton set? Why does it need IfcOwnerHistory?

I assume your file was in IFC2X3 and in IFC2X3 OwnerHistory on IfcRoot elements is not optional.

See: https://standards.buildingsmart.org/IFC/RELEASE/IFC2x3/TC1/HTML/ifckernel/lexical/ifcroot.htm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants