Skip to content

Commit b9f453e

Browse files
Version 0.2.0 - edits meeting 03-03-2020
1 parent 93e2e68 commit b9f453e

File tree

3 files changed

+59
-7
lines changed

3 files changed

+59
-7
lines changed

src/bt_ifcjson.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module BimTools
2828
PLUGIN_ROOT_PATH = File.dirname(__FILE__) unless defined? PLUGIN_ROOT_PATH
2929

3030
module IfcJson
31-
VERSION = '0.1.0'.freeze
31+
VERSION = '0.2.0'.freeze
3232

3333
# load plugin only if SketchUp version is PRO
3434
if Sketchup.is_pro? && Sketchup.version_number>1600000000

src/bt_ifcjson/exporter.rb

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,40 @@
2020

2121
module BimTools
2222
module IfcJson
23-
require File.join(PLUGIN_PATH, 'obj.rb')
24-
require File.join(PLUGIN_PATH, 'IfcGloballyUniqueId.rb')
23+
require File.join(PLUGIN_PATH, "obj.rb")
24+
require File.join(PLUGIN_PATH, "IfcGloballyUniqueId.rb")
2525
class IfcJsonExporter
2626
attr_accessor :root_objects
2727
def initialize( entities )
28-
@root_objects = Array.new
28+
@geometry = Array.new
29+
@root_objects = {
30+
"header" => {
31+
"file_description" => {
32+
"description" => "ViewDefinition [CoordinationView]",
33+
"implementation_level" => "2;1"
34+
},
35+
"file_name" => {
36+
"name" => "7m900_tue_hello_wall_with_door.json",
37+
"time_stamp" => "2020-02-22T11:10:04",
38+
"author" => "",
39+
"organization" => "",
40+
"preprocessor_version" => "IFC-manager for SketchUp (ifcjson-3.1.0)",
41+
"originating_system" => "SketchUp Pro 2020 (20.0.373)",
42+
"authorization" => ""
43+
},
44+
"file_schema" => "IFC2X3"
45+
},
46+
"data" => []
47+
}
2948
export_path = get_export_path()
3049

3150
# only start export if path is valid
3251
unless export_path.nil?
33-
@root_objects.concat( collect_objects( entities, Geom::Transformation.new() )[0] )
52+
@root_objects["data"].concat( collect_objects( entities, Geom::Transformation.new() )[0] )
3453
end
3554

55+
@root_objects["data"].concat( @geometry )
56+
3657
to_file( export_path )
3758
end # def initialize
3859

@@ -53,6 +74,11 @@ def collect_objects(entities, parent_transformation, parent_guid=nil)
5374
end
5475
object_hash["GlobalId"] = guid.to_json()
5576

77+
# add volume if object is manifold
78+
if entity.volume > 0
79+
object_hash["Volume"] = entity.volume
80+
end
81+
5682
isDecomposedBy, child_faces = collect_objects(entity.definition.entities, transformation, guid.to_s)
5783

5884
unless isDecomposedBy.empty?
@@ -62,7 +88,33 @@ def collect_objects(entities, parent_transformation, parent_guid=nil)
6288
# only add representation if there are any faces
6389
if child_faces.length > 0
6490
obj = OBJ.new(child_faces, parent_transformation)
65-
object_hash["Representation"] = obj.to_s
91+
representation_guid = BimTools::IfcManager::IfcGloballyUniqueId.new().to_json
92+
object_hash["Representations"] = [
93+
{
94+
"Class": "ShapeRepresentation",
95+
"ref": representation_guid
96+
}
97+
]
98+
# {
99+
# "Class": "ProductDefinitionShape",
100+
# "Representations": [
101+
# {
102+
# "Class": "ShapeRepresentation",
103+
# "RepresentationIdentifier": "Body",
104+
# "RepresentationType": "OBJ",
105+
# "Items": [obj.to_s]
106+
# }
107+
# ]
108+
# }
109+
110+
# add geometry as seperate objects at the end of the file
111+
@geometry << {
112+
"Class" => "ShapeRepresentation",
113+
"GlobalId" => representation_guid,
114+
"RepresentationIdentifier" => "Body",
115+
"RepresentationType" => "OBJ",
116+
"Items" => [obj.to_s]
117+
}
66118
end
67119
child_objects << object_hash
68120
elsif entity.is_a?(Sketchup::Face)

src/bt_ifcjson/obj.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def initialize( faces, transformation )
5454
end # def initialize
5555

5656
def to_s()
57-
return @vertices.join("\n") << "\n" << @polygons.join("\n")
57+
return @vertices.join("\\n") << "\\n" << @polygons.join("\\n")
5858
end
5959
end # OBJ
6060
end # module IfcJson

0 commit comments

Comments
 (0)