mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 01:07:57 -06:00
Use AMF object and volume metadata for handling per-object and per-volume settings
This commit is contained in:
parent
4d67f902b6
commit
f82a8475a1
7 changed files with 47 additions and 27 deletions
|
@ -160,14 +160,11 @@ sub selection_changed {
|
|||
|
||||
# attach volume material config to settings panel
|
||||
my $volume = $self->{model_object}->volumes->[ $itemData->{volume_id} ];
|
||||
my $material = $self->{model_object}->model->get_material($volume->material_id // '_');
|
||||
$material //= $volume->assign_unique_material;
|
||||
$config = $volume->config;
|
||||
$self->{staticbox}->SetLabel('Part Settings');
|
||||
|
||||
# get default values
|
||||
@opt_keys = @{Slic3r::Config::PrintRegion->new->get_keys};
|
||||
|
||||
$config = $material->config;
|
||||
} elsif ($itemData->{type} eq 'object') {
|
||||
# select all object volumes in 3D preview
|
||||
if ($self->{canvas}) {
|
||||
|
@ -211,21 +208,12 @@ sub on_btn_load {
|
|||
foreach my $volume (@{$object->volumes}) {
|
||||
my $new_volume = $self->{model_object}->add_volume($volume);
|
||||
$new_volume->set_modifier($is_modifier);
|
||||
if (!defined $new_volume->material_id) {
|
||||
# it looks like this block is never entered because all input volumes seem to have an assigned material
|
||||
# TODO: check we can assume that for any input format
|
||||
my $material_name = basename($input_file);
|
||||
$material_name =~ s/\.(stl|obj)$//i;
|
||||
my $material = $self->{model_object}->model->set_material($material_name);
|
||||
$new_volume->material_id($material_name);
|
||||
}
|
||||
|
||||
# apply the same translation we applied to the object
|
||||
$new_volume->mesh->translate(@{$self->{model_object}->origin_translation}, 0);
|
||||
|
||||
# set a default extruder value, since user can't add it manually
|
||||
my $material = $self->{model_object}->model->get_material($new_volume->material_id);
|
||||
$material->config->set_ifndef('extruder', 1);
|
||||
$new_volume->config->set_ifndef('extruder', 0);
|
||||
|
||||
$self->{parts_changed} = 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue