Saturday, May 12, 2012

Javascript blogger test

Cut and Paste JavaScript-JavaScript calculator I just want to try something out with this blogger software. I want to see if I put inline javascript in a post. This post might be deleted later, after the test.





This free script provided by
JavaScript Kit

Sunday, April 15, 2012

Cloud CADCAM via twisted python

I have been working a bit with Julian Todd of FreeSteel . We have started working on a way of serving out toolpaths, using his 'Slicer' routine from a server. The server takes triangle vertices in and returns tool location paths, for waterline type machining. Julian is very familiar with twisted python and plans on using it for his own server. At the moment, I am running his library locally.

Here is an image of a part that I designed in FreeCAD and applied this 'Slicer' scheme to:



The python code that I used for this doesn't post process into actual g-code, but it could.

import Mesh
import Part,FreeCAD
from FreeCAD import Base,Vector
import freesteelpy as kernel

s=Gui.Selection.getSelectionEx()
s1 = s[0]
m1 = s1.Object
m1.Mesh.write("/home/danfalck/mesh1.py") #write the triangle list to a file
f1 = m1.Mesh.Facets #returns out a list of facets

fssurf = kernel.FsSurf.New()
for f in f1:
fssurf.PushTriangle(f.Points[0][0],f.Points[0][1],f.Points[0][2], f.Points[1][0],f.Points[1][1],f.Points[1][2], \
f.Points[2][0],f.Points[2][1],f.Points[2][2])

def doit(fssurf, z , rad):
fssurf.Build(1.0)

fshoriztoolsurf = kernel.FsHorizontalToolSurface.New()
fshoriztoolsurf.AddSurf(fssurf)
fshoriztoolsurf.AddCylinder(rad, z, 10.0, 0) #cylinder radius, lower Z, upper Z, how the cylinder is connected to the rest of the tool -tangential etc.
fsimplicitarea = kernel.FsImplicitArea.New(0)
fsimplicitarea.AddHorizToolSurf(fshoriztoolsurf)
fsimplicitarea.SetContourConditions(0.99, -1.0, 0.002, 2, -1.0, 0.9)
fsweave = kernel.FsWeave.New()
fsweave.SetShape(-25, 25, -25, 25,.1) #(-x, -y, x , y of bounding area, last arg is granularity of path)
fsimplicitarea.GenWeaveZProfile(fsweave)
fsweave.GetNContours()

fspath2x = kernel.FsPath2X.New(0)
fspath2x.RecordContour(fsweave, False, 0, 0.0)

fspath2x.GetNpts()

[ (fspath2x.GetD(i,0), fspath2x.GetD(i,1)) for i in range(fspath2x.GetNpts()) ]

[ (fspath2x.GetD(i,0), fspath2x.GetD(i,1), fspath2x.GetD(i,2)) for i in range(fspath2x.GetNpts()) ]

pt0 = (fspath2x.GetD(0,0), fspath2x.GetD(0,1), fspath2x.GetD(0,2))

#FreeCAD.ActiveDocument.addObject("Part::Feature","rapids)\n")
c = Part.Compound([])

for i in range(fspath2x.GetNpts()-1):
line = ( Part.makeLine( (fspath2x.GetD(i,0), fspath2x.GetD(i,1), fspath2x.GetD(i,2) ) , ( fspath2x.GetD(i+1,0), fspath2x.GetD(i+1,1), fspath2x.GetD(i+1,2) ) ) )
c.add(line)

c.Placement=Base.Placement(Base.Vector(0.00,0.00,z),Base.Rotation(0.00,0.00,0.00,1.00))

Part.show(c)

rad = 1.0
startdepth = 2.5
zdepth = -3.0
stepdown = .25
steps = startdepth

while startdepth >= zdepth:
z = startdepth
doit(fssurf,z,rad)
startdepth =startdepth-stepdown


Sorry for the poor formatting of the source code- I need to figure that out soon.

Friday, January 13, 2012

Sunday, January 1, 2012

More Progress

I was able to hack together a crude 'Profile Operation' dialog and connect it to heekscnc and libarea functions this weekend. Now I can bring up the dialog, select the edges of a solid, and then backplot the code.
It's definitely a rough hack, but it shows some potential.

Saturday, December 31, 2011

Using QtDesigner!!!!



I'm starting to get the hang of using QtDesigner for making pyQt Dialogs with FreeCAD/HeeksCNC. I love it!!!!

A little progress report

I'm still learning the internals of FreeCAD. I helped the main project a little by creating a lowly 'Point' class, which Yorik integrated into the Draft workbench. Doing this helped me get familiar with the source. Having this object class will also be useful later on for CAM work (start and end points for profiles etc).
I have also made some scripts for extracting libarea 'curve' elements from objects in the FreeCAD document. Right now, I can click on edges of solids or lines and arcs in Sketches or Draft elements and then run a macro to produce some python code that can be pasted into a HeeksCNC python script for producing g-code.
The resulting code looks like this:

curve = area.Curve()
#open path
curve.append(area.Point(62.244881,-33.935955))
curve.append(area.Vertex(-1 , area.Point( 57.129109, -39.051727), area.Point(57.129109, -33.935955)))
curve.append(area.Point( -56.043546, -39.051727))
curve.append(area.Vertex(-1 , area.Point( -64.821892, -30.273381), area.Point(-56.043546, -30.273381)))

If you've ever used HeeksCNC, this code should look familiar.
I can take this code and paste it into a script such as this one:

import sys
sys.path.insert(0,'/usr/lib/heekscnc/')
import math
import area
area.set_units(1)
import kurve_funcs
from nc.nc import *
import nc.emc2b

output('/home/danfalck/Documents/freecad/curve_output/test.tap')
program_begin(123, 'Test program')
absolute()
metric()
flush_nc()

set_plane(0)

workplane(1)

#(4.7752 mm Carbide End Mill)
tool_defn( id=4, name='4.7752 mm Carbide End Mill', radius=2.3876, length=23.876, gradient=-0.1)
tool_diameter = float(4.7752)
cutting_edge_angle = float(0)

#path/geometry section
curve = area.Curve()
curve.append(area.Point(62.244881,-33.935955))
curve.append(area.Vertex(-1 , area.Point( 57.129109, -39.051727), area.Point(57.129109, -33.935955)))
curve.append(area.Point( -56.043546, -39.051727))
curve.append(area.Vertex(-1 , area.Point( -64.821892, -30.273381), area.Point(-56.043546, -30.273381)))
#end of path/geometry section

#program action:
comment('tool change to 4.7752 mm Carbide End Mill')
tool_change( id=4)
spindle(7000)
feedrate_hv(840, 100)
clearance = float(5)
rapid_safety_space = float(2)
start_depth = float(0)
step_down = float(2)
final_depth = float(-10)
roll_radius = float(5.0)
offset_extra = 0
roll_on = 'auto'
roll_off = 'auto'
extend_at_start= 0
extend_at_end= 0
lead_in_line_len= 5.0
lead_out_line_len= 5.0
kurve_funcs.profile(curve, 'left', tool_diameter/2, offset_extra, roll_radius, roll_on, roll_off, rapid_safety_space, clearance, start_depth, step_down, final_depth,extend_at_start,extend_at_end,lead_in_line_len,lead_out_line_len )

absolute()

program_end()



The resulting gcode might give something like this (backplotted in FreeCAD):


Saturday, November 5, 2011

FreeCAD

Lately I've gotten interested in FreeCAD .
FreeCAD is "a a general purpose Open Source 3D CAD/MCAD/CAx/CAE/PLM modeler" written in C++, with python scripting built in. It runs on Windows, Linux, and supposedly Mac OS X. FreeCAD is built "with a modular software architecture which makes it easy to provide additional functionality without modifying the core system."
I am interested in adapting some of the HeeksCNC libraries to a plugin for FreeCAD. My motives are practical, I think:

1. FreeCAD's is maintained by a core group of developers already. They are very active.
2. It has python scripting built in by default. HeeksPython is great,but is broken frequently by changes to HeeksCAD itself.
3. The OS related build system is already taken care of for all desktop platforms. I don't want to deal with this at all.
4. There is an active FreeCAD forum.
5. I just want to work on CADCAM and import/export issues.

I have been working on improving the DXF import/export scripts that are already in FreeCAD and have started on a DXF to constraints/Sketcher importer. I have also started work on backplotting CNC g-code into FreeCAD:



The screenshot is from some g-code that I generated in HeeksCNC and backplotted using the HeeksCNC python scripting, adapted to FreeCAD.