I would really like to control the colour of different parts of the output. For example chip pins grey, chip bodies black. Capacitors different colour from resistors.
The scripts will be run from FreeCADCmd, not from the GUI. Here is what I have so far, all I need is a way of passing some color or material info through to the step export code.
So far what I have read suggests its only possible via the GUI, but that seems against the ethos of FreeCAD, and compared to the FreeCADCmd the GUI is slow, compute intensive, and I am running this headless on a machine in the cloud all of which makes me really keen to find a way to work without the GUI.
Any tips, suggestions, other lines of enquiry welcome.
Code: Select all
import Part import sys import Draft PartNumber = 'F981A336MSAAS1' # Dimensions BodyLengthAvg = 2.05 BodyWidthAvg = 1.3 HeightMax = 0.9 PinWidth1Avg = 0.5 PinWidth2Avg = 0.5 myDocument = App.ActiveDocument myDocument = App.newDocument() doc=App.newDocument(PartNumber) term1 = FreeCAD.ActiveDocument.addObject("Part::Feature","term1") body = FreeCAD.ActiveDocument.addObject("Part::Feature","body") term2 = FreeCAD.ActiveDocument.addObject("Part::Feature","term2") from FreeCAD import Base term1p = Part.makeBox(PinWidth1Avg,HeightMax,BodyWidthAvg) term1.Shape = term1p bodyp = Part.makeBox(BodyLengthAvg-PinWidth1Avg-PinWidth2Avg,HeightMax,BodyWidthAvg) bodyp.translate(Base.Vector(PinWidth1Avg,0,0)) body.Shape = bodyp term2p = Part.makeBox(PinWidth2Avg,HeightMax,BodyWidthAvg) term2p.translate(Base.Vector(BodyLengthAvg-PinWidth2Avg,0,0)) term2.Shape = term2p doc.recompute() topObjects= for obj in FreeCAD.ActiveDocument.Objects: topObjects.append(obj) from os.path import expanduser home = expanduser("~") Part.export(topObjects,home+'/t.stp') Part.export(topObjects,home+'/t.stl')