Notifications
Clear all

PrusaSlicer INI docs?  

  RSS
gnat
 gnat
(@gnat)
Noble Member
PrusaSlicer INI docs?

I want to start playing with some profile customizations, but I'm finding how it is working a bit confusing.

For example I had created a custom PETG profile via PS itself. The only changes I made were to the first layer and overall temp values, yet a lot more settings were saved in the custom config. When I created it, I was using the MK3S config. Now that I have my MMU installed I see that it only shows up when I select the single filament mode.

Conversely I just created a MMU specific version by hand by inheriting from the Prusament MMU2 profile and again changing the temps. Now while it shows up when I select the MMU printer, it also shows up when I select the Single mode profiles too (while the "Prusament PETG MMU2" profile disappears and is replaced with the "Prusament PETG" profile).

Basically my current puzzlement is how do I control what profiles show up based on the selected printer. Though more general documentation around layouts and hierarchy would be nice too.

MMU tips and troubleshooting
Posted : 30/06/2019 3:29 am
bobstro
(@bobstro)
Illustrious Member
RE: PrusaSlicer INI docs?

Welcome to a world of poor documentation (dating back to the Slic3r days) and cryptic functions.

I suspect the specific answer to your profile issue is to be found under Print Settings->Dependencies->Profile dependencies->Compatible printers condition. You'll find some conditions here to limit when a print profile is visible. For example, load a printer profile for a 0.40mm nozzle and you'll see the 0.15mm QUALITY MK3 print profile. Load a printer profile with a different nozzle size and it disappears from the list. Take a look at the compatible printers condition and you'll find:

printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/ and nozzle_diameter[0]==0.4

Notice the bolded "==" sign at the end. This profile will only show up if you are using a nozzle size of exactly 0.40mm. Change that to >= and it's nnow visible to 0.40mm and larger nozzle printer profiles. (I use this along with 0-sized extrusion widths to let PS calculate the widths at slice time, letting me use a single print profile with multiple nozzle sizes.) I've got more notes on modifying profiles and setting dependencies here.

Now to the question of the config files themselves: When you export a config file, PS creates one file with all settings from all 3 tabs in one file. Open a saved config.ini and you'll see every setting neatly alphabetized. Export a config bundle, and you'll find all of your custom profiles neatly broken out under separate profiles categorized with your profile names in square brackets. Here's one of mine:

[print:QUALITY 0.05mm layers for 0.15mm+ nozzle (RLG 20190628)]

You can create .ini config bundles of your own containing profiles containing settings for any mix of:

print:
printer:
filament:

each with a similar heading with the type, a colon and your unique profile name (dupes get over-written, last in wins).

You'll quickly notice the Prusa default profiles are not exported into a config bundle. I actually had problems with this in the past, so I'm glad of this. If you want to look at the Prusa config, open up your PrusaSlicer configuration file. I'm on a Mac, so I find it under ~/Library/Application Support/Prusa Slicer/vendor/PrusaResearch.ini.

The first thing you'll notice is that a lot of the configs are fragmentary. They build on each other through inherits= statements.  For example, I got sick of trying to maintain multiple printer profiles for each of 12 possible nozzle sizes I own. I was especially frustrated when I'd forget to copy custom gcode I carefully crafted for one to another. What I've done is created a master printer profile:

[printer:Baseline (RLG 20190628)]
[... a whole bunch of settings I want in every profile ...]
end_gcode = [... my custom end g-code - all 1 line delimited with \n ...]
start_gcode = [... my custom start g-code - all 1 line delimited with \n ...]
[... a whole bunch more settings I want in every profile ...]

Then I can create tweaked profiles with just a few lines, being sure to insert an inherits= pointing to my baseline profile:

[printer:QUALITY Prusa i3 Mk3 0.30 nozzle (RLG 20190628)]
inherits = Baseline (RLG 20190628)
min_layer_height = 0.04
max_layer_height = 0.24
nozzle_diameter = 0.30
printer_settings_id = QUALITY Prusa i3 Mk3 0.30 nozzle
printer_variant = 0.3
retract_before_wipe = 0%
retract_length = 0.40
retract_lift = 0.3

Any setting not explicitly specified will be inherited from the baseline specified. My new 0.30mm nozzle profile printer profile inherits the startup and end gcode from the baseline configuration, saving errors re-typing it. A few notes:

  • Exporting configs or config bundles always creates each profile with all settings, so you have to manually create and maintain your own if you want to take full advantage of inheritance.
  • So far as I can tell, you cannot inherit from the Prusa default profiles in another file. Inheritance only seems to work within the same .ini file.
  • None of this is documented, and may all change or go away with any release.

If you still want to partake in this journey into madness, feel free to take a look at my current working set of printer, print and filament profiles. Just import each one into PrusaSlicer as a separate config bundle. My profiles all contain my initials in the name, so there should be no collisions with your settings.

 

 

 

 

 

 

 

My notes and disclaimers on 3D printing

and miscellaneous other tech projects
He is intelligent, but not experienced. His pattern indicates two dimensional thinking. -- Spock in Star Trek: The Wrath of Khan

Posted : 30/06/2019 4:39 am
gnat
 gnat
(@gnat)
Noble Member
Topic starter answered:
RE: PrusaSlicer INI docs?

Thanks Bob. Some of that I was figuring out, some is definitely enlightening. I'll have to reread it at not 1am 🤣 

MMU tips and troubleshooting
Posted : 30/06/2019 5:20 am
gnat
 gnat
(@gnat)
Noble Member
Topic starter answered:
RE: PrusaSlicer INI docs?
Posted by: bobstro

Welcome to a world of poor documentation (dating back to the Slic3r days) and cryptic functions.

Yeah I know. I was hoping that there was a community driven version that someone knew about.

I suspect the specific answer to your profile issue is to be found under Print Settings->Dependencies->Profile dependencies->Compatible printers condition.

Yeah I had seen that, but the way it is showing up in the INI it is hard to follow since they cram it all into one line. Looking at it again this morning I now see the "!" that was hidden in there to negate the remaining tests that do match the MMU profile. I guess in my old age I've become too used to Go enforcing coding standards and forgotten my early days of hating Perl 4 code 😆 

Now to the question of the config files themselves: When you export a config file, PS creates one file with all settings from all 3 tabs in one file. Open a saved config.ini and you'll see every setting neatly alphabetized. Export a config bundle, and you'll find all of your custom profiles neatly broken out under separate profiles categorized with your profile names in square brackets. Here's one of mine:

[print:QUALITY 0.05mm layers for 0.15mm+ nozzle (RLG 20190628)]

What's under ~/.PrusaSlicer doesn't look like that, at least for the customized config. There is a copy of the main config there and it looks as described, but the one I generated from the UI is in a filament sub direction and the name of the file is the name that shows up in the UI. There is no header, just the sorted list of attributes. There are similar sub directories for print and printer too.

  • So far as I can tell, you cannot inherit from the Prusa default profiles in another file. Inheritance only seems to work within the same .ini file.

I believe you are correct. The UI generated file still contains the inheritance attribute, but based on my manual attempt I agree that setting is doing nothing.

I like the separate files idea as trying to jump all around in the main config makes it difficult to understand what all is happening, but to instead have to change every file when I decide to update a common setting will get ugly quickly...

If you still want to partake in this journey into madness, feel free to take a look at my current working set of printer, print and filament profiles. Just import each one into PrusaSlicer as a separate config bundle. My profiles all contain my initials in the name, so there should be no collisions with your settings.

Well since Prusa doesn't feel the MMU is capable of printing high detail for a multi-material job (.15 with a .4 nozzle is the best they offer) I have little choice but to experiment...

Thanks again for the insights.

MMU tips and troubleshooting
Posted : 30/06/2019 5:44 pm
--
 --
(@)
Illustrious Member
RE: PrusaSlicer INI docs?

Another +1 for the detailed explanation.  Thank Bob.

Posted : 30/06/2019 6:33 pm
bobstro
(@bobstro)
Illustrious Member
RE: PrusaSlicer INI docs?
Posted by: Tim

Another +1 for the detailed explanation.  Thank Bob.

You're very welcome. Just trying to dump the ol' brain out before I forget stuff. Need to update my notes pages on this stuff. Hope it's useful.

My notes and disclaimers on 3D printing

and miscellaneous other tech projects
He is intelligent, but not experienced. His pattern indicates two dimensional thinking. -- Spock in Star Trek: The Wrath of Khan

Posted : 30/06/2019 7:28 pm
bobstro
(@bobstro)
Illustrious Member
RE: PrusaSlicer INI docs?

Uhm... I just wrote another detailed piece and... it's gone. I'm going to add notes pages to my online notebook and point there from now on. The new forums are increasingly a waste of time for long-term preservation of information. 

My notes and disclaimers on 3D printing

and miscellaneous other tech projects
He is intelligent, but not experienced. His pattern indicates two dimensional thinking. -- Spock in Star Trek: The Wrath of Khan

Posted : 30/06/2019 7:30 pm
--
 --
(@)
Illustrious Member
RE: PrusaSlicer INI docs?

I've never lost content (yet, knock on wood); but every single use of the new forum I gain increased incentive to stop participating.

Posted : 30/06/2019 9:53 pm
gnat
 gnat
(@gnat)
Noble Member
Topic starter answered:
RE: PrusaSlicer INI docs?
Posted by: Tim

I've never lost content (yet, knock on wood); but every single use of the new forum I gain increased incentive to stop participating.

I have. You spend a lot of time writting a very detailed post with lots of useful information. Then you try to post and find you've been logged out and it also ate your post to boot. 

MMU tips and troubleshooting
Posted : 30/06/2019 10:50 pm
gnat
 gnat
(@gnat)
Noble Member
Topic starter answered:
RE: PrusaSlicer INI docs?

Here is a little script I whipped up this afternoon. It reads the PrusaResearch.ini from your ~/.PrusaSlicer/vendor directory and copies the given object to a new config file for you to work from. What it does for you is collapse the entire hierarchy into a single complete (as to what is defined in the source file) snapshot of what that object looks like.

The tool expects to live in ~/.PrusaSlicer/bin and it takes 3 arguments:

  • type: The object type (filament, print, printer, sla_material, or sla_print)
  • source: The object's name (e.g. Prusament PETG MMU2)
  • name: The name of your new object.

It will then collapse the source object into a single entity and save it to the correct place (e.g. ~/.PrusaSlicer/filament/My Cool PETG.ini) so that PS will see it the next time you run it (you need to restart if it is already running).

The purpose is two fold. First is that it gives you a collapsed place to look at all an object's settings without having to jump around in the main PrusaResearch.ini file. Second it gives you a starting point to work from.

Future plans are to add a comparison tool so you can see just what differs between two objects. This would be useful for knowing what changes to make as well as identifying updates to make when Prusa releases a new configuration.

This should just work on a Mac, but I've only tested Linux. I have no idea about Windows, but I used the OS agnostic tools for working with directories so it could work...

Example:

$ bin/create_new.py filament "Prusament PETG MMU2" "My cool PETG MMU2"
Writing config to ./filament/My cool PETG MMU2.ini
$ bin/create_new.py printer "Original Prusa i3 MK3S MMU2S" "My cool MMU2"
Writing config to ./printer/My cool MMU2.ini

Code:

#!/usr/bin/env python

import os
import re
import sys
import os.path
import argparse
import datetime


BASE_DIR = os.path.normpath(os.path.join(os.path.dirname(__file__), ".."))


def process_cli():
  """
  Creates an argparse object and parses the command line.
  Returns the argparse object
  """
  cli = argparse.ArgumentParser(
    description="Utility to generate new user configs from the main INI",
    formatter_class=argparse.ArgumentDefaultsHelpFormatter,
  )

  cli.add_argument("type",
    help="The type of object to work with",
    choices=["filament", "print", "printer", "sla_material", "sla_print"],
  )
  cli.add_argument("source", help="The name of the source object")
  cli.add_argument("name", help="The name of the new object")

  cli.add_argument("-s", "--source-file",
    help="The source file to read.",
    default=os.path.join(BASE_DIR, "vendor", "PrusaResearch.ini"),
  )

  return cli.parse_args()

def read_source_ini(filename):
  """
  Loads the given INI file into a dictionary keyed first by type
  and second by name.
  Returns the resulting dict.
  """
  name_re = re.compile(r"^\s*\[(\S+?)(|(:(.+?)))\]")
  skip_re = re.compile(r"^\s*(|#.*)$")
  value_re = re.compile(r"^\s*(\S+?)\s*=\s*(.*)$")

  ini = {}
  curr = {}
  fp = open(filename, 'r')
  for line in fp:
    line = line.rstrip()
    if skip_re.match(line):
      continue

    match = name_re.search(line)
    if match is not None:
      # Found a group header
      group = match.group(1)

      if group not in ini:
        ini[group] = {}
      
      if group == "vendor":
        # Special case with no sub-dicts
        curr = ini[group]
      else:
        ini[group][match.group(4)] = {}
        curr = ini[group][match.group(4)]
      
      continue # might as well short circuit

    match = value_re.search(line)
    if match is None:
      # not sure how we get here actually...
      continue

    curr[match.group(1)] = match.group(2) 
  
  fp.close()

  return ini

def assemble_config(ini, group, name):
  """
  Traverses inheritance to generate a flat configuration
  Returns a flat dictionary with all attributes for the
  given object.
  """

  if group not in ini:
    print "Invalid type: {}".format(group)
    sys.exit(1)
  
  return get_config(ini[group], name, {})

def get_config(group, name, config):
  """
  Add any attributes from the named object to config if they
  don't already exist. If the inherits attribute exists,
  recursively descend into it.
  Returns a flattened config with all the attributes.
  """
  if name not in group:
    print "Invalid object: {}".format(name)
    sys.exit(1)
  
  parent = None
  for k, v in group[name].iteritems():
    if k not in config:
      # Don't have it yet, take it
      config[k] = v
    
    if k == "inherits":
      parent = v
  
  if parent is not None:
    config = get_config(group, parent, config)
  
  return config

def write_config(version, group, name, config):
  """
  Writes the given named file to the given group directory with the
  config contents. Includes a leading comment with the base
  PrusaResearch.ini version number.
  """
  attrs = config.keys()
  attrs.sort()

  filename = os.path.join(BASE_DIR, group, "{}.ini".format(name))
  print "Writing config to {}".format(filename)
  fp = open(filename, "w")

  fp.write("# Created by {} with {} at {}\n".format(
    os.getlogin(), os.path.basename(sys.argv[0]),
    datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
  ))

  fp.write("# vendor_version = {}\n\n".format(version))

  for key in attrs:
    fp.write("{} = {}\n".format(key, config[key]))
  
  fp.close()


if __name__ == "__main__":
  cli = process_cli()
  ini = read_source_ini(cli.source_file)
  config = assemble_config(ini, cli.type, cli.source)
  write_config(ini['vendor']['config_version'], cli.type, cli.name, config)
MMU tips and troubleshooting
Posted : 30/06/2019 11:48 pm
marksanctuary
(@marksanctuary)
New Member
RE: PrusaSlicer INI docs?

@bobstro can you make the pastebin filament public so I can get a copy of it?

Geeetech Aluminium Prusa i3 (Sanguinololu, T8 Lead Screw)

Posted : 30/12/2019 1:05 am
marksanctuary
(@marksanctuary)
New Member
RE: PrusaSlicer INI docs?

@bobstro also I really like your online notebook! What web software are you using for the online notebook? It's not anything like wordpress.

Geeetech Aluminium Prusa i3 (Sanguinololu, T8 Lead Screw)

Posted : 30/12/2019 7:38 pm
bobstro
(@bobstro)
Illustrious Member
RE: PrusaSlicer INI docs?
Posted by: @marksanctuary

@bobstro can you make the pastebin filament public so I can get a copy of it?

Here are the updated filament profiles, printer profiles, and print profiles I'm using. I've also updated the notes page with everything combined as a single config bundle. The filament examples are a bit less organized than the print and printer examples.

My notes and disclaimers on 3D printing

and miscellaneous other tech projects
He is intelligent, but not experienced. His pattern indicates two dimensional thinking. -- Spock in Star Trek: The Wrath of Khan

Posted : 30/12/2019 8:12 pm
bobstro
(@bobstro)
Illustrious Member
RE: PrusaSlicer INI docs?
Posted by: @marksanctuary

@bobstro also I really like your online notebook! What web software are you using for the online notebook? It's not anything like wordpress.

It's the Sphinx static webpage generator. I don't have to have any server-side code running as it only generates HTML, so any lightweight web server can handle it. No potential security holes with logins, databases or other niceties. It's basic, but it works well for my purposes. I'm using the readthedocs template which you may see used with a lot of open source projects.

My notes and disclaimers on 3D printing

and miscellaneous other tech projects
He is intelligent, but not experienced. His pattern indicates two dimensional thinking. -- Spock in Star Trek: The Wrath of Khan

Posted : 30/12/2019 8:16 pm
Nikolai
(@nikolai)
Noble Member
RE: PrusaSlicer INI docs?

If you guys are interested in static webpage generators, I can also recommend https://gohugo.io/

Often linked posts:
Going small with MMU2
Real Multi Material
My prints on Instagram

Posted : 30/12/2019 10:02 pm
Share: