From 98e93d329f259ca29f3ca5592268b01cddc15bff Mon Sep 17 00:00:00 2001 From: Markus Lampert Date: Fri, 21 Oct 2016 16:27:28 -0700 Subject: [PATCH] Added reloading of post processor to pick up user changes in the script in case they edited it. --- src/Mod/Path/PathScripts/PathJob.py | 6 ++++++ src/Mod/Path/PathScripts/PathPost.py | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Mod/Path/PathScripts/PathJob.py b/src/Mod/Path/PathScripts/PathJob.py index a59d9de37..d699d719e 100644 --- a/src/Mod/Path/PathScripts/PathJob.py +++ b/src/Mod/Path/PathScripts/PathJob.py @@ -115,6 +115,12 @@ class ObjectPathJob: postname = obj.PostProcessor + "_post" exec "import %s as current_post" % postname + # make sure the script is reloaded if it was previously loaded + # should the script have been imported for the first time above + # then the initialization code of the script gets executed twice + # resulting in 2 load messages if the script outputs one of those. + exec "reload(%s)" % 'current_post' + if hasattr(current_post, "UNITS"): if current_post.UNITS == "G21": obj.MachineUnits = "Metric" diff --git a/src/Mod/Path/PathScripts/PathPost.py b/src/Mod/Path/PathScripts/PathPost.py index 0d1fd1d25..ad11a4743 100644 --- a/src/Mod/Path/PathScripts/PathPost.py +++ b/src/Mod/Path/PathScripts/PathPost.py @@ -95,7 +95,10 @@ class CommandPathPost: postArgs = postobj.PostProcessorArgs postname += "_post" - exec "import %s as current_post" % postname + try: + current_post + except NameError: + exec "import %s as current_post" % postname reload(current_post) current_post.export(obj, filename, postArgs)