IfcOpenShell / IfcOpenShell

Open source IFC library and geometry engine
GNU Lesser General Public License v3.0
1.72k stars 692 forks source link

BlenderBIM. Ifc exporting: BREP and loosing material #865

Closed GOBA-esp closed 4 years ago

GOBA-esp commented 4 years ago

Hi!

Is it possible to export an Ifc, defining the elements, as Sweptsolid (extruded) instead of BREP.

I have loosed the material in the exportation, or I am not sure I ha have loosed it during importation. This is what I have done:

This is from the original IFC:

IfcMaterial_1

In the new one, I don’t see the Ifcmaterial:

IfcMaterial_2

Moult commented 4 years ago

It is possible to re-export as a swept solid, but the process is incredibly manual and impractical to do right now for any meaningful project. Blender is actually exceptionally good at breps and meshes, so for Blender meshes are a good thing :) Unfortunately most CAD applications are exceptionally bad a meshes, so people who haven't been trained to work with meshes think they aren't desirable :(

Still an issue though, will consider how to fix it.

It is considered normal for the owning user / application to change, as not a single vendor has properly implemented owner history. This bug exists for all BIM programs. Perhaps the BlenderBIM Add-on should be the first to fix this? :)

I find it surprising that materials are lost. Have you got a test file? Feel free to send to dion@thinkmoult.com if it is sensitive.

GOBA-esp commented 4 years ago

Hi Dion!

I think Blender BIM should be the first, because it's the only one that works with IFC, directly :)

I have sent you an email.

Moult commented 4 years ago

I received your email and I see why the materials are being lost. It is because it has both a material defined as well as a surface style defined. In the rules of IFC, the colour of a surface style override the material colour. Therefore, the BlenderBIM Add-on will ignore all the material data, resulting in a loss of material.

This is not good behaviour, but actually it is the behaviour that most BIM applications do too - they do not distinguish between material and styles... the correct behaviour is to preserve materials and surface styles both, and then let the colour be defined by one or the other. Let's be the first to solve this!

To answer your question about changing surface style on export in your email - yes, you can define both material and surface styles in Blender and export both of them. In the material tab, any material assigned to the object directly as opposed to the object's data, becomes a surface style colour:

image

By the way, many other BIM programs have bugs related to reading surface style colours and material colours. It may be the case that Blender is doing the colour properly, but the other program cannot read it properly.

You may want to experiment with these two options to see if they make a difference in the other BIM program:

image

Moult commented 4 years ago

I think I've fixed the issue where materials aren't retained. Hopefully it works for you.

Replace export_ifc.py with this.

Replace import_ifc.py with this.

GOBA-esp commented 4 years ago

Thanks! Once I’ve checked the results (hopefully during today), I let you know!

Moult commented 4 years ago

I've added a new feature where the geometry type is stored during an import. Note that it doesn't actually do anything intelligent with this data yet - i.e. the geometry is still by default in brep form. However, it's a start. in Blender, Blender understands extrusions, but they are painful to edit, compared to breps where you can bulk grab vertices and move them.

Also ping @theoryshaw as he has been asking for this too for a while ;)

Replace import_ifc.py with this.

Replace prop.py with this.

Replace ui.py with this.

image

Moult commented 4 years ago

Part of the issue of maintaining representation types is that sometimes other BIM programs have a broken implementation of representation contexts. This means that when I expect to find a 3D model body element, I find something else instead. It seems as though CYPECAD, as demonstrated by your file, exhibits this problem. See below, where both Body and Axis are part of the same context, instead of separated into a Body and Axis subcontext. Just an FYI, you might want to report to them as a bug.

#142= IFCSHAPEREPRESENTATION(#7,'Body','SweptSolid',(#147));
#152= IFCSHAPEREPRESENTATION(#7,'Axis','Curve3D',(#154));
#7= IFCGEOMETRICREPRESENTATIONCONTEXT($,'Model',3,1.E-005,#9,$);

Though not directly related to solving your problem, it is indirectly related, so I advise to patch this update too:

The implications of this, is that the object has an empty subcontext, and when I invoke the BlenderBIM Add-on's ability to extract a single representation, it finds the wrong one. As shown in the screenshot below, you see empty fields, and the column is extracted as an Axis, not the Body (extruded) SweptSolid that I want.

Hope it makes sense ... still a work in progress, will leave it for now, will continue later!

image

GOBA-esp commented 4 years ago

Hi Dion,

This is a lot of information, I need time to understand it 😊 But, once I do it I’ll report Cype what you are telling me about the representation.

I just want to show you one thing, that may be important. I have repeated the same process:

This is what I see for beams:

Cambio propiedades_1

For columns:

Cambio propiedades_2

For Slabs:

Cambio propiedades_3

I don’t know if it’s normal that those properties are lost, XDim, YDim, or the "minus", but what I know is that a Slab has nothing to do whith a column… Can you see if there is a problem in Blender. It could also be a problem whith BimVision.

Moult commented 4 years ago

The XDim, YDim, properties are lost simply because the BlenderBIM Add-on does not retain the extruded area solid and exports a BREP. The extrusion contains a rectangular parametric extrusion profile, which is lost when a BREP comes out of Blender. This is consistent behaviour with what Blender is currently capable of. Of course, as you reported this bug, it needs to be fixed still :)

The minus sign is nothing to worry about. There is no such things as a "top elevation" in IFC, so likely that is something that BIMVision is calculating in addition to the IFC data, and a minus sign could be due to a variety of reasons, one of which could be rounding errors.

The column is bizarre! Have you got an IFC of that file which thinks a slab is a column? I tried exporting the same Pano 4 (30 cm) slab and it works fine for me.

Moult commented 4 years ago

Fixed the issue where incorrect types might get assigned (note: your CYPECAD IfcSlabTypes and IfcColumnTypes are actually missing a name - this is not incorrect, but is perhaps undesirable, I'm not sure if this is CYPECAD in general, or specific to your model)

Replace export_ifc.py with this.

Other issues are still pending.

GOBA-esp commented 4 years ago

Hi! Thanks!

It seems the types are correct :)

It’s only missing material for IfcSlabs (it’s ok for IfcColumn and IfcBeams). I'm sorry I hadn't notice berore:

IfcSlab_Comparation

I need to check other model with more types of elements, including footing.

When you say that in the IFC created from CYPECAD, there is missing a name, you mean this?

IfcSlabType

Maybe, my structural program doesn’t let me change anything, and I need so much to learn...

Moult commented 4 years ago

The material is lost because the material is stored using the "4.4.5.3 Material Layer Set Usage" feature in IFC. If you check this feature table this is something that the BlenderBIM Add-on does not yet support.

I will add the feature.

Yes, that is the missing name I am referring to.

Moult commented 4 years ago

There is now an updated import feature that has partial, but not complete support for IfcMaterialLayerSetUsage import. Replace import_ifc.py with this.

What will happen now is that all the layers in a layer set will be imported, but then on export time it will only be compressed into a single material. This doesn't matter for your scenario (I think it's OK) because in your scenario CYPECAD only defines a single layer. Layer sets are meant to be used when there are multiple layers of materials. Hopefully it works a bit better for you now.

I'll continue to build better layer set features, and continue to consider how to better support extrusions, and will keep you updated.

GOBA-esp commented 4 years ago

Thank you very much!

Moult commented 4 years ago

Apologies for the slow progress on this, busy with some other work right now unfortunately :)

GOBA-esp commented 4 years ago

Apologies not needed :)

You have made a lot of improvements!

Moult commented 4 years ago

@GOBA-esp Just a head's up that progress is still being made on this. Prior to this, the BlenderBIM Add-on did not have any support for "native IFC geometries", so to implement this, there is quite a bit of groundwork to do.

You may be interested in reading #885 where I talk about 8 steps that are required to achieve this. In the latest commit, 0237f12 - I have completed 5 out of 8 of the steps I talked about. In particular, extrusions with rectangles (like columns) or arbitrary profiles (like slabs or roofs) are now understood by the importer. As it is still not yet complete, I will not ask you to replace any files yet or to test anything just yet. I have not yet begun work pushing this to the exporter (though the exporter already has some support built in).

GOBA-esp commented 4 years ago

Thank you @Moult!

And also thank you for pointing this:

Just an FYI, you might want to report to them as a bug.

#142= IFCSHAPEREPRESENTATION(#7,'Body','SweptSolid',(#147));
#152= IFCSHAPEREPRESENTATION(#7,'Axis','Curve3D',(#154));
#7= IFCGEOMETRICREPRESENTATIONCONTEXT($,'Model',3,1.E-005,#9,$);

Cype is going to improve the syntax :)

Moult commented 4 years ago

Good to hear that Cype is responsive! Thanks for reporting to them!

Materials now work with native meshes. Also, Blender will now store which portions of the object belong to different native representation items.

image

Moult commented 4 years ago

Still making slow progress - kinda busy with a few other things right now.

GOBA-esp commented 4 years ago

You're great! Thanks!

Moult commented 4 years ago

Haven't forgotten about this! Almost there! I think all the data is imported now, so all I need to do is wire it up to the exporter.

Moult commented 4 years ago

The basic feature is now done (see https://github.com/IfcOpenShell/IfcOpenShell/commit/d3f07c4ac48e85e714073b9c213a90a5797793f4 ). The BlenderBIM Add-on will now round-trip both IfcRectangleProfileDef and IfcArbitraryProfileDef. There have been many changes, so perhaps rather than asking you to replace many files it is easier to just wait until the next BlenderBIM Add-on release which will be this weekend. When it is released, I hope you can help test :)

Ping @theoryshaw - woohoo!

It works on your file, but I am aware that this implementation is not comprehensive. There will be scenarios which include IFC features that I have not yet built support for, for example, I haven't yet allowed for extrusions with voids. There is also more testing to be done with opening elements, having multiple extrusions in a single shape, mixing geometry types in a single object, and more... but the first step is here!

GOBA-esp commented 4 years ago

When it is released, I hope you can help test :)

Of course! :)

Thanks!

Moult commented 4 years ago

@GOBA-esp testing time :) The new release is out on the BlenderBIM.org website.

Prior to importing, ensure this option is enabled. Then, extrusions should be retained. Try importing and exporting and see what happens. It is quite likely you may still come across shortcomings, as some are already known to me, but if you report them as you come across them that will help me prioritise, and if we're lucky and none are applicable to your scenario, then it's good that it helps you :)

image

GOBA-esp commented 4 years ago

Thanks @Moult! Tomorrow, I'll test it! :)

GOBA-esp commented 4 years ago

Hi @Moult !

I am not sure If there’s something I’ve done wrong.

I’ve installed the add-on:

BlenderBIM_Version

Once I’ve done that, I couldn’t see the “Import Native Representation” option:

BlenderBIM_Menu

I’ve restarted Blender, and now I don’t see any import option:

BlenderBIM_Menu_2

Am I looking in the wrong place?

Moult commented 4 years ago

@GOBA-esp it might be good to start clean - delete everything in your Blender add-ons dir (C:/Users/helen/AppData/Roaming/Blender Foundation/2.82/scripts/addons/) and then install the add-on.

GOBA-esp commented 4 years ago

Thanks @Moult! The menu is correct now :)

I'll let you know the results of what I test!

GOBA-esp commented 4 years ago

Hi @Moult!

I don’t know what’s happening. I’ve located some walls missing after importation.

This is the 3D after importing without “Import native representation”:

Blender_1

And this is using “Import native representation”:

Blender_2

Moult commented 4 years ago

Fantastic! You've discovered a bug in the new native element feature - which file is this, so I can fix it?

GOBA-esp commented 4 years ago

In the file "ESTRUCTURA PORTALES 1 Y 2". Let me know if it doesn't happen when you check it, because I am not sure if it's exactly the same file.

Moult commented 4 years ago

Aha, I forgot about shapes with booleans. Good spot! Booleaned shapes are not supported right now, so I've written some code to fall back to a mesh for those particular instances:

Replace import_ifc.py with this.

GOBA-esp commented 4 years ago

Hi! Those walls are imported now. I don’t really know what shape with booleans are, but those walls are exported as BREP instead as Sweptsolid, but it seems to me that this is what you expect, right?

I haven’t seen anything else.

Thanks!

Moult commented 4 years ago

@GOBA-esp a shape with boolean means that it isn't a pure extruded swept solid - it is first a swept solid, and then portions are "voided / cut out". So yes, exporting as BREP is what I would expect :)

But for other things, is it working well for you?

GOBA-esp commented 4 years ago

Yes, great, than you!!! :)

Moult commented 4 years ago

@GOBA-esp great! Closing this bug. Feel free to open a new bug anytime if there is a new issue!