SakeTami
TRY FOR FREE
cebstudios
cebstudios

patreon


Override Context, very simple way

Just use the code below (got it from the link: https://devtalk.blender.org/t/quick-way-to-force-context-area-in-test-script/11139/4 )

from contextlib import contextmanager
@contextmanager
def context(area_type: str):
    area = bpy.context.area
    former_area_type = area.type
    area.type = area_type
    try:
        yield area
    finally:
        area.type = former_area_type


Then you can override the context using:

with context('GRAPH_EDITOR'):
    bpy.ops.graph.clean(threshold=0.02, channels=False)

List from the site: https://docs.blender.org/api/current/bpy.types.Area.html#bpy.types.Area.type 

Comments

๋งค์šฐ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ์ตœ์ข… ์• ๋“œ์˜จ์€ ๋งค์šฐ ๋ณต์žกํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ถœ์‹œ๋˜๋Š” ๋ฐ ์‹œ๊ฐ„์ด ๊ฑธ๋ฆฝ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ๋ฌด๋ฃŒ๋กœ ์ œ๊ณต๋˜๋Š” ๋ฒ ํƒ€ ๋ฒ„์ „์€ ์ด๋ฏธ ๋ช‡ ๊ฐ€์ง€ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‚˜๋Š” ์—ฌ์ „ํžˆ ์• ๋“œ์˜จ์„ ๊ฐ„๋‹จํ•˜๊ฒŒ ์ž‘๋™์‹œํ‚ค๋Š” ๋ฐฉ๋ฒ•์„ ํ…Œ์ŠคํŠธํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ถœ์‹œ๋˜๋ฉด ๋ชจ๋“  ํ›„์›์ž๋Š” ๋ฌด๋ฃŒ ๋˜๋Š” ํ• ์ธ๋œ ๋ฒ„์ „์„ ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ค๋Š˜ Patreon์ธ ๋ชจ๋“  ์‚ฌ๋žŒ์€ ํ™•์‹คํžˆ ๋ฌด๋ฃŒ๋กœ ๋ฐ›์„ ๊ฒƒ์ž…๋‹ˆ๋‹ค. Thank you very much. the final addon should take a while to be released, as it is very complex. but the beta version which is available for free, it is already possible to do some things. I'm still testing how to make the addon work simply. when it launches all patreons will be able to receive a free or discounted version. Everyone who is a Patreon today will certainly receive it for free.

์นœ์ ˆํ•œ ์„ค๋ช… ์ž˜ ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. ์ •์‹ Addon ์ถœ์‹œ๊ฐ€ ๊ธฐ๋Œ€๋˜๋„ค์š”. ํ•ญ์ƒ ์‘์›ํ•ฉ๋‹ˆ๋‹ค.


More Creators