Notifications
Clear all

Advanced post processing script commands  

  RSS
savannah.j
(@savannah-j)
New Member
Advanced post processing script commands

Hello,

does anybody know how to use a replace command with slic3r post processing ?

i know how to do it in s3d , but the same method wont work in slic3r .

For example i want to replace tall the gcode lines "G1 Z1 F500" with "G1 Z2 F500"

Thanks.

prepaidgiftbalance
Posted : 15/12/2018 11:01 am
bobstro
(@bobstro)
Illustrious Member
Re: Advanced post processing script commands

You can write a script that is called after slicing. The gcode filename will be passed to the script after it is generated by Slic3r. I use python for scripts. You could do what you want to do easily with regular expressions.

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 : 15/12/2018 4:36 pm
wmbalance
(@wmbalance)
Member
RE: Advanced post processing script commands

Slic3r is a popular open-source 3D printing slicer software that allows you to generate G-code from 3D models. While it offers extensive configuration options, it doesn't have a built-in text-based search and replace feature like some other slicer software.

To achieve a search and replace operation in your G-code generated by Slic3r, you can use external text processing tools or scripts. Here's a general approach to do this:

Export G-code: Use Slic3r to generate the initial G-code file for your 3D print as you normally would.

Use a Text Editor or Script:

Open the generated G-code file with a text editor (e.g., Notepad++ or Visual Studio Code).Use the text editor's find and replace feature to replace the desired strings, such as "G1 Z1 F500" with "G1 Z2 F500."

If you want to automate this process or perform more complex text manipulation, you can use a scripting language like Python. Here's a simple example in Python:

pythonCopy code# Read the original G-code file with open('original.gcode', 'r') as file: gcode = file.read() # Perform the text replacement gcode = gcode.replace('G1 Z1 F500', 'G1 Z2 F500') # Write the modified G-code back to a new file with open('modified.gcode', 'w') as file: file.write(gcode)

In this Python script, you read the original G-code, perform the replacement using the replace method, and then write the modified G-code to a new file.

Remember to replace 'original.gcode' and 'modified.gcode' with the actual file paths as needed.

Once you've replaced the desired lines in the G-code, you can use the modified G-code file for your 3D printing job.

Keep in mind that manually editing G-code can introduce errors, so always double-check the modified G-code for correctness before using it in your 3D printer.

Posted by: @savannah-j

Hello,

does anybody know how to use a replace command with slic3r post processing ?

i know how to do it in s3d , but the same method wont work in slic3r .

For example i want to replace tall the gcode lines "G1 Z1 F500" with "G1 Z2 F500"

Thanks.

 

Posted : 18/09/2023 10:04 am
Share: