I'm trying to create a Sapling Tree object using Python. The Sapling Tree is an object that comes from this add-on: https://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Curve/Sapling_Tree
I'm able to create it using the UI (Add > Curve > Sapling Tree Gen). I can see the command executed by the UI in the Info window. That command is:
bpy.ops.curve.tree_add(do_update=True, bevel=False, prune=False, showLeaves=False, useArm=False, seed=0, handleType='0', levels=2, length=(1, 0.3, 0.6, 0.45), lengthV=(0, 0, 0, 0), taperCrown=0, branches=(0, 50, 30, 10), curveRes=(8, 5, 3, 1), curve=(0, -40, -40, 0), curveV=(20, 50, 75, 0), curveBack=(0, 0, 0, 0), baseSplits=0, segSplits=(0, 0, 0, 0), splitByLen=True, rMode='rotate', splitAngle=(0, 0, 0, 0), splitAngleV=(0, 0, 0, 0), scale=13, scaleV=3, attractUp=(0, 0, 0.5, 0.5), attractOut=(0, 0, 0, 0), shape='7', shapeS='4', customShape=(0.5, 1, 0.3, 0.5), branchDist=1, nrings=0, baseSize=0.4, baseSize_s=0.25, splitHeight=0.2, splitBias=0, ratio=0.015, minRadius=0.0015, closeTip=False, rootFlare=1, autoTaper=True, taper=(1, 1, 1, 1), radiusTweak=(1, 1, 1, 1), ratioPower=1.1, downAngle=(90, 110, 45, 45), downAngleV=(0, 80, 10, 10), useOldDownAngle=False, useParentAngle=True, rotate=(99.5, 137.5, 137.5, 137.5), rotateV=(15, 0, 0, 0), scale0=1, scaleV0=0.1, pruneWidth=0.4, pruneBase=0.3, pruneWidthPeak=0.6, prunePowerHigh=0.5, prunePowerLow=0.001, pruneRatio=1, leaves=25, leafDownAngle=45, leafDownAngleV=10, leafRotate=137.5, leafRotateV=0, leafScale=0.17, leafScaleX=1, leafScaleT=0, leafScaleV=0, leafShape='hex', leafangle=0, horzLeaves=True, leafDist='6', bevelRes=0, resU=4, armAnim=False, previewArm=False, leafAnim=False, frameRate=1, loopFrames=0, wind=1, gust=1, gustF=0.075, af1=1, af2=1, af3=4, makeMesh=False, armLevels=2, boneStep=(1, 1, 1, 1))
But, when I copy and paste that command into the Python Console and run it, I get this error:
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
File "C:\Program Files\Blender Foundation\Blender\2.78\scripts\modules\bpy\ops.py", line 189, in __call__
ret = op_call(self.idname_py(), None, kw)
RuntimeError: Error: Traceback (most recent call last):
File "C:\Program Files\Blender Foundation\Blender\2.78\scripts\addons\add_curve_sapling\__init__.py", line 911, in execute
addTree(self)
File "C:\Program Files\Blender Foundation\Blender\2.78\scripts\addons\add_curve_sapling\utils.py", line 1424, in addTree
bend = props.bend#
File "C:\Program Files\Blender Foundation\Blender\2.78\scripts\modules\bpy_types.py", line 605, in __getattribute__
return super().__getattribute__(attr)
AttributeError: 'AddTree' object has no attribute 'bend'
location: C:\Program Files\Blender Foundation\Blender\2.78\scripts\modules\bpy\ops.py:189
I am able to copy and paste the UI command for creating a native object (i.e. a bezier curve), and that works just fine. I'm not sure whether this error has to do the Sapling Tree specifically, or applies to all add-on objects.
I understand that using bpy.ops
commands are notoriously finicky, but I cannot find any other method to create the Sapling Tree since it isn't a native object.
I am running Blender 2.78 64-bit on Windows 10.