Skip to content

Commit

Permalink
Merge pull request #72 from BIM-Tools/develop
Browse files Browse the repository at this point in the history
Release version 5.3.1
  • Loading branch information
janbrouwer authored Nov 10, 2024
2 parents 5ccc5ce + 0e6753b commit aadbf70
Show file tree
Hide file tree
Showing 15 changed files with 263 additions and 229 deletions.
2 changes: 1 addition & 1 deletion src/bt_ifcmanager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module BimTools

module IfcManager
# Version and release information.
VERSION = '5.3.0'
VERSION = '5.3.1'

# load plugin only if SketchUp version is PRO
# raised minimum version to 2017 due to switch to htmldialog
Expand Down
58 changes: 0 additions & 58 deletions src/bt_ifcmanager/lib/lib_ifc/IfcPile_su.rb
Original file line number Diff line number Diff line change
@@ -1,116 +1,58 @@
# frozen_string_literal: true



# IfcPile_su.rb

#

# Copyright 2024 Jan Brouwer <[email protected]>

#

# This program is free software; you can redistribute it and/or modify

# it under the terms of the GNU General Public License as published by

# the Free Software Foundation; either version 2 of the License, or

# (at your option) any later version.

#

# This program is distributed in the hope that it will be useful,

# but WITHOUT ANY WARRANTY; without even the implied warranty of

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

# GNU General Public License for more details.

#

# You should have received a copy of the GNU General Public License

# along with this program; if not, write to the Free Software

# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,

# MA 02110-1301, USA.

#

#



module BimTools

module IfcPile_su

VALID_CONSTRUCTION_TYPES = %i[

CAST_IN_PLACE

COMPOSITE

PRECAST_CONCRETE

PREFAB_STEEL

USERDEFINED

NOTDEFINED

].freeze



attr_reader :constructiontype



def initialize(ifc_model, sketchup, _total_transformation)

@ifc_version = ifc_model.ifc_version

super

end



# ConstructionType attribute deprecated in IFC4

def constructiontype=(value)

return unless @ifc_version == 'IFC 2x3'



# TODO: hacky fix, should be part of PropertyReader

enum_value = if value.is_a?(String)

value.upcase.to_sym

elsif value.respond_to?(:value)

value.value.upcase.to_sym

else

value.to_sym

end



@constructiontype = VALID_CONSTRUCTION_TYPES.include?(enum_value) ? enum_value : nil

end

end

end

16 changes: 1 addition & 15 deletions src/bt_ifcmanager/lib/lib_ifc/IfcProduct_su.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,7 @@ def initialize(ifc_model, sketchup, total_transformation)
name ||= definition.name
@name = IfcManager::Types::IfcLabel.new(ifc_model, name)

# Set IfcProductType
if ifc_model.options[:types]
if @ifc_model.product_types.key?(definition)
@type_product = @ifc_model.product_types[definition]
@type_product.add_typed_object(self)
else
type_name = self.class.name.split('::').last + 'Type'
if @ifc_module.const_defined?(type_name)
type_product = @ifc_module.const_get(type_name)
@type_product = type_product.new(ifc_model, definition, self.class)
@ifc_model.product_types[definition] = @type_product
@type_product.add_typed_object(self)
end
end
end
@type_product = @ifc_model.product_types[definition] if @ifc_model.product_types.key?(definition)
@type_properties = ifc_model.options[:type_properties] && @type_product

add_common_attributes(ifc_model, @su_object)
Expand Down
67 changes: 67 additions & 0 deletions src/bt_ifcmanager/lib/lib_ifc/IfcRoof_su.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# frozen_string_literal: true

# IfcRoof_su.rb
#
# Copyright 2024 Jan Brouwer <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
#

module BimTools
module IfcRoof_su
def initialize(ifc_model, sketchup, _total_transformation)
@ifc_version = ifc_model.ifc_version
super
end

# ShapeType attribute renamed to PredefinedType in IFC4
def predefinedtype=(value)
# TODO: hacky fix, should be part of PropertyReader
enum_value = if value.is_a?(String)
value.upcase.to_sym
elsif value.respond_to?(:value)
value.value.upcase.to_sym
else
value.to_sym
end

if @ifc_version == 'IFC 2x3'
@shapetype = enum_value
else
@predefinedtype = enum_value
end
end

# ShapeType attribute renamed to PredefinedType in IFC4
def shapetype=(value)
# TODO: hacky fix, should be part of PropertyReader
enum_value = if value.is_a?(String)
value.upcase.to_sym
elsif value.respond_to?(:value)
value.value.upcase.to_sym
else
value.to_sym
end

if @ifc_version == 'IFC 2x3'
@shapetype = enum_value
else
@predefinedtype = enum_value
end
end
end
end
86 changes: 20 additions & 66 deletions src/bt_ifcmanager/lib/lib_ifc/IfcSite_su.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,46 +21,22 @@
#
#

require_relative 'ifc_types'

module BimTools
module IfcSite_su
@reflatitude = nil
@reflongitude = nil

# add project location, if set in sketchup model
# (!) north angle still missing?
def set_latlong
return unless Sketchup.active_model.georeferenced?

local_point = Geom::Point3d.new([0, 0, 0])
@latlong = Sketchup.active_model.point_to_latlong(local_point)
end

def reflatitude=(values)
if valid_latlong_list?(values)
@reflatitude = values
else
puts 'Invalid reflatitude values'
end
end

def reflongitude=(values)
if valid_latlong_list?(values)
@reflongitude = values
else
puts 'Invalid reflongitude values'
end
def initialize(ifc_model, su_instance, su_total_transformation)
@ifc_model = ifc_model
@su_model = ifc_model.su_model
super
end

def reflatitude
lat_long_ifc(@latlong[1]) if @latlong
def reflatitude=(_values)
puts "Function 'reflatitude=' for 'IfcSite' not implemented"
end

def reflongitude
lat_long_ifc(@latlong[0]) if @latlong
end

def elevation
IfcManager::Types::IfcLengthMeasure.new(@ifc_model, @latlong[2]) if @latlong
def reflongitude=(_values)
puts "Function 'reflongitude=' for 'IfcSite' not implemented"
end

private
Expand All @@ -69,39 +45,17 @@ def valid_latlong_list?(values)
values.is_a?(Array) && values.all? { |v| v.is_a?(IfcCompoundPlaneAngleMeasure) }
end

# convert sketchup latlong coordinate (decimal) to IFC notation (degrees)
def lat_long_ifc(coordinate)
return unless Sketchup.active_model.georeferenced?

d = coordinate.abs
neg_pos = (coordinate / d).to_int

# degrees
i = d.to_int
deg = i * neg_pos

# minutes
d -= i
d *= 60
i = d.to_int

min = i * neg_pos

# seconds
d -= i
d *= 60
i = d.to_int
sec = i * neg_pos

# millionth-seconds
d -= i
d *= 1_000_000
i = d.to_int
msec = i * neg_pos
# Converts a decimal degree value to a compound plane angle measure.
#
# @param decimal_degrees [Float] The decimal degree value to be converted.
# @return [Types::IfcCompoundPlaneAngleMeasure] The converted compound plane angle measure.
def convert_to_compound_plane_angle_measure(decimal_degrees)
degrees = decimal_degrees.to_i
minutes = ((decimal_degrees - degrees) * 60).to_i
seconds = (((decimal_degrees - degrees) * 60 - minutes) * 60).to_i
millionths = ((((decimal_degrees - degrees) * 60 - minutes) * 60 - seconds) * 1_000_000).to_i

# (!) values should be Ifc INTEGER objects instead of Strings(!)
# (!) returned object should be of type IFC LIST instead of IFC SET
IfcManager::Types::List.new([deg.to_s, min.to_s, sec.to_s, msec.to_s])
IfcManager::Types::IfcCompoundPlaneAngleMeasure.new(@ifc_model, [degrees, minutes, seconds, millionths])
end
end
end
2 changes: 1 addition & 1 deletion src/bt_ifcmanager/lib/lib_ifc/IfcSpace_su.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module IfcSpace_su

attr_reader :interiororexteriorspace

def initialize(ifc_model, sketchup, total_transformation)
def initialize(ifc_model, su_instance, su_total_transformation)
@ifc_version = ifc_model.ifc_version
super
end
Expand Down
Loading

0 comments on commit aadbf70

Please sign in to comment.