1
$\begingroup$

The Data Transfer modifier offers multiple enum properties which in the interface can be changed with clicking (exclusively sets one value and disables the others) or shift-clicking/dragging (allows to set multiple values).

Data Transfer Modifier Example 1

This behaviour not only affects each of these enum properties on their own, but also reaches across all the other properties, unsetting previously set values in property A if values in set B are set. (To illustrate this, the next image shows the state of the modifier from the previous image after clicking on "UVs" - the values "Sharp" and "UV Seam" are unset in the other enum property)

enter image description here

In the interface, setting multiple values in multiple enum properties is possible through shift-clicking across them, but when scripting the same behaviour I run into a problem:

obj.modifiers["DataTransfer"].data_types_loops_uv = {"UV"}

... does what one expects, and so does - mind the different property being set here (!) ...

obj.modifiers["DataTransfer"].data_types_edges = {"SHARP_EDGE"}

... but the second line also removes the previously set "UV" value on the previous property (!) ...

Lacking shift-click in a script :) and not knowing of a way to set both data_types_loops_uv and data_types_edges in one assignment (and rather wanting to avoid working with multiple DataTransfer modifiers for each property) I am now stuck and would appreciate any help!

$\endgroup$
  • 1
    $\begingroup$ The term 'radio' is generally not used and instead 'enum' is used for this type of UI element. It may be better to replace the word 'radio' with 'enum' in your question. $\endgroup$ – Ray Mairlot Oct 2 '15 at 15:30
  • $\begingroup$ Thanks @RayMairlot, I was in fact unsure how to call it and went for interface design lingo :) sounds more like a blender question now that i edited everything! $\endgroup$ – Simon Repp Oct 2 '15 at 20:43
  • 2
    $\begingroup$ Given the discrepancy between setting the enums with code and UI, this could be bugreportworthy, which if anything will clarify the situation. $\endgroup$ – batFINGER Oct 10 '15 at 15:33
  • $\begingroup$ I'll maybe wait some more (maybe someone who has touched the internals of this will add something), but in any case this is a valuable hint, thanks - I'll go with it if nothing else turns up. (and maybe I'll discuss it with one of the core devs either way :)) $\endgroup$ – Simon Repp Oct 11 '15 at 18:58
  • $\begingroup$ I just opened a bug report for this: developer.blender.org/T46522 $\endgroup$ – Simon Repp Oct 17 '15 at 19:56
1
$\begingroup$

The problem is data_types_edges as well as the other data transfer attributes are python set objects and you are overwriting the entire set losing the previous values.

To add an element to a set, us the |= operator.

import bpy

data_transfer = bpy.context.object.modifiers["DataTransfer"]

data_transfer.data_types_edges |= {'SHARP_EDGE'}

It seems that the add() and update() function do not affect the modifier; so just use |= instead.

$\endgroup$
  • $\begingroup$ The hassle is that running your code above will add ok to the data_type_edges enum selection, but will clear any selections in the other types, (verts, loops, polys). eg append data_transfer.data_types_verts_vgroup |= {'VGROUP_WEIGHTS'} to your script $\endgroup$ – batFINGER Oct 10 '15 at 18:17
  • $\begingroup$ There was another answer like this already (which was deleted by the author) ... like batFINGER already says (and like it says in the title of the question), this is not about modifying a single property, but multiple ones, that somehow, unexpectedly alter each other under the hood. I did yet another edit to my question now to point this out even more clearly. :) $\endgroup$ – Simon Repp Oct 11 '15 at 18:56
0
$\begingroup$

Confirmed as a bug here https://developer.blender.org/T46522, Bastien Montagne is already on it with full dedication. Amazing :)

Case closed.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.