API Documentation: convert_custom_morphs_to_shapekeys and convert_standard_morphs_to_shapekeys seem to be missing/replaced

Issue #930 resolved
schema created an issue

I was trying to convert all morphs of an object into shape keys (works perfectly via UI). Looking at the latest API Documentation at https://diffeomorphic.blogspot.com/p/daz-importer-operators-version-16.html

I found both convert_custom_morphs_to_shapekeys and convert_standard_morphs_to_shapekeys

After looking into the source, it seems the operations have been replaced with convert_morphs_to_shapekeys.

However, I can’t seem to get this operation working. I’ve been using it like

import_daz.set_selection(["MeshObjectToConvert"])
bpy.ops.daz.convert_morphs_to_shapekeys()

which doesn’t do anything as expected, as it is missing a GeneralSelector

I’m not sure how to provide one without UI or if that operation was even meant to be used this way.

Is it possible in 1.6 to convert all morphs to shape keys via script?


It looks like convert_morphs_to_shapekeys would need some arguments to be called from via API to be able to select morphs manually.

Comments (10)

  1. Luke Graybill

    I haven’t used that operator myself, but based on how import_daz.set_selection seems to be used for other operators, it probably needs to take a list of the shapekey names you want to convert (as opposed to the mesh name as in your example.)

    Although, take what I say with a large grain of salt, I’m still pretty new to blender scripting (and even newer to using this addon API!)

  2. schema reporter

    I’m in the same boat as you and pretty new to blender scripting.

    I tried to submit an array of strings, but the method gives me a runtimes error if I do. From looking at the source and comparing it with an operation that takes arguments, it doesn’t seem like this one takes any.

    Maybe settings the Selector is something that’s not an argument, but similar as set_selection

  3. schema reporter

    Reading more, it seems like the class of the operation is inheriting from GeneralMorphSelect/Selector, and I’m starting to understand how the blender API calls these from UI.

    The only way I got it to work for now is to hack together my own operation that executes part of the UI setup of the MorphSelector (collecting the morphs, and then selecting them). This is of course not a solution to the problem.

    I’m now pretty sure for this functionality to be used in the API, it would need a suitable API operation that takes arguments and does the selection from there.

  4. Thomas Larsson repo owner

    bpy.ops.daz.convert_morphs_to_shapekeys(morphset = '', category = '')

    Convert face rig morphs to shapekeys

    Parameters:
       Use import_daz.setSelection(list_of_selection) to specify input selection.

    • morphset (enum in []) - Type
    • category (enum in []) - Category

  5. Thomas Larsson repo owner

    It turned out it wasn’t so easy to set the selection in this case. In the last commit, the operator behaves differently when called from the panel and from a script: when called from a script all available morphs are converted. So you loose the possibility to select morphs to be converted from a script, but perhaps you don’t need a selection in this case. Anyway, it’s a limitation.

  6. schema reporter

    Thank you. This works for me.

    In case I would have to select less than every morph, this solution should be possible to use as well. I’d probably just copy the mesh, and remove the morphs I wouldn’t want to convert. After that, the converted shape keys could be transferred to the original mesh.

  7. schema reporter

    API has been updated with the new function.

    Latest commit makes it possible to use convert_morphs_to_shapekeys, though with the limitation that all morphs are converted.

  8. Log in to comment