FreeCAD Code update

well, a few days after posting that code below for freecad to kisslicer bridge, I started having people contact me on the freecad forums and an administrator on there also agreed, so I copied the code, slightly modified, to the freecad’s main wiki as part of the official wiki documents under the macro section. The link for it is here:

I hope eventually it can be added in as an option as part of the main program rather than just a script/macro. Ive also gotten messages on the forums from people saying that it works good with pyCAM, cura, slic3r, and a few other slicing software/cnc software.

As Ive said before, I use it on a daily basis, so I know it works good, but what the code does, you save your current design, then click the button for the macro/script, and it will open the object, as it looks in your design, up in your slicing/printing software, ready to print. So instead of having to export everything, then finding your slicing software and opening the exported stl file, it just does everything automatically and opens it up in your slicing software, directly from freecad itself while automatically exporting the stl file in the same folder as the design file, and opens up your slicing software automatically ready to slice/print.

My FreeCAD addon

Ive been working on a FreeCAD addon since I use kisslicer to slice up my stl files for my 3d objects I design, so eventually, I got tired of constantly having to search for the stl files, and designed this code. The code will automatically convert only the visible parts that you want, group them together, and export it as an stl file next to the original design file, with the same filename except with stl extension. Then it’ll open the STL file automatically for you ready to slice and to create gcode from your settings.

I designed it on linux, but it should easily be converted to be used on windows or any other system. Just create a macro in freecad, and paste this into the macro, then save it. Then you can go to tools/customize and set up the macro to a button on the toolbar, so you can just click the button and it converts everything for you.

import FreeCAD
import Mesh
import sys
import math
import os
import subprocess

# some fuctions

def getPlacement(quat,vect,obj):
  if quat[3] > -1  and quat[3] < 1:
    delta = math.acos(quat[3])*2.0
    scale = math.sin(delta/2)
    rx = quat[0]/scale
    ry = quat[1]/scale
    rz = quat[2]/scale
    delta = 0
    rx = 0
    ry = 0
    rz = 1

info0 = "translation "+str(vect.x)+" "+str(vect.y)+" "+str(vect.z)
info1 = "rotation "+str(rx)+" "+str(ry)+" "+str(rz)+" "+str(delta)
return info0+" "+info1
# some definitions
placement = App.Placement(App.Vector(0,0,0),App.Rotation(0,0,0,1))

# user need to set this directory where STL files will be placed
OutDir = FreeCAD.ActiveDocument.FileName.replace(FreeCAD.ActiveDocument.Label + ".fcstd", "")
visible_objs = []
KISSlicer = "/kisslicer location/"     #put the location of your kisslicer directory here

# Get Objects in document
doc = App.ActiveDocument
objs = doc.Objects

# hide all
for obj in objs:
  if obj.ViewObject.isVisible():

print "number of volumes "+str(len(visible_objs))

for obj in visible_objs:
# {
  # get volume
  volume = obj.Shape.Volume

  # get Rotation and translation of volume
  quat = obj.Placement.Rotation.Q
  vect = obj.Placement.Base
  pinfo = getPlacement(quat,vect,obj)

  # reset placement, export it and set at original placement
  oldPlacement = obj.Placement
  obj.Placement = placement
  obj.Placement = oldPlacement

stlFile = OutDir+str(doc.Label)+".stl"
subprocess.Popen([KISSlicer + "KISSlicer", stlFile])

You’ll have to change the values of the location of KISSlicer, or modify it for whatever slicer software you use, and it should work fine.

Update 2

Well, makerfaire is over, and it was a complete blast this year. I found the Printrbot guys there also and got the broken board problem solved, which is a really good thing, and the little printer is finally fixed now. Im back onto working on my reprap prusa mendel I2, and was trying to design my own hot end for the thing, which is a chore in and of itself due to the fact that I dont have a lathe or know of someone with a machining shop.

As before, Im still adding mods to my playstation that I found in the trash, and I think it’s almost finally perfect for me. I used one of my PIC microcontrollers and created a mod chip for it, which was a bit easier than it sounds. I had tons of psx games, but most were scratched beyond belief from not being used and just tossed around for the last 3-4 years, so I can just use the rom sites to download copies of them and so I can play them again.

So Ive been doing that, and bogging down the internet connection getting copies of my psx games to play again, just had a little issue with a few games due to needing an anti mod chip patch so they’ll play.  Also just working on my prusa mendel, it seem to keep me busy most of the time, but may make another after this one’s made due to wanting one to be able to take around with me to different places, and not take up a bunch of space, which if I get it running good, I may just do that with my pbjr.

Nothing new, just got alot of questions answered at makerfaire that I was curious about, and alot of new ideas about how to do things. On the question I asked before about the ft232 usb-ttl chip and dropouts, I found out that it happens with all chips, and the best way to avoid that is have true isolated grounding, some printers use chips with built in usb stuff and that also helps too, but just keep an isolated ground, and give good connections for the chips, and everything will be fine.