最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Blender gives a `NameError` error when calling get_strokes() - Stack Overflow

programmeradmin0浏览0评论

I'm currently working on an addon for Blender that turns the camera view into an SVG. There's this error that shows up when I try calling get_strokes()

File "d:\Blender builds\Blender 4.2.1\4.2\scripts\freestyle\modules\freestyle\utils.py", line 95, in get_strokes
    return tuple(map(Operators().get_stroke_from_index, range(Operators().get_strokes_size())))
 
NameError: name 'Operators' is not defined

This function exists in Blender's api. It's the first time I'm coding an addon for Blender, so I might be missing something obvious.

To replicate this, you can set up a Python 3.7 environment and install bpy and numpy, and finally run bpy_post_install. For example on Conda:

conda create -n blender python=3.7 -y
conda activate blender
pip install bpy numpy
bpy_post_install

Then run the following code:

import bpy
from freestyle.utils import get_strokes

var = get_strokes()

I really need to get the strokes from the freestyle linesets for the project I'm working on at work. I'm now stuck on this part. I tried looking into the code of the existing addon Freestyle SVG Exporter to try to find how to do it, but I'm very lost.

发布评论

评论列表(0)

  1. 暂无评论