Thanks for the quick reply!
I think that a block that would extremely useful to us (and also to many of your customers) is a simple variation of the function block you already have.
The new block might be called “Python Function” and it might work like this:
- When you create the function in studio, you can pick “Create Python Function” for example.
- What happens next is you get a block very similar to the normal function block. I.e. it asks you the name and creates a block. Like the normal function block, you have fields for function name and the flyout for function parameters - no change so far.
- The difference is that this new block does not accept docking with blockly commands - instead it has a single blockly “multi-line field” in which the user can type python code. Something like this:
When blockly generates the code for this block, the block’s python code would get inserted “as-is” into a function in a way very like what it does with normal functions now. In other words, the code generated might be something like this:
#Define Mydef class
def __init__(self, *args, **kwargs):
def function_1(cls, r):
# NOTE: code below was provided by the user through
# a Python function block
# calculate area of circle
area = math.pi * r * r
# End of user code
That’s it! Or something similar.
What’s great about this for us is that we can create a “library” of small Blockly functions in Python to do things that XArm Studio does not currently support and our operators can just use those Blockly functions without having to learn Python.
You should probably stress that this block is for advanced users only – code is inserted into the Python file “as is”. It is up to the user to make sure they don’t “break” anything.
Thank you for considering my request! I think this block can benefit many users!
Applied Anodize, Inc.
PS If you go ahead and do something like this, it occurred to me that XArm studio does not appear to be able to create “string” values so they can be passed to functions. This should be very easy to implement and would be necessary to make this “Python Function” block fully useful.