Skip to content

Commit

Permalink
Place objects to correct layers
Browse files Browse the repository at this point in the history
  • Loading branch information
oguzhankoral committed Aug 19, 2024
1 parent ef99e69 commit fa64451
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion speckle_connector_3/src/sketchup_model/query/layer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def entity_layer_from_path(string_layer_path, separation = '::')
# @param sketchup_model [Sketchup::Model] active model
# @param layer_name [String] layer name to get the next one if exists.
def get_increment_layer_name(sketchup_model, layer_name)
return layer_name if sketchup_model.layers.any? { |l| l.display_name != layer_name }
return layer_name unless sketchup_model.layers.any? { |l| l.display_name == layer_name }

counter = 1
new_layer_name = layer_name
Expand Down
7 changes: 4 additions & 3 deletions speckle_connector_3/src/speckle_objects/geometry/line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,11 @@ def self.to_native(state, line, layer, entities, &_convert_to_native)
UiData::Report::ConversionStatus::WARNING)
end

line_layer_name = SketchupModel::Query::Layer.entity_layer_from_path(line['layer'])
line_layer = state.sketchup_state.sketchup_model.layers.to_a.find { |l| l.display_name == line_layer_name }
# line_layer_name = SketchupModel::Query::Layer.entity_layer_from_path(line['layer'])
# line_layer = state.sketchup_state.sketchup_model.layers.to_a.find { |l| l.display_name == line_layer_name }
edges.each do |edge|
edge.layer = line_layer.nil? ? layer : line_layer
edge.layer = layer
# edge.layer = line_layer.nil? ? layer : line_layer
unless line['sketchup_attributes'].nil?
SketchupModel::Dictionary::BaseDictionaryHandler
.attribute_dictionaries_to_native(edge, line['sketchup_attributes']['dictionaries'])
Expand Down
7 changes: 4 additions & 3 deletions speckle_connector_3/src/speckle_objects/geometry/mesh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,15 @@ def self.to_native(state, mesh, layer, entities, &convert_to_native)
# Add faces from mesh with material and smooth setting
entities.add_faces_from_mesh(native_mesh, smooth_flags, material, material)
added_faces = entities.grep(Sketchup::Face).last(native_mesh.polygons.length)
mesh_layer_name = SketchupModel::Query::Layer.entity_layer_from_path(mesh['layer'])
mesh_layer = state.sketchup_state.sketchup_model.layers.to_a.find { |l| l.display_name == mesh_layer_name }
#mesh_layer_name = SketchupModel::Query::Layer.entity_layer_from_path(mesh['layer'])
#mesh_layer = state.sketchup_state.sketchup_model.layers.to_a.find { |l| l.display_name == mesh_layer_name }
# Merge only added faces in this scope
# if model_preferences[:merge_coplanar_faces]
# added_faces = Converters::CleanUp.merge_coplanar_faces(added_faces)
# end
added_faces.each do |face|
face.layer = mesh_layer unless mesh_layer.nil?
face.layer = layer
# face.layer = mesh_layer unless mesh_layer.nil?
# Smooth edges if they already soft
# FIXME: Below line should be reconsidered. It might be a good to know here mesh comes from NURBS or not.
face.edges.each { |edge| edge.smooth = true if edge.soft? } if has_any_non_planar_quad_mesh
Expand Down

0 comments on commit fa64451

Please sign in to comment.