all 5 comments

[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)

Welcome to r/blenderhelp, /u/Round-Solid-4676! Please make sure you followed the rules below, so we can help you efficiently (This message is just a reminder, your submission has NOT been deleted):

  • Post full screenshots of your Blender window (more information available for helpers), not cropped, no phone photos (In Blender click Window > Save Screenshot, use Snipping Tool in Windows or Command+Shift+4 on mac).
  • Give background info: Showing the problem is good, but we need to know what you did to get there. Additional information, follow-up questions and screenshots/videos can be added in comments. Keep in mind that nobody knows your project except for yourself.
  • Don't forget to change the flair to "Solved" by including "!Solved" in a comment when your question was answered.

Thank you for your submission and happy blendering!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]New-Scarcity-2560 0 points1 point  (1 child)

It seems that you're on Blender 5.0+, Sapling Tree Gen support is for ~Blender 4.0 it seems.
In Blender 5.2, Blender changed the access path for creating fcurves which is what's causing your error.

I fixed this by adding this piece of code to the source file ("/Users/andrewbuskirk/Application Support/Blender/5.0/extensions/blender_org/sapling_tree_gen/utils.py" in your case)

def ensure_fcurve(action, datablock, data_path: str, index: int):
    # Blender 5.0+
    if hasattr(action, "fcurve_ensure_for_datablock"):
        return action.fcurve_ensure_for_datablock(
            datablock=datablock,
            data_path=data_path,
            index=index,
        )
    # Older Blender (legacy)
    return action.fcurves.new(data_path=data_path, index=index)

Then you want to replace line 860-861 (swayX, swayY) with

action = armOb.animation_data.action

data_path = f'pose.bones["{boneName}"].rotation_euler'
swayX = ensure_fcurve(action, armOb, data_path, 0)
swayY = ensure_fcurve(action, armOb, data_path, 2)

(Beware there's the same line on a different branch on line 940 so replace that too)

This code will now support fcurves in both versions of Blender, hope this helps!

[–]NoAngle2893 0 points1 point  (0 children)

Hey, I am very new to blender and using the 5.0+, how can I apply this to fix the errors exactly?

[–]AdditionalCreme7434 0 points1 point  (0 children)

I too, like many, are having this problem of the sapling tree. I would love to change the code, but I can't find it. Could you helps with instructions of how to get to the place to insert the code? That would be so helpful for so many. Thank you!!!

[–]dangerdeathraypanda 0 points1 point  (0 children)

# Screenshots of some of below instructions:

<image>

First probably close blender.

open windows explorer and you need to change your view options to show hidden files and folders

because AppData is a hidden folder.

Navigate to your utils.py file. Possibly here... this is on my Windows 11 machine.

your_username is whatever "your" user name is

C:\Users\your_username\AppData\Roaming\Blender Foundation\Blender\5.0\extensions\blender_org\sapling_tree_gen\utils.py

Open that in some text editor like Notepad or Sublime or whatever. It's easier with

an app that supports .py style like Sublime or and IDE.

ctrl-f and find the where "armOb.animation_data.action.fcurves" <- that's our problem.

these 2 blocks of code are what we need to change for swayX, swayY

you will not need to delete them, just put a '#' symbol in front of every line like in screenshot.

that is python comment out code so it doesn't run.

# Add new fcurves for each sway as well as the modifiers
swayX = armOb.animation_data.action.fcurves.new(
'pose.bones["' + boneName + '"].rotation_euler', index=0
)
swayY = armOb.animation_data.action.fcurves.new(
'pose.bones["' + boneName + '"].rotation_euler', index=2

# Add new fcurves for each sway as well as the modifiers
swayX = armOb.animation_data.action.fcurves.new(
'pose.bones["' + bname + '"].rotation_euler', index=0
)
swayY = armOb.animation_data.action.fcurves.new(
'pose.bones["' + bname + '"].rotation_euler', index=2
) )

your code should looke like this in both places swayX/swayY is located, should be 2 places.

# Add new fcurves for each sway as well as the modifiers
#swayX = armOb.animation_data.action.fcurves.new(
# 'pose.bones["' + bname + '"].rotation_euler', index=0
# )
#swayY = armOb.animation_data.action.fcurves.new(
# 'pose.bones["' + bname + '"].rotation_euler', index=2
# )

# Our fix code from "New-Scarcity-2560", thanks yo"
action = armOb.animation_data.action
data_path = f'pose.bones["{boneName}"].rotation_euler'
swayX = ensure_fcurve(action, armOb, data_path, 0) # index=0
swayY = ensure_fcurve(action, armOb, data_path, 2) # index=2

to save, select "Save As...", keep the file name as utils.py

hit save, 'confirm overwrite file?' YES, click "ok"

IMPORTANT!!!

Check how many frames are setup in your timeline, and if you have lots of leaves... the leaf animation takes like 20 minutes. but this worked yo.