Proportional editing of disconnected objects using Python API doesn't work #87239

Closed
opened 2021-04-06 15:58:44 +02:00 by Christopher Burns · 6 comments

System Information
Operating system: Ubuntu 20
Graphics card: 2080 Ti

Blender Version
Broken: 2.93 de1eeaa3d2
Worked: ???

Doing a manual proportional translate with one object selected will proportionally move nearby objects, as it should. If you attempt the same operation using Python, only the selected object will move

Exact steps for others to reproduce the error

With the attached blender file...

proportional-transform-bug.blend

  1. g-z to move the selected cube up.... surrounding cubes are also transformed
  2. undo the transform
  3. go to the scripting window and copy the generated command from step 1
  4. execute the copied command... only the selected cube is transformed
**System Information** Operating system: Ubuntu 20 Graphics card: 2080 Ti **Blender Version** Broken: 2.93 de1eeaa3d24a Worked: ??? Doing a manual proportional translate with one object selected will proportionally move nearby objects, as it should. If you attempt the same operation using Python, only the selected object will move **Exact steps for others to reproduce the error** With the attached blender file... [proportional-transform-bug.blend](https://archive.blender.org/developer/F9921862/proportional-transform-bug.blend) 1. g-z to move the selected cube up.... surrounding cubes are also transformed 2. undo the transform 3. go to the scripting window and copy the generated command from step 1 4. execute the copied command... only the selected cube is transformed

Added subscriber: @christopher.burns

Added subscriber: @christopher.burns
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Philipp Oeser self-assigned this 2021-04-07 09:25:43 +02:00
Member

Can confirm, will check.

Can confirm, will check.
Member

Changed status from 'Confirmed' to: 'Archived'

Changed status from 'Confirmed' to: 'Archived'
Member

Looked into this, and this is another example where execution of an operator fails outside the correct context of the 3DView.


Small detour:

  • if called from outside the 3DView, initTransInfo will set t->view to the view of the python console (or the Text Editor if called from there)
  • with this t->view set to something not the 3DView, there are checks in count_proportional_objects which then dont survive for the additional objects considered for proportional editing:
    • BASE_EDITABLE(v3d, base) -- because BKE_base_is_visible(v3d, base) is not true
    • BASE_SELECTABLE(v3d, base) -- for the same reasons than the above
  • if these objects dont survive the test, TransformContainer->data_len is then only for one object (instead of the "correct" 27 in the example file)
  • operator then only acts on one object (instead of the "correct" 27 in the example file)

Having said all that, this "wrong" context is not considered a bug, if you really need to call the bpy.ops.transform.translate operator from outside the 3DView, you can craft the context beforehand to behave correctly:
(please also refer to https://docs.blender.org/api/master/bpy.ops.html#execution-context)

import bpy

override = bpy.context.copy()

for window in bpy.context.window_manager.windows:
    screen = window.screen

    for area in screen.areas:
        if area.type == 'VIEW_3D':
            override['window'] = window
            override['screen'] = screen
            override['area'] = area
            for r in area.regions:
                if r.type == 'WINDOW':
                    override['region'] = r
                    break
            break

bpy.ops.transform.translate(override, value=(0, 0, 1.31437), orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(False, False, True), mirror=True, use_proportional_edit=True, proportional_edit_falloff='SHARP', proportional_size=2.59374, use_proportional_connected=False, use_proportional_projected=False)

So you can use it outside the 3DView as demonstrated in this file (using the override context described above):
proportional-transform-bug-override.blend

And while it is not super convenient, this behavior is not considered a bug for now, will have to archive this report (feel free to comment again though if issues persist)

Looked into this, and this is another example where execution of an operator fails outside the correct context of the 3DView. --- Small detour: - if called from outside the 3DView, `initTransInfo` will set `t->view` to the view of the python console (or the Text Editor if called from there) - with this `t->view` set to something not the 3DView, there are checks in `count_proportional_objects` which then dont survive for the additional objects considered for proportional editing: - BASE_EDITABLE(v3d, base) -- because BKE_base_is_visible(v3d, base) is not true - BASE_SELECTABLE(v3d, base) -- for the same reasons than the above - if these objects dont survive the test, `TransformContainer->data_len` is then only for one object (instead of the "correct" 27 in the example file) - operator then only acts on one object (instead of the "correct" 27 in the example file) --- Having said all that, this "wrong" context is not considered a bug, if you really need to call the `bpy.ops.transform.translate` operator from outside the 3DView, you can craft the context beforehand to behave correctly: (please also refer to https://docs.blender.org/api/master/bpy.ops.html#execution-context) ``` import bpy override = bpy.context.copy() for window in bpy.context.window_manager.windows: screen = window.screen for area in screen.areas: if area.type == 'VIEW_3D': override['window'] = window override['screen'] = screen override['area'] = area for r in area.regions: if r.type == 'WINDOW': override['region'] = r break break bpy.ops.transform.translate(override, value=(0, 0, 1.31437), orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(False, False, True), mirror=True, use_proportional_edit=True, proportional_edit_falloff='SHARP', proportional_size=2.59374, use_proportional_connected=False, use_proportional_projected=False) ``` So you can use it outside the 3DView as demonstrated in this file (using the override context described above): [proportional-transform-bug-override.blend](https://archive.blender.org/developer/F9922623/proportional-transform-bug-override.blend) And while it is not super convenient, this behavior is not considered a bug for now, will have to archive this report (feel free to comment again though if issues persist)
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#87239
No description provided.