0
$\begingroup$

Why gives an error on bpy.ops.uv.snap_cursor(target='SELECTED') ?

enter image description here

enter image description here

$\endgroup$

1 Answer 1

2
$\begingroup$

First you have to find the UV editor area that interests you. This will apply the operator in the first visible UV editor it finds:

>>> imgeds = [a for a in C.window_manager.windows[0].screen.areas if a.type == 'IMAGE_EDITOR']
>>> uved = next(i for i in imgeds if [s for s in i.spaces if s.mode=='UV'])
>>> bpy.ops.uv.snap_cursor({'area': uved}, target='SELECTED')
$\endgroup$
10
  • $\begingroup$ thank you very match $\endgroup$
    – tormozzzz
    Commented Nov 29, 2021 at 16:35
  • $\begingroup$ C.window_manager.windows[0].screen.areas - what C ? $\endgroup$
    – tormozzzz
    Commented Nov 29, 2021 at 17:41
  • $\begingroup$ NameError: name 'C' is not defined $\endgroup$
    – tormozzzz
    Commented Nov 29, 2021 at 17:48
  • $\begingroup$ How create text data-blok with this code without error ? $\endgroup$
    – tormozzzz
    Commented Nov 29, 2021 at 18:08
  • $\begingroup$ How to select a specific object, for example 'Plane', to perform these actions on it ? $\endgroup$
    – tormozzzz
    Commented Nov 29, 2021 at 18:12

You must log in to answer this question.

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