[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: gEDA-user: PCB+GL+3D Packages??
On 11/15/2010 08:19 PM, kai-martin knaak wrote:
.. and that's about all it can do right now. I don't want to frustrate
Here's an example of a python script that can be launched from a python interpreter window
of HeeksCAD. It defines a shelf parametrically. It can be exported as STEP or STL
for interoperation and cutting of normal non-fancy CNC milling machine cuts.
HeeksCNC is usable to help with making tool paths.
I don't see exactly how it would benefit the pcb project, but the code is BSD licensed and in C++
if/when PCB goes that way.
.png's of screen shots are here:
So far my script generates this first.
http://ecosensory.com/diybio/pegs_shelfsized.heeks.png
then I use the GUI to select and cut out the cylinders.
http://ecosensory.com/diybio/holes_shelfsized.heeks.png
http://ecosensory.com/diybio/holes_shelfsized.heeks2.png
How to use a script file from the console window is:
-----------------------
To run a file from the interpreter use this path directive to
add the script dir, /home/john/heekscad:
import HeeksPython as cad
import sys
sys.path.insert(0,'/home/john/heekscad')
import shelfsized # for python script file named shelf3g.py
reload(shelfsized) # to iterate additions to the script, and what you get.
------------------------------------------------
The writing of my first script was a little slow to start because
I was baffled by the python interpreter import of a module not updating after the first load.
I needed reload, a python2.6 function that is going away, to get easy code writing with a quick
look each step of the way. Because I knew a little python, I was able to add a feature already.
I added a way to place new cylinders in any orientation, so the script could operate on
the 3D representation without having to reorient the whole set of objects several times.
That is more than I could do with pcb as it was a few years ago when I tried... So the code is
arrange well enough, and people are available to help, and it does things now.
Freecad is going to be great, but last I tried doing booleans it slowed to a crawl and was unusable.
Below is the script that made the screenshots. The screen shots were needed because printing is broken.
Printing broken isn't such a big deal, since you can export to very standard usable STL, STEP,
and from 2D sketches, DXF. So, decide for yourselves what it can do right now.
John Griessen
-------------
# shelfsized.py
# dimensions in millimeters.
# default dimensions get overridden:
ox=0;oy=0;oz=0 # origin corner point
width=500
depth=155
thick=12 #default size shelf.
hole1dist=30 #distance from side cam to front edge shelf.
hole2dist=47.54 #distance from side cam to back edge shelf.
hole3dist=120 #distance from back cam to side edge shelf.
doweldist=23.04 #distance for cam hole to grab dowel well.
dowelhole=7.25 #diameter for dowel holes.
camhole=12.05 #diameter for cam holes.
camdepth=10.0 #depth of cam holes.
def draw():
import HeeksPython as cad
ikeaize(ox,oy,oz,width,depth,thick,hole1dist,hole2dist, \
hole3dist,doweldist,dowelhole,camhole)
shelf1= cad.getlastobj()
def ikeaize(ox,oy,oz,width,depth,thick,hole1dist,hole2dist, \
hole3dist,doweldist,dowelhole,camhole):
import HeeksPython as cad
cad.setcolor(191,240,191)
cad.cuboid(ox,oy,oz,width,depth,thick)
cad.setcolor(191,191,240)
shelf_slab2 = cad.getlastobj()
cad.cylinder(ox + doweldist,depth - hole1dist, \
oz + thick - camdepth,camhole / 2,camdepth * 2)
hole1 = cad.getlastobj()
cad.directedcylinder(ox + doweldist,depth - hole1dist, \
oz + thick / 2,-1,0,0,dowelhole / 2,35)
edgehole1 = cad.getlastobj()
cad.cylinder(width - doweldist,depth - hole1dist, \
oz + thick - camdepth,camhole / 2,camdepth * 2)
hole1b = cad.getlastobj()
cad.directedcylinder(width - doweldist,depth - hole1dist, \
oz + thick / 2,1,0,0,dowelhole / 2,35)
edgehole1b = cad.getlastobj()
cad.cylinder(ox + doweldist,oy + hole2dist, \
oz + thick - camdepth,camhole / 2,camdepth * 2)
hole2 = cad.getlastobj()
cad.directedcylinder(ox + doweldist,oy + hole2dist, \
oz + thick / 2,-1,0,0,dowelhole / 2,35)
edgehole2 = cad.getlastobj()
cad.cylinder(width - doweldist,oy + hole2dist, \
oz + thick - camdepth,camhole / 2,camdepth * 2)
hole2b = cad.getlastobj()
cad.directedcylinder(width - doweldist,oy + hole2dist, \
oz + thick / 2,1,0,0,dowelhole / 2,35)
edgehole2b = cad.getlastobj()
cad.cylinder(ox + hole3dist,oy + doweldist, \
oz + thick - camdepth,camhole / 2,camdepth * 2)
hole3 = cad.getlastobj()
cad.directedcylinder(ox + hole3dist,oy + doweldist, \
oz + thick / 2,0,-1,0,dowelhole / 2,35)
edgehole3 = cad.getlastobj()
cad.cylinder(width - hole3dist,oy + doweldist, \
oz + thick - camdepth,camhole / 2,camdepth * 2)
hole3b = cad.getlastobj()
cad.directedcylinder(width - hole3dist,oy + doweldist, \
oz + thick / 2,0,-1,0,dowelhole / 2,35)
edgehole3b = cad.getlastobj()
draw()
_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user