Skip to content

Commit

Permalink
Catch differences in IFC schema versions
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrouwerdigibase committed Oct 20, 2024
1 parent 16f4434 commit d419efb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
5 changes: 3 additions & 2 deletions src/bt_ifcmanager/lib/lib_ifc/IfcProduct_su.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,11 @@ def initialize(ifc_model, sketchup, total_transformation)
(is_a? @ifc_module::IfcElement) &&
!(is_a? @ifc_module::IfcFeatureElementSubtraction) &&
!(is_a? @ifc_module::IfcVirtualElement) &&
!(is_a? @ifc_module::IfcSpatialElement) &&
!(is_a? @ifc_module::IfcSpatialStructureElement) &&
!(is_a? @ifc_module::IfcRoof) &&
!(is_a? @ifc_module::IfcElementAssembly) &&
!(is_a? @ifc_module::IfcCurtainWall)
!(is_a? @ifc_module::IfcCurtainWall) &&
!(defined?(@ifc_module::IfcSpatialZone) && is_a?(@ifc_module::IfcSpatialZone))

# collect dynamic component attributes if export option is set
BimTools::DynamicAttributes.get_dynamic_attributes(ifc_model, self) if ifc_model.options[:dynamic_attributes]
Expand Down
9 changes: 5 additions & 4 deletions src/bt_ifcmanager/lib/lib_ifc/PropertyReader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,17 @@ def initialize(ifc_model, ifc_entity, entity_dict, instance_class = nil)
@attributes
end


@propertyset_names = names - @all_attributes - ifc_entity_inverse_attributes
end

def handle_predefined_type(value)
if value == :userdefined
if value == 'userdefined'
object_type_or_element_type = @ifc_dict['ObjectType'] || @ifc_dict['ElementType']
return :notdefined if object_type_or_element_type
end
value
return value if value.is_a?(Symbol)

value.is_a?(String) ? value.to_sym : value.value.to_sym # TODO: hacky fix
end

# Set the IFC entity attributes using all combined attribute possibilitites from IfcProduct and IfcTypeProduct
Expand Down Expand Up @@ -184,7 +185,7 @@ def set_attribute(attr_dict)
return false if value.nil? || (value.is_a?(String) && value.empty?)

ifc_value = determine_ifc_value(property, value)
ifc_value = handle_predefined_type(ifc_value) if ifc_value.is_a?(Symbol) && name == 'PredefinedType'
ifc_value = handle_predefined_type(ifc_value) if name == 'PredefinedType'

@ifc_entity.send("#{name.downcase}=", ifc_value) if ifc_value
end
Expand Down
12 changes: 6 additions & 6 deletions src/bt_ifcmanager/lib/lib_ifc/entity_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -526,14 +526,14 @@ def add_representation_to_parent(placement_parent, definition_manager, su_materi
# @return [void]
def add_placement_parent_relationships(ifc_entity, placement_parent)
return unless placement_parent

return if ifc_entity == placement_parent

unless ifc_entity.is_a?(@ifc_module::IfcSurfaceFeature) && placement_parent.is_a?(@ifc_module::IfcProduct)
return
end # TODO: should be IfcElement

placement_parent.add_surface_feature(ifc_entity)
if defined?(@ifc_module::IfcSurfaceFeature) &&
defined?(@ifc_module::IfcRelAdheresToElement) &&
ifc_entity.is_a?(@ifc_module::IfcSurfaceFeature) &&
placement_parent.is_a?(@ifc_module::IfcProduct) # TODO: should be IfcElement
placement_parent.add_surface_feature(ifc_entity)
end
end
end
end
Expand Down
10 changes: 7 additions & 3 deletions src/bt_ifcmanager/lib/lib_ifc/spatial_structure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ def add(ifc_entity)
add_default_spatialelement(@ifc_module::IfcBuildingStorey)
end
@spatial_structure << ifc_entity
when ->(entity) { entity.is_a?(@ifc_module::IfcProduct) && !entity.is_a?(@ifc_module::IfcSpatialElement) }
when lambda { |entity|
entity.is_a?(@ifc_module::IfcProduct) && !entity.is_a?(@ifc_module::IfcSpatialStructureElement)
}
if (spatial_structure_types & [@ifc_module::IfcSpace, @ifc_module::IfcBuildingStorey,
@ifc_module::IfcSite]).empty?
add_default_spatialelement(@ifc_module::IfcBuildingStorey)
Expand Down Expand Up @@ -220,9 +222,11 @@ def set_parent(ifc_entity)
@spatial_structure[-1]
end
ifc_entity.parent = parent

# IfcSurfaceFeature is not part of the normal spatial structure
return if defined?(@ifc_module::IfcSurfaceFeature) && ifc_entity.is_a?(@ifc_module::IfcSurfaceFeature)

case ifc_entity
when @ifc_module::IfcSurfaceFeature
# skip
when @ifc_module::IfcSpatialStructureElement
ifc_entity.parent.add_related_object(ifc_entity)
else
Expand Down

0 comments on commit d419efb

Please sign in to comment.