Explode components in the IFC up to a certain level

Be aware that in SketchUp, IFC (and any other classification) assignments are made at the component definition level.

:warning: This means that exploding any component instance(s) will lose all classification attributes, and any associated name property (either instance name or definition name.) This is because they just become loose geometry.


See this topic thread:


BUT, … IFC types are set in an attribute dictionary attached to the component’s definition.

So, if cinst was a reference to an IFC component instance, then you’d check the IFC type:

def ifc_type_is?( comp_inst, ifc_tag )
  dict = comp_inst.definition.attribute_dictionary("AppliedSchemaTypes")
  return false if dict.nil? # nil if it doesn't exist
  return dict["IFC 2x3"] == ifc_tag ? true : false
end

then call that method:

cinst.explode if ifc_type_is?(cinst,"IfcBuildingStorey")

Or like:

model.definitions.each {|cdef|
  dict = cdef.attribute_dictionary("AppliedSchemaTypes")
  if dict != nil && dict["IFC 2x3"] == "IfcBuildingStorey"
    cdef.instances.each {|i| i.explode }
  end
}

BTW, I do not see “IfcStorey” as a tag in the “IFC 2x3” schema.
EDIT: Okay, changed examples above to “IfcBuildingStorey”.