BlenderBoi / Game_Rig_Tools

GNU General Public License v3.0
20 stars 4 forks source link

Added Bone Extraction Mode: Expression #3

Open emil-dietrich opened 1 year ago

emil-dietrich commented 1 year ago

Each bone is extracted if the expression returns True. Each bone is accessible in the expression by the var bone.

BlenderBoi commented 1 year ago

Interesting contribution! I will take some time to review the code and test the feature, hopefully it will be a good addition to Game Rig Tools

emil-dietrich commented 1 year ago

For the last commit a8414a8 before: image after: image

xx was what I entered in the input field

BlenderBoi commented 12 months ago

I will need some time to check if this is safe

eval seems to have some security risk, I will need some time to research if this is ok to add

emil-dietrich commented 11 months ago

If there is a security risk its that you can use python within blender. Everyone can open a text file in blender and press execute. To add to it: Only one variable is accessible by the expression and that is bone. If you have open questions or if theres something unclear you can also ask here. You don't need to investigate alone.

Blender also uses expressions for drivers. They evaluate the python code from C++, but that does not really matter. https://github.com/blender/blender/blob/01a2bd03695f217616acc2581fe8746f5cd226d7/source/blender/python/intern/bpy_driver.cc#L573

BlenderBoi commented 11 months ago

Fair Point, I will do some testing and if it works will I will merge it

emil-dietrich commented 11 months ago

Dont merge what you dont understand. Dont feel pressured to add this before you are comfortable with the changes.

emil-dietrich commented 11 months ago

Sry, for another addition: rigify also dynamically executes python code, see finalize_script property. It calls it as follows (in generate.py:594): exec(finalize_script.as_string(), {})

(You can see where rigify is located on your hard drive if you go to the preferences -> addons -> rigify -> File: ...)

exec and eval are basically the same, but eval returns a value and exec does not.

The above still applies - if you dont feel comfortable with the change im fine with that.

BlenderBoi commented 11 months ago

I think it would be a good addition, I will merge it, but I will take some time to study it