What is the meaning of "Placement" in path operations?

Here's the place for discussion related to CAM/CNC and the development of the Path module.
nahshon
Posts: 135
Joined: Wed Jul 24, 2013 8:06 pm

What is the meaning of "Placement" in path operations?

Postby nahshon » Sat Nov 19, 2016 2:47 pm

I'm confused. Should a path element have a "Placement" and how is it used?

I see that a Job really creates paths twice. It looks like each operation creates own path, which is affected by the placement. The "Job" creates a combined path that is not affected by placements.
(Is this duplication needed?)

If we look at PathJob.py, function execute:

Code: Select all

                if obj.UsePlacements:
                    for c in child.Path.Commands:
                        cmds.append(c.transform(child.Placement))
                else:
                    cmds.extend(child.Path.Commands)

but I could not find where obj.UsePlacements could be modified.
There is similar code in PathCompoundExtended.py.
FeaturePathCompound.cpp actually has a property for UsePlacements.
Untitled.png
Untitled.png (144.45 KiB) Viewed 792 times
nahshon
Posts: 135
Joined: Wed Jul 24, 2013 8:06 pm

Re: What is the meaning of "Placement" in path operations?

Postby nahshon » Sat Nov 19, 2016 4:12 pm

Also, the Position of the Body is ignored. IMHO this is a bug as there is no way to create a path that is related to a rotated shape. I will open a bug in the tracker after I understand what is the correct behavior.
Untitled1.png
Untitled1.png (75.59 KiB) Viewed 781 times
Attachments
Shape2.fcstd
(18.66 KiB) Downloaded 8 times
sliptonic
Posts: 621
Joined: Tue Oct 25, 2011 10:46 pm

Re: What is the meaning of "Placement" in path operations?

Postby sliptonic » Sat Nov 19, 2016 4:21 pm

A quick overview of the Path objects:
In C++ we have:
Command: which holds a single command with its parameters
Path: holds a list of commands.
(Also tools and tooltables but that's not relevant here.)

The user is interacting with the Python Feature objects which are:
Path Feature: A document object that holds a Path and takes care of drawing it.
Path Compound: Works like a FreeCAD group and collects several Paths together.
Path Job (formerly called Path Project): A special case of Compound. Jobs are generally what you want to post-process.

The job doesn't really create the path twice but it does display it twice, once for the underlying Path and once for the group itself.

Path Placements *should* apply a transform to the path and result in shifted gcode. However, I believe this is pretty thoroughly broken at the moment.
The UsePlacement transformation was in place before v0.17 started and hasn't received any attention since. So I'm not even clear how this should work related to SuperPlacements, Bodies, Parts, etc.
nahshon
Posts: 135
Joined: Wed Jul 24, 2013 8:06 pm

Re: What is the meaning of "Placement" in path operations?

Postby nahshon » Sun Nov 20, 2016 1:58 am

sliptonic wrote:A quick overview of the Path objects:

Thanks for the review. I find it really helpful.
The job doesn't really create the path twice but it does display it twice, once for the underlying Path and once for the group itself.

If I understand it, a path is actually stored twice (in memory and in the .fcstd file). Ideally it should be kept only once in memory. Is there a reason to store a path that can be recomputed in the .fcstd file?

I think I can now explain a feature that I would like to see in FreeCAD.
Add an optional "Placement" operation that will take effect before a series of milling/drilling operations.
The meaning of the operation is that a part should be mounted in a certain placement/orientation before the following operation are processed.
The resulting path will be viewed with the reverse transformation (so it is still aligned with the body view).

If the machine has 4 or 5 axes, the "Placement" command could actually rotate the part to the requested orientation. Otherwise it may be possible to pause the CNC operation and let the user mount the part to the new position.

The (faked) image is an attempt to show a possible result of processing 6 faces, where each face has a different placement.
Untitled2.png
Untitled2.png (25.42 KiB) Viewed 756 times
mlampert
Posts: 292
Joined: Fri Sep 16, 2016 9:28 pm

Re: What is the meaning of "Placement" in path operations?

Postby mlampert » Sun Nov 20, 2016 7:30 am

nahshon wrote:I think I can now explain a feature that I would like to see in FreeCAD.
Add an optional "Placement" operation that will take effect before a series of milling/drilling operations.
The meaning of the operation is that a part should be mounted in a certain placement/orientation before the following operation are processed.
The resulting path will be viewed with the reverse transformation (so it is still aligned with the body view).

Would the same be achieved if you could place and orient the part itself before you create the Job and it's Paths?

In a similar vain, let's say, you had the possibility to move and rotate the Part - and you could place the origin (0,0,0) anywhere you want. Would you still require a placement of an individual Path?
nahshon
Posts: 135
Joined: Wed Jul 24, 2013 8:06 pm

Re: What is the meaning of "Placement" in path operations?

Postby nahshon » Sun Nov 20, 2016 1:22 pm

mlampert wrote:
nahshon wrote:I think I can now explain a feature that I would like to see in FreeCAD.
Add an optional "Placement" operation that will take effect before a series of milling/drilling operations.
The meaning of the operation is that a part should be mounted in a certain placement/orientation before the following operation are processed.
The resulting path will be viewed with the reverse transformation (so it is still aligned with the body view).

Would the same be achieved if you could place and orient the part itself before you create the Job and it's Paths?

In a similar vain, let's say, you had the possibility to move and rotate the Part - and you could place the origin (0,0,0) anywhere you want. Would you still require a placement of an individual Path?


It will not work now, due to a bug.

Anyway, a part can normally use multiple placements. One may be used for assembly, one or more for manufacturing, and then you may want to use a placement for packaging (which could be described as yet another assembly).
Also, remember that a part may have multiple copies in an assembly, each copy with own placement.

My idea here is to include the placement used for manufacturing as part of the job (or a compound). A simple job for a single part will use just one placement t the beginning of the job. Complex jobs may contain more than one placement, and in the future I hope this could be used for controlling rotation in multi-axis machines.
mlampert
Posts: 292
Joined: Fri Sep 16, 2016 9:28 pm

Re: What is the meaning of "Placement" in path operations?

Postby mlampert » Sun Nov 20, 2016 7:46 pm

Got that, thanks for the clarification.
If that bug was fixed and you had the ability to place a part specifically for a job - would there still be a requirement for a placement of an individual Path (also assuming that bug was fixed and it would work)?
nahshon
Posts: 135
Joined: Wed Jul 24, 2013 8:06 pm

Re: What is the meaning of "Placement" in path operations?

Postby nahshon » Mon Nov 21, 2016 5:42 pm

mlampert wrote:Got that, thanks for the clarification.
If that bug was fixed and you had the ability to place a part specifically for a job - would there still be a requirement for a placement of an individual Path (also assuming that bug was fixed and it would work)?

Assuming the bug would be fixed, it will be possible to position a part, create a job and create the gcode file, then change back to the original position of the part.

By having a placement command in the job, it will be separate from the default placement of the part, and also it will be possible to create gcode for multiple placements of the same part.
roivai
Posts: 7
Joined: Thu Feb 02, 2017 5:29 pm
Location: Oulu, Finland

Re: What is the meaning of "Placement" in path operations?

Postby roivai » Sat Feb 11, 2017 9:03 am

Hi,

I struggled with this same question as I needed to make a Path job that would cut multiple parts on a same run. I know it could be done with fixture offset etc, but I also wanted to rotate parts to allow efficient nesting on the stock. I thought it would be easily done by making a copy of a (compound) Path and then placing it with offset and rotation. But like mentioned here, the Placement only affected the view object, not the Path itself.

I wrote a method to position and rotate Path commands if anyone is interested. For now, I incorporated it to PathCopy feature only, as that was what I needed at that point. But if needed, I think it could be used more generally. It allowed me to do for example this:

pathcopy_example.png
pathcopy_example.png (55.43 KiB) Viewed 272 times


You can check the code by looking at a commit on my fork:

https://github.com/pekkaroi/FreeCAD/commit/6243ea4085cacf2c695f883d22ed9149da50bc3b

BR,
Pekka
User avatar
yorik
Site Admin
Posts: 8684
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: What is the meaning of "Placement" in path operations?

Postby yorik » Sat Feb 11, 2017 3:44 pm

The general idea behind having a placement in Path objects was:

- You can have a Path that is expressed in machine coordinates (basically in the XY plane), but that you could move around in FreeCAD (for example place it on top of the assembled object). Moving the path around should reflect in its display in FreeCAD, but should not change the gcode coordinates, because you will still want to cut the piece in the XY plane.

- Sometimes, however, you do want that moving the placement affects its stored coordinates. For example, you would want to simply copy/paste a same path object at several locations. For that, it must be encapsulated inside a Path Compound. The Path Compound has a property to turn on/off the use of its childrens placements. If on, the compound, when building its final path, will apply the placement of its children.