Export STEP to PrusaSlicer

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
demonlibra
Posts: 79
Joined: Tue Jan 21, 2020 1:11 pm

Export STEP to PrusaSlicer

Post by demonlibra »

PrusaSlicer 2.5.0 is able to import STEP files.
Wrote a macro to send selected models to PrusaSlicer with STEP.

Code: Select all

# -*- coding: utf-8 -*-

# ----------- Export STEP to PrusaSlicer ------------

slicer_path = '/home/demonlibra/app/PrusaSlicer-2.5.0-beta1/prusa-slicer' # Path to PrusaSlicer

save_to_temp = True # Save step files to temp file
#save_to_temp = False # Save model near FCStd

# ----------------------------------------------------------------------

import ImportGui
import datetime
import os
import subprocess
import tempfile

objects_to_export = FreeCADGui.Selection.getSelection()						# Выделенные объекты
slicer_args = [slicer_path]

for object in objects_to_export:														# Перебор выделенных объектов
	label = object.Label
	now = datetime.datetime.now()
	doc = FreeCAD.activeDocument()
	filename = os.path.basename(doc.FileName).partition('.')[0]
	if save_to_temp:																		# Если сохранять во временный каталог
		dirname = tempfile.gettempdir()
		file_path = os.path.join(dirname, filename)  + '-' + label + '.step'
	else:																						# Иначе сохранять рядом с файлом FCStd
		dirname = os.path.dirname(doc.FileName)
		#file_path = os.path.join(dirname, filename) + label + '_' + now.strftime("%Y%m%d_%H%M") + '.step'
		file_path = os.path.join(dirname, filename)+ '-' + label + '.step'
	slicer_args.append(file_path)
	ImportGui.export([object], file_path)											# Экспорт модели в step

subprocess.Popen(slicer_args)															# Запустить слайсер

phpBB [video]
User avatar
dork
Posts: 14
Joined: Tue Feb 18, 2020 7:49 pm
Location: Netherlands

Re: Export STEP to PrusaSlicer

Post by dork »

As a PrusaSlicer user I thought at first "Great!".
But reading further at Prusa I understood that the STEP import converts the file to a triangle mesh internally before slicing.
So for now I will export the mesh from FreeCAD as usual and keep control over it.
demonlibra
Posts: 79
Joined: Tue Jan 21, 2020 1:11 pm

Re: Export STEP to PrusaSlicer

Post by demonlibra »

Also You can use macros Export2Slicer, which export model to stl and open PrusaSlicer be one click.

Image
Post Reply