Yes, it’s me again:yes:.
This time I have questions only very looseley (if at all) related 2 what the other thread was about, so I dare open up a new one.
Here’s the story:
I have set up an EnumProp (on scene level) which is being drawn (as popup-menu) into a panel. Now the update-function thereof is meant to cause changes to what else is displayed in said panel.
More preciseley spoken, the panel’s draw-function is meant to display one out of 16 existing custom FloatProps of an armature, depending on which of the 16 options was chosen in the popup-menu.
The puropse of all this is basically as follows:
[1.]User chooses one out of 16 options. ->
[2.]EnumProp’s update-function shows corresponding mesh (out of 16 choosable ones) & hides all other 15.->
[3.]Panel shows corresponding custom FloatProp of an armature beneath the popup-menu->
[4.]User changes value of the currently displayed custom FloatProp (see [3.])->
[5.]Custom FloatProp changes rendering opacity of shown mesh (see [2.]) via driver
And before you ask, no, I can’t just use the same custom FloatProp 4 all 16 drivers.
The whole UI described will eventually appear twice and is meant to facilitate crossfades between 2 out of said 16 meshes. So if both meshes’ drivers were using the same FloatProp, they couldn’t fade one out while fading the other in. Well, technically, they could, if one of 'em used the “scripted expression”-setting with sth. like “1 - var” put in there.
The real issue is though, it’s simply not predefined from which mesh 2 which other mesh such crossfade would occur.
Hope I explained this in an understandable way.
So, 2 come back 2 the realm of scripting:
Steps [1.] and [2.] as seen above work out fine (thx again 2 CoDEmanX 4 helping me out on that one already).
But I failed to make the EnumProp’s update-function 2 properly tell the draw-function inside the panel-class, which custom FloatProp of that Armature 2 draw.
What I tried was this:
Declare a global, empty string variable in the beginning, like so:
#blabla...
opacity_key_1 = ""
#blabla...
Then inside said EnumProp’s update-function, this var gets assigned the snippet which identifies the needed custom FloatProp of that armature, like so (the 2nd line after the if-statement):
#blabla...
def update_mouth_key_1_options(self, context):
hide=True
obs2hide=mesh_mouth_all
hideObjects(context, obs2hide, hide)
hide=False
if self.mouth_key_1_options == '1':
obs2hide=mesh_mouth_agonizing
opacity_key_1="\'[\"Opacity Agonizing\"]\'"
print("opacity_key_1 = %s"%(opacity_key_1))
#etc., blabla...
The print-comand tells me, it’s working as expected till there. But seems like I can’t just put in the variable as argument inside my draw-function, like so (last line before the placeholder-comment):
#blabla...
class VIEW3D_PT_face_extras_mouth(bpy.types.Panel):
bl_idname="view3d.face_extras_mouth"
bl_label = "Face Extras: Mouth"
bl_space_type="VIEW_3D"
bl_region_type="UI"
def draw(self,context):
layout=self.layout
sce = context.scene
fem = sce.face_extras_mouth
cop = bpy.data.objects["[Head|Face|Mouth|Cheeks]"]
arm = bpy.data.armatures["Armature"]
ok1 = opacity_key_1
layout.label("Mouthkey 1:")
box = layout.box()
box.prop(fem, 'mouth_key_1_options', text="")
box.prop(arm, "%s"%(opacity_key_1), text="")
#blabla...
It won’t work if I repalce the last line with
box.prop(arm, opacity_key_1, text="")
neither.
I guess it was a naive idea altogether to store this into a string variable and try to use that inside the draw-function (even though it seems 2 be but a string, if I typed it in manually).
So how 2 make this work? Do I need a PointerProp here? - If so, how do I set this up correctly? Wouldn’t even know which type that’d have 2 be.
Do I need something altogether different?
Or am I just missing the obvious here?
Thank you for having enough patience with me 2 even read this far. Any help would be much appreciated, I doubt I’ll get this figured out by myself (though I promise, I’ll try).
greetings & thx in advance,
Kologe