BIM-Tools / SketchUp-IFC-Manager

IFC data manager and exporter for SketchUp.
GNU General Public License v3.0
59 stars 20 forks source link

Units are lost when exporting IFC #27

Open rafhik opened 2 years ago

rafhik commented 2 years ago

Hi, Great job with this plugin. I have a problem when I create custom Psets. I have a PsetQuantityTakeOff dictionary but the values have no units when I import them in a IFC viewer. When I export to IFC all of them are converted to IFC Label. Only if I change IfcQuantityLength by IfcLengthMeasure the export IFC has units (mm) although my model is in meters. What have I do to have units in volumes and areas? This is my code (where a, b, x y , z are calculated values):

    ifcDict = instance.definition.attribute_dictionary("IFC 2x3")
    ifcQuantities = ifcDict.attribute_dictionary("PsetQuantityTakeOff", true)
    ifcQuantitiesNetVolume = ifcQuantities.attribute_dictionary("NetVolume", true)

    ifcQuantitiesNetVolume.set_attribute "IfcQuantityVolume", "value", a.to_s
    ifcQuantitiesNetVolume.set_attribute "IfcQuantityVolume", "is_hidden", false
    ifcQuantitiesNetVolume.set_attribute "IfcQuantityVolume", "attribute_type", Float

    ifcQuantitiesGrossVolume = ifcQuantities.attribute_dictionary("GrossVolume", true)

    ifcQuantitiesGrossVolume.set_attribute "IfcQuantityVolume", "value", v.to_s
    ifcQuantitiesGrossVolume.set_attribute "IfcQuantityVolume", "is_hidden", false
    ifcQuantitiesGrossVolume.set_attribute "IfcQuantityVolume", "attribute_type", Float

    ifcQuantitiesGrossFootprintArea = ifcQuantities.attribute_dictionary("GrossFootprintArea", true)

    ifcQuantitiesGrossFootprintArea.set_attribute "IfcQuantityArea", "value", s.to_s
    ifcQuantitiesGrossFootprintArea.set_attribute "IfcQuantityArea", "is_hidden", false
    ifcQuantitiesGrossFootprintArea.set_attribute "IfcQuantityArea", "attribute_type", Float

    ifcQuantitiesNominalLength = ifcQuantities.attribute_dictionary("NominalLength", true)

    ifcQuantitiesNominalLength.set_attribute "IfcQuantityLength", "value", x.to_s
    ifcQuantitiesNominalLength.set_attribute "IfcQuantityLength", "is_hidden", false
    ifcQuantitiesNominalLength.set_attribute "IfcQuantityLength", "attribute_type", Float

    ifcQuantitiesNominalWidth = ifcQuantities.attribute_dictionary("NominalWidth", true)

    ifcQuantitiesNominalWidth.set_attribute "IfcQuantityLength", "value", y.to_s
    ifcQuantitiesNominalWidth.set_attribute "IfcQuantityLength", "is_hidden", false
    ifcQuantitiesNominalWidth.set_attribute "IfcQuantityLength", "attribute_type", Float

    ifcQuantitiesNominalHeight = ifcQuantities.attribute_dictionary("NominalHeight", true)

    ifcQuantitiesNominalHeight.set_attribute "IfcQuantityLength", "value", z.to_s
    ifcQuantitiesNominalHeight.set_attribute "IfcQuantityLength", "is_hidden", false
    ifcQuantitiesNominalHeight.set_attribute "IfcQuantityLength", "attribute_type", Float  

    ifcQuantities.set_attribute "Units", "value", "volume (m3) - area (m2) - length (m)"
    ifcQuantities.set_attribute "Units", "is_hidden", false
    ifcQuantities.set_attribute "Units", "attribute_type", String

Captura de pantalla 2021-11-23 a las 9 30 14

Thanks in advance and sorry by my poor English

janbrouwer commented 2 years ago

Hi @rafhik,

Cool that you are diving in this deep into adding IFC properties! On export I have to guess the best IFC type based on property name and ruby type (ia float, string) so all values that are not understood are mapped to the fallback type of IfcLabel, I could try to improve the "guessing" part, or maybe add additional "IFC manager specific" properties where one could write the IFC type, I have to think on that.

And for the meters vs millimeters, the IFC model units are hardcoded to mm at this time, would be nice to make that dependent on the curent Sketchup unit settings, but that would take some work...

janbrouwer commented 2 years ago

Added IFC export suport for all Sketchup units https://github.com/BIM-Tools/SketchUp-IFC-Manager/commit/6422dd136e4f2ee15573ec0b8971851a636d899b

Didn't look at Quantities yet but this is a big step.