PathMillFace : set/change Base property (without GUI)

Here's the place for discussion related to CAM/CNC and the development of the Path module.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
cristian.a73
Posts: 41
Joined: Wed Jul 18, 2018 4:15 pm

PathMillFace : set/change Base property (without GUI)

Post by cristian.a73 »

Hi FreeCAD Forumer
In my code, in order to create a PathMillFace I do :

Code: Select all

from PathScripts import PathMillFace

objFaceMill = PathMillFace.Create("FaceMill")
objFaceMill.Base = [ ( glPartObj, ( 'Face50' ) ) ]
objFaceMill.recompute()
this work fine,,,but when I need to work on Shape.Faces[x] cannot get the face name...so

Code: Select all

	face = myShape.Faces[...]
	objFaceMill.Base = [ ( checkObj, ( face ) ) ]
doesn't work because face must be a string array (not face array)


changing the file PathMillFace.py (row 81) to

Code: Select all

if isinstance(s, str):
	sublist.append(o.Shape.getElement(s))
else:
	sublist.append(s)
and row 103

Code: Select all

if isinstance(sub, str):
	shape = getattr(b[0].Shape, sub)
else:
	shape = sub
doen't solve

Does anyone have any idea ?
Last edited by cristian.a73 on Fri Sep 28, 2018 11:15 pm, edited 1 time in total.
mlampert
Veteran
Posts: 1772
Joined: Fri Sep 16, 2016 9:28 pm

Re: PathMillFace : set/change Base property (without GUI)

Post by mlampert »

you should use PathOp.addBase(...)
User avatar
cristian.a73
Posts: 41
Joined: Wed Jul 18, 2018 4:15 pm

Re: PathMillFace : set/change Base property (without GUI)

Post by cristian.a73 »

mlampert wrote: Fri Sep 28, 2018 10:37 pm you should use PathOp.addBase(...)
ok, but doesn't solve...it still need a face name even <Part.Face>


This code work, but.... is it a best practice ?!

Code: Select all

def get_face_name(s, source_face):
    source_face_hcode = source_face.hashCode()
    for iFace in range(0, len(s.Faces)):
        fname = "Face"+str(iFace+1)
        f = None
        try:
            f = getattr(s, fname)
        except Exception as e: 
            ''' '''
        if f:
            if source_face_hcode == f.hashCode():
                return fname
    return None
mlampert
Veteran
Posts: 1772
Joined: Fri Sep 16, 2016 9:28 pm

Re: PathMillFace : set/change Base property (without GUI)

Post by mlampert »

cristian.a73 wrote: Fri Sep 28, 2018 11:25 pm
mlampert wrote: Fri Sep 28, 2018 10:37 pm you should use PathOp.addBase(...)
ok, but doesn't solve...it still need a face name even <Part.Face>
You'll always need a face name, that's how FreeCAD and its properties works. The face names are generated internally and there are some issues with determinism. If you want to know more search for "topological naming" and you'll find a lot of ... comments ... pain ... tries and failures ... it's an active field of research.

I would recommend to find the top face(s) by iterating through all faces and looking at their attributes - I presume you know which faces are eligible for face milling.
User avatar
cristian.a73
Posts: 41
Joined: Wed Jul 18, 2018 4:15 pm

Re: PathMillFace : set/change Base property (without GUI)

Post by cristian.a73 »

You'll always need a face name, that's how FreeCAD and its properties works. The face names are generated internally and there are some issues with determinism. If you want to know more search for "topological naming" and you'll find a lot of ... comments ... pain ... tries and failures ... it's an active field of research.

I would recommend to find the top face(s) by iterating through all faces and looking at their attributes - I presume you know which faces are eligible for face milling.
Yes, I know which faces to pass to Path.MillFace
If faces name is the way to code, and it's generated internally in non deterministic mode, really don't understand : why Face.Name property doesn't exist ??
Post Reply