From 1df4ec3ad1f6c899feb688857532c6f0713b759e Mon Sep 17 00:00:00 2001 From: Youness Alaoui Date: Mon, 10 Aug 2015 15:09:19 -0400 Subject: [PATCH] Change material ini file into material.ini and add a profile_file key to [info] --- Cura/util/resources.py | 20 +++++++++++++++++--- resources/quickprint/README | 19 ++++++++++--------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/Cura/util/resources.py b/Cura/util/resources.py index fd610f34..c0ce5f36 100644 --- a/Cura/util/resources.py +++ b/Cura/util/resources.py @@ -123,12 +123,14 @@ class ProfileIni(object): self.ini = ini_file self.path = os.path.split(self.ini)[0] self.base_name = os.path.splitext(os.path.basename(self.ini))[0] - if self.base_name == 'profile': + if self.base_name == 'profile' or self.base_name == 'material': self.base_name = os.path.basename(self.path) # Name to show in the UI self.name = self._getProfileInfo(ini_file, 'name') if self.name is None: self.name = self.base_name + # Finds the full path to the real profile_file + self.profile_file = self._findProfileFile() # default = The default profile to select self.default = self.str2bool(self._getProfileInfo(self.ini, 'default')) # disabled = do not make available in the UI @@ -143,6 +145,18 @@ class ProfileIni(object): except: self.order = 999 + def _findProfileFile(self): + profile_file = self._getProfileInfo(self.ini, 'profile_file') + if profile_file is None: + return self.ini + else: + if os.path.exists(profile_file): + return profile_file + elif os.path.exists(os.path.join(self.path, profile_file)): + return os.path.join(self.path, profile_file) + else: + return self.ini + def _getProfileInfo(self, ini_file, key): cp = configparser.ConfigParser() cp.read(ini_file) @@ -161,7 +175,7 @@ class ProfileIni(object): def getProfileDict(self): profile_dict = {} cp = configparser.ConfigParser() - cp.read(self.ini) + cp.read(self.profile_file) for setting in profile.settingsList: section = 'profile' if setting.isProfile() else 'alterations' if setting.isProfile() or setting.isAlteration(): @@ -239,7 +253,7 @@ def getSimpleModeMaterials(): if not option._isInList(global_options): global_options.append(option) - material_files = sorted(glob.glob(os.path.join(path, '*/profile.ini'))) + material_files = sorted(glob.glob(os.path.join(path, '*/material.ini'))) if len(material_files) > 0: for material_file in material_files: material = PrintMaterial(material_file) diff --git a/resources/quickprint/README b/resources/quickprint/README index 4cdb8525..51eaf400 100644 --- a/resources/quickprint/README +++ b/resources/quickprint/README @@ -1,33 +1,34 @@ Global print profiles are defined here. The format is : option_*.ini -Material/profile.ini +Material/material.ini Material/option_*.ini -Material/Quality/profile.ini +Material/Profile/profile.ini -All options must have 'option_' as prefix in their filename, and any subdirectory with a profile.ini file in it will be considered a material. In that material directory, any option files will be specific to that material and any subdirectory with a profile.ini file will be considered material quality (high quality, low quality, high strength, etc..). +All options must have 'option_' as prefix in their filename, and any subdirectory with a material.ini file in it will be considered a material. In that material directory, any option files will be specific to that material and any subdirectory with a profile.ini file will be considered a material profile (high quality, low quality, high strength, High clarity, etc..). These global options and profiles will apply to all machines. For a machine specific quickprint settings, you need a directory with the machine_type as name and then the same format of files as above. -Those new machine specific materials and options will only override global materials and options if they are similarly named, so it can be used to add a single material for a machine without duplicating all of the global options and materials. In order to override a material or an option, the directory name (or filename for options) must be match. +Those new machine specific materials and options will only override global materials and options if they are similarly named, so it can be used to add a single material for a machine without duplicating all of the global options and materials. In order to override a material or an option, the directory name (or filename for options) must match. For example : option_support.ini option_brim.ini -ABS/profile.ini +ABS/material.ini ABS/Low/profile.ini ABS/High/profile.ini -my_machine_type/PLA/profile.ini +my_machine_type/PLA/material.ini my_machine_type/PLA/Normal/profile.ini This would cause 'my_machine_type' typed machines to have both ABS (with Low and High quality) and PLA (with Normal quality only) materials, as well as support and brim options, while every other machine will only get the ABS material with both optins. If the machine needs to override the ABS material, you can simply add a file : -my_machine_type/ABS/profile.ini -to override the ABS setting, where you can either control the content of the profile.ini, or add new options, or override global options for that specific material, or add new or override existing quality settings for ABS. +my_machine_type/ABS/material.ini +to override the ABS setting, where you can either control the content of the material.ini, or add new options, or override global options for that specific material, or add new or override existing quality settings for ABS. -The profile.ini file can contain 3 sections : [info], [profile] and [alterations] in which the [profile] and [alterations] sections contain respectively profile and alteration settings for printing, while the [info] section can contain the following keys : +The profile.ini and material.ini files can contain 3 sections : [info], [profile] and [alterations] in which the [profile] and [alterations] sections contain respectively profile and alteration settings for printing, while the [info] section can contain the following keys : name = string -> The name of the profile to show in the UI disabled = true/false -> Disables this profile. Can be used to override a quality or material and disable it entirely. Default is False always_visible = true/false -> If set to True and the profile.ini belongs to the single quality of a material, or to the single material of a machine, it will allow the quality or material to always be visible in the UI. Otherwise, the material or quality section will be hidden from the UI. Default is True order = int -> The order to show this material or quality in the UI. Default is 999 +profile_file = Relative path to a file which will be used for fetching the [profile] and [alterations] sections. In that case, the [profile] and [alterations] sections in the material.ini or profile.ini file are ignored Profile options are applied in the following order : Material -> Quality -> Options. This allows you to group common settings for materials or to have options override everything else. -- 2.30.2