3
$\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$
1
  • $\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, 2015 at 18:01

1 Answer 1

3
$\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$
2
  • $\begingroup$ Wow. How did I not look to see that I needed a colon at the end? Thanks so much! $\endgroup$
    – Colin
    Nov 2, 2015 at 20:25
  • $\begingroup$ I myself, was stuck on .props and such. $\endgroup$ Nov 2, 2015 at 20:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .