Unable to call Edge Flow from another add-on
Neltulz opened this issue · 10 comments
Hi, I'm trying to write my own add-on that utilizes your "Edge Flow" addon for blender, and I'm running into issues.
Whenever I try to run:
bpy.ops.mesh.set_edge_flow(tension=180, iterations=1)
from my own blender Addon script,
I get this error:
Error: Traceback (most recent call last): File "C:\Users\Neil Moore\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\EdgeFlow\op_set_edge_flow.py", line 93, in execute self.revert() File "C:\Users\Neil Moore\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\EdgeFlow\op_set_edge_flow.py", line 19, in revert for obj in self.objects: File "c:\Program Files\Blender Foundation\Blender\2.80\scripts\modules\bpy_types.py", line 674, in __getattribute__ return super().__getattribute__(attr) AttributeError: 'SetEdgeFlowOP' object has no attribute 'objects'
So, I tried this instead:
bpy.ops.mesh.set_edge_flow("INVOKE_DEFAULT")
<-- This works
However, I lose the ability to set any of the parameters. So, I tried this:
bpy.ops.mesh.set_edge_flow("INVOKE_DEFAULT", tension=-500, iterations=1)
Unfortunately, setting the parameter of "tension" to "-500" simply changes nothing. The parameters appears to be ignored, and default values are chosen.
It would be nice if I could use the edge flow script in my own addon. I'm trying to automate the creation of "loop cuts" and then simultaneously apply edge flow. The addon will be free, and would simply be a companion addon. In other words, I do not want to redistribute your addon with my addon, I simply wish to be able to call the command, and if the addon exists in the user's addons folder, the edge flow will be applied to the selected edges. I will of course, provide credit! :)
Any help would be greatly appreciated!
mhh interessting - I think the problem might be that I assume this is always called via invoke first, while it appears that if its called via the api it directely calls execute... just a first guess tho.
gotta read into this topic again.
mhh interessting - I think the problem might be that I assume this is always called via invoke first, while it appears that if its called via the api it directely calls execute... just a first guess tho.
gotta read into this topic again.
Hi, thanks for your quick response! :)
I believe I have a solution, thanks to a very helpful person in the Blender Discord #help-coding channel. If you open the op_set_edge_flow.py
file, and scroll down to line 109, you have self.tension
, self.iterations
, and self.bias
specified there. Simply commenting out or removing these 3 lines allows me to use the command like this:
bpy.ops.mesh.set_edge_flow("INVOKE_DEFAULT", tension=180, iterations=32)
If you could remove those 3 lines, and release an update to the edge flow addon, I would be able to use your addon with my addon. :)
well - these lines are intentionally added. It makes sure that the opertor always starts with the default values. As I found it not usefull that blender remembers what values where used the last time the operator is run - well at least in this case, often this behaviour is desired. Maybe there is a side effect free alternative..
I changed some stuff to allow for a bpy.ops call you can give it a try.
Hi, thanks for the update! I have downloaded the files, and installed the addon.
I'm trying to run this command:
bpy.ops.mesh.set_edge_flow(tension=scene.neltulzSubDEdge.tension, iterations=scene.neltulzSubDEdge.numIterations, min_angle=scene.neltulzSubDEdge.minAngle)
The parameters are being set by my custom property group. It doesn't appear to be working.
It doesn't appear to be accepting my variables. I printed my variables to console to confirm they are being set properly, so, I'm not really 100% sure why it's not working.
If you would like to experiment on your end, you can simply use a "loop cut" to insert (for example) 8 edge loops, then while those edge loops are still selected, run the bpy.ops.mesh.set_edge_flow.....
command with some parameters.
hey, it was a bit late when i pushed the last version, so I missed something obvious. So please retry the newest version..
Awesome! Everything seems to be working great! If you could push this as a release, I would be able to instruct others to download the latest version of EdgeFlow before using my Addon from the Release section of this github repo! :)
Thank you for updating the addon with these bug fixes. My only request for the future would be to keep the same property names, and addon operator name so that future versions of EdgeFlow do not break my addon. I will be sure to credit you with my addon as well! :)
The last release with tag 04 (https://github.com/BenjaminSauder/EdgeFlow/releases) should already be up to date.
Oh, okay. I misread the Github page. Thanks! You may close this issue now!
done :)