blender python addon: unexpected result of object join #62494

Closed
opened 2019-03-12 15:15:56 +01:00 by Wim den Boer · 8 comments

System Information
Operating system: MacOS 10.13.6
Graphics card: Geforce GT1030

Blender Version
Broken: 2.80, hash: e6eb7b9cce, type: Release build date: 2019-03-12, 01:51:49
Worked: 2.79b

Use of bpy.ops.object.join() in addon script gives an unexpected result

The upload file contains a simplified addon to demonstrate the problem, two screen dumps and a simple blend file

Steps:

  1. Install addon Testbed
  2. Open test_object_join.blend
  3. Click Testbed button in 3D-header
  4. Tweak scale property in operator panel

Result after step 3 is a cube with 5 unconnected meshes with proper location and scale. (screenshot "default scale.png")
Result after step 4 is a cube with 5 unconnected meshes all with the original object location and scale. (screenshot "with scale setting.png")

The step 3 result is what you expect with and without tweaking the scale property. Is is the result you get in 2.79b and when skipping the bpy.ops.object.join() in the script and joining "by hand".

test object join.zip

**System Information** Operating system: MacOS 10.13.6 Graphics card: Geforce GT1030 **Blender Version** Broken: 2.80, hash: e6eb7b9ccee1, type: Release build date: 2019-03-12, 01:51:49 Worked: 2.79b Use of bpy.ops.object.join() in addon script gives an unexpected result The upload file contains a simplified addon to demonstrate the problem, two screen dumps and a simple blend file Steps: 1. Install addon Testbed 2. Open test_object_join.blend 3. Click Testbed button in 3D-header 4. Tweak scale property in operator panel Result after step 3 is a cube with 5 unconnected meshes with proper location and scale. (screenshot "default scale.png") Result after step 4 is a cube with 5 unconnected meshes all with the original object location and scale. (screenshot "with scale setting.png") The step 3 result is what you expect with and without tweaking the scale property. Is is the result you get in 2.79b and when skipping the bpy.ops.object.join() in the script and joining "by hand". [test object join.zip](https://archive.blender.org/developer/F6810175/test_object_join.zip)
Author

Added subscriber: @WimdenBoer

Added subscriber: @WimdenBoer
Member

Added subscriber: @JacquesLucke

Added subscriber: @JacquesLucke
Campbell Barton was assigned by Jacques Lucke 2019-03-13 13:00:16 +01:00
Member

This is probably an undo issue.

lang=python
import bpy
from bpy.props import FloatProperty

def copyObject(loc, scale, object):
    newobject = bpy.data.objects.new(object.name, object.data.copy())
    newobject.scale *= scale
    newobject.location = loc
    return newobject

class TestOperator(bpy.types.Operator):
    bl_idname = "test.test"
    bl_label = "Test"
    bl_options = {'REGISTER', 'UNDO'}
    
    scale: FloatProperty(default=0.1)
    
    def execute(self, context):
        obj = context.view_layer.objects.active
        for i in range(1,5):
            newobj = copyObject((2*i,0,0), self.scale, obj)
            context.scene.collection.objects.link(newobj)
            newobj.select_set(True)
        bpy.ops.object.join()
        return {'FINISHED'} 
    
bpy.utils.register_class(TestOperator)

undo issue.gif

This is probably an undo issue. ``` lang=python import bpy from bpy.props import FloatProperty def copyObject(loc, scale, object): newobject = bpy.data.objects.new(object.name, object.data.copy()) newobject.scale *= scale newobject.location = loc return newobject class TestOperator(bpy.types.Operator): bl_idname = "test.test" bl_label = "Test" bl_options = {'REGISTER', 'UNDO'} scale: FloatProperty(default=0.1) def execute(self, context): obj = context.view_layer.objects.active for i in range(1,5): newobj = copyObject((2*i,0,0), self.scale, obj) context.scene.collection.objects.link(newobj) newobj.select_set(True) bpy.ops.object.join() return {'FINISHED'} bpy.utils.register_class(TestOperator) ``` ![undo issue.gif](https://archive.blender.org/developer/F6814116/undo_issue.gif)

Added subscriber: @ZedDB

Added subscriber: @ZedDB

I'll mark this as confirmed then.

I'll mark this as confirmed then.
Campbell Barton was unassigned by Dalai Felinto 2019-12-23 16:34:53 +01:00

Added subscriber: @ideasman42

Added subscriber: @ideasman42
Author

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Wim den Boer self-assigned this 2020-01-07 20:59:03 +01:00
Author

Retested this issue with 2.81a:

version: 2.81 (sub 16), branch: master, commit date: 2019-12-04 11:32, hash: f1aa4d18d4

bpy.ops.object.join() worked as expected.

I have changed the status to resolved.

My little contribution to the tracker curfew :)

Thanks

Retested this issue with 2.81a: version: 2.81 (sub 16), branch: master, commit date: 2019-12-04 11:32, hash: f1aa4d18d49d bpy.ops.object.join() worked as expected. I have changed the status to resolved. My little contribution to the tracker curfew :) Thanks
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
4 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#62494
No description provided.