Proposed GUI scripting support and other improvements - PR #4797

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!
eyalm
Posts: 11
Joined: Mon Dec 06, 2021 5:06 pm

Re: Proposed GUI scripting support and other improvements - PR #4797

Post by eyalm »

This is great !
Thank you much Russel.
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Proposed GUI scripting support and other improvements - PR #4797

Post by onekk »

Many Thanks Russ4262.

It works in:
OS: Artix Linux (openbox)
Word size of FreeCAD: 64-bit
Version: 0.20.26498 (Git) AppImage
Build type: Release
Branch: (HEAD detached at 1895593)
Hash: 18955931c7f0926a4cd9d2719be5a433b49ae56e
Python version: 3.9.7
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.5.3
Locale: Italian/Italy (it_IT)
As a test I create a CreateVcarve modifying methods, like you have done for CreateProfile, I checked and is working, provided all things are correct like a proper Tool:

Code: Select all

def CreateVcarve(parentJob=None):
    """Create Path Vcarve operation with GUI support, but without initial GUI interaction.
    Allow for parent job assignment at instantiation."""

    PathVcarve = PathVcarveGui.PathVcarve
    PathUtils = PathVcarve.PathOp.PathUtils
    res = PathVcarveGui.Command.res
    gitVersion = getVersion()[2]

    # print("git version: {}".format(gitVersion))

    if gitVersion > 24291:
        obj = res.objFactory(res.name, obj=None, parentJob=parentJob)
    else:
        if parentJob:
            obj = doc.addObject("Path::FeaturePython", res.name)
            doc.recompute()
            parentJob.Proxy.addOperation(obj)  # add new operation object to job object
            hold = PathUtils.addToJob
            PathUtils.addToJob = addToJob2  # Overwrite original function with improved
            obj = PathVcarve.Create(res.name, obj=obj)
            PathUtils.addToJob = hold  # restore original function
        else:
            obj = res.objFactory(res.name, obj=None)

    obj.ViewObject.Proxy = PathOpGui.ViewProvider(obj.ViewObject, res)
    obj.ViewObject.Proxy.deleteOnReject = False
    obj.ViewObject.Visibility = False
    return obj
Many thanks.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
Post Reply