2
$\begingroup$

I am writing a Blender Add-on which takes properties from configuration file and generates a tree based on the customization. The Add-On allows tweaking of certain properties, most notably whether the tree is monopodial (one canopy) or sympodial (multiple canopies).

If the tree is sympodial, I want the user to be able to select how many canopies are present in the Add-On. If the tree is monopodial, I want the fields to either be hidden or greyed out/locked for editing.

I've tried something like

row = box.row()
row.prop(scn, "Tree_Form")
if (tree_form == "Sympodial")
    row = box.row()
    row.prop(scn, "Num_Canopies")

But I haven't had success. Admittedly, I am a complete novice to Python and Blender Add-Ons in general.

$\endgroup$
  • $\begingroup$ Based on guesswork re your code snippet, you want something like if(scn.Tree_Form == "Sympodial"): Don't forget the colon after the if statement. $\endgroup$ – batFINGER Nov 2 '15 at 18:01
2
$\begingroup$

Try this:

row = box.row()
row.prop(scn, "Tree_Form")
if scn.Tree_Form == "Sympodial": # the ':' is required
    row = box.row()
    row.prop(scn, "Num_Canopies")
$\endgroup$
  • $\begingroup$ Wow. How did I not look to see that I needed a colon at the end? Thanks so much! $\endgroup$ – Colin Nov 2 '15 at 20:25
  • $\begingroup$ I myself, was stuck on .props and such. $\endgroup$ – Andrew Mast Nov 2 '15 at 20:29

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.