mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	Keep model objects aligned to Z = 0 in plater
This commit is contained in:
		
							parent
							
								
									050f9ff61a
								
							
						
					
					
						commit
						360dee862b
					
				
					 10 changed files with 43 additions and 32 deletions
				
			
		|  | @ -469,7 +469,7 @@ sub load_model_objects { | |||
|             $need_arrange = 1; | ||||
|          | ||||
|             # add a default instance and center object around origin | ||||
|             $o->center_around_origin; | ||||
|             $o->center_around_origin;  # also aligns object to Z = 0 | ||||
|             $o->add_instance(offset => $bed_centerf); | ||||
|         } | ||||
|      | ||||
|  | @ -1074,15 +1074,7 @@ sub export_stl { | |||
|     return if !@{$self->{objects}}; | ||||
|          | ||||
|     my $output_file = $self->_get_export_file('STL') or return; | ||||
|      | ||||
|     # In order to allow for consistent positioning in the parts editor, | ||||
|     # we never alter the original Z position. Meshes are aligned to zero  | ||||
|     # at slice time. So we do the same before exporting. | ||||
|     my $model = $self->{model}->clone; | ||||
|     foreach my $model_object (@{$model->objects}) { | ||||
|         $model_object->translate(0,0,-$model_object->bounding_box->z_min); | ||||
|     } | ||||
|     Slic3r::Format::STL->write_file($output_file, $model, binary => 1); | ||||
|     Slic3r::Format::STL->write_file($output_file, $self->{model}, binary => 1); | ||||
|     $self->statusbar->SetStatusText("STL file exported to $output_file"); | ||||
|      | ||||
|     # this method gets executed in a separate thread by wxWidgets since it's a button handler | ||||
|  | @ -1282,10 +1274,12 @@ sub object_settings_dialog { | |||
| 	$self->pause_background_process; | ||||
| 	$dlg->ShowModal; | ||||
| 	 | ||||
| 	# update thumbnail since parts may have changed | ||||
| 	if ($dlg->PartsChanged) { | ||||
|     	$self->make_thumbnail($obj_idx); | ||||
| 	} | ||||
|     # update thumbnail since parts may have changed | ||||
|     if ($dlg->PartsChanged) { | ||||
| 	    # recenter and re-align to Z = 0 | ||||
| 	    $model_object->center_around_origin; | ||||
|         $self->make_thumbnail($obj_idx); | ||||
|     } | ||||
| 	 | ||||
| 	# update print | ||||
| 	if ($dlg->PartsChanged || $dlg->PartSettingsChanged) { | ||||
|  |  | |||
|  | @ -214,7 +214,7 @@ sub on_btn_load { | |||
|                 $new_volume->set_name(basename($input_file)); | ||||
|                  | ||||
|                 # apply the same translation we applied to the object | ||||
|                 $new_volume->mesh->translate(@{$self->{model_object}->origin_translation}, 0); | ||||
|                 $new_volume->mesh->translate(@{$self->{model_object}->origin_translation}); | ||||
|                  | ||||
|                 # set a default extruder value, since user can't add it manually | ||||
|                 $new_volume->config->set_ifndef('extruder', 0); | ||||
|  | @ -226,7 +226,9 @@ sub on_btn_load { | |||
|      | ||||
|     $self->reload_tree; | ||||
|     if ($self->{canvas}) { | ||||
|         $self->{canvas}->reset_objects; | ||||
|         $self->{canvas}->load_object($self->{model_object}); | ||||
|         $self->{canvas}->set_bounding_box($self->{model_object}->bounding_box); | ||||
|         $self->{canvas}->Render; | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -332,7 +332,7 @@ sub _slice_region { | |||
|     # consider the first one | ||||
|     $self->model_object->instances->[0]->transform_mesh($mesh, 1); | ||||
| 
 | ||||
|     # align mesh to Z = 0 and apply XY shift | ||||
|     # align mesh to Z = 0 (it should be already aligned actually) and apply XY shift | ||||
|     $mesh->translate((map unscale(-$_), @{$self->_copies_shift}), -$self->model_object->bounding_box->z_min); | ||||
|      | ||||
|     # perform actual slicing | ||||
|  |  | |||
|  | @ -68,6 +68,7 @@ sub set_model { | |||
|         # if all input objects have defined position(s) apply duplication to the whole model | ||||
|         $model->duplicate($self->duplicate, $self->_print->config->min_object_distance); | ||||
|     } | ||||
|     $_->translate(0,0,-$_->bounding_box->z_min) for @{$model->objects}; | ||||
|     $model->center_instances_around_point($self->print_center); | ||||
|      | ||||
|     foreach my $model_object (@{$model->objects}) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alessandro Ranellucci
						Alessandro Ranellucci