Tuesday 29 April 2014

FreeCAD: Work-Features Faster Than Expected

(Update, work-features release 1 here)
A brief post to show the current state of the work-features implementation:


Things have gone faster than expected, but there remains a lot of work to do.

What do you think about the feature?


Greetings!

Monday 28 April 2014

FreeCAD: Work-Features, Origin

After working a bit more in the work-points script I realized that is obligatory to have origin work-features, as origin of coordinates point, X, Y, Z axis, XY, XZ and YZ planes.

A screenshot to clarify:



The colors of the axis are to distinguish them, and the origin work-planes colors are different from the future user-created work-plane colors. 

Everything is ordered in the tree-view by name and invisible by default:




I'm trying to figure how to use Github, I think I have posted the code here

To use it, with a part or new document opened, copy-paste the code, that's all. 


Bye!


Sunday 27 April 2014

FreeCAD: Work Points

Sometimes when using the FreeCAD part-design workbench I feel the need of placing a sketch in a position that can't be achieved with the current sketch placing options.
I haven't seen any object similar to work-points, work-axis, work-planes... in FreeCAD, but I'm used to them in Autodesk Inventor.

I'm trying (from time to time) to implement this functionality in FreeCAD, and this is the first post about it.

The idea is that work-points and work-axis serve to determine the position of a work-plane, and a work-plane serves to place a sketch.

For example with tree points, or one point and an axis, or two axis, we can place a work-plane, then a sketch on it and later build more complex things easily and faster.

These work-objects can be created from existing objects or added as new objects.

Let's start with something very basic:

Workpoints: Midpoint


A midpoint is a point in the middle of a line, a vertex in FreeCAD.

At the moment this can be used as a macro, but without the ability to create work-planes, it is useless.


# -*- coding: utf-8 -*-
import Part
from FreeCAD import Console

try:
  MouseSel = Gui.Selection.getSelectionEx() #Gets Current Mouse Selection
  for s in range(len(MouseSel)):                          # Explores the objects selected
    Sel = MouseSel[s]
    Edge_List = Sel.SubObjects   # Retrieves the edge list of the current object

    for i in range(len(Edge_List)):   # For every edge in the list
      Vector_A=Edge_List[i].valueAt(0.0)  # initial point of the edge
      Vector_B=Edge_List[i].valueAt(Edge_List[i].Length)  # endpoint of the edge
      
      Vector_MidPoint = Vector_B+Vector_A
      Vector_MidPoint = Vector_MidPoint.multiply(0.5)
      
      MidPoint_Vertex = Part.Vertex(Vector_MidPoint)  #Creates the point
      
      #this conditional creates a folder that will contain all workpoints
      if not(App.ActiveDocument.getObject("WorkPoints")):
        App.ActiveDocument.addObject("App::DocumentObjectGroup","WorkPoints")
      
      
      name = "Midpoint" #name of the feature we are going to add to FreeCAD
      MidPoint = App.ActiveDocument.addObject("Part::Feature",name) #add the feature
      MidPoint.Shape = MidPoint_Vertex #links feature with the point created in the block above
      MidPoint = App.ActiveDocument.getObject("WorkPoints").addObject(MidPoint) 
      #moves everything to the folder "Workpoints"

except: #Something funny happened
  Console.PrintError("Select only edges")



This is how it works:

Create something or open a file with some shape at it, like this one:


Select some random edges (non circular):


Copy-paste the code above at the python terminal of FreeCAD.

Result:


And in the tree-view, all points have been place inside the "WorkPoints" folder:



And this is all it does. 

The next work-point feature will be the center of a circular edge. 

I need to improve things, for example, move the folder "workpoints" to the top of the tree-view (I have found absolutely nothing about that), create a new feature called workpoint, with its own symbol in the tree-view and predetermined colors for beter visibility, and more... 

Greetings!

Sunday 13 April 2014

Another crappy machine

I have been out of the blog for a while because I'm busy with other projects, but I think that I can show here this one, about parallel port, python and floppy drives:




My conclusion is that stepper motors (from floppy and DVD drives) haven't enough torque to do anything useful, because the will simply jump several steps when applied a bit of load.

It has been a good exercise about machine control, I was trying to slice a part on FreeCAD, get the trajectories and then carve foam with this machine, but I do not have time to continue with this at the moment.

I will post here a bit about programming this things using python.


Bye!