bpy.ops.logic.controller_add() is too eager in making name unique #42858

Closed
opened 2014-12-09 17:01:21 +01:00 by inactive account · 6 comments

System Information
Ubuntu 14.10, GeForce 460.

Blender Version
Broken: 2.72b & 2f637004d5

Short description of error
bpy.ops.logic.controller_add(type='PYTHON', name='Startup') will create a controller that is named Startup1 when there is already another logic brick with the name Sensor. However, in the GUI itself, it is perfectly possible to have both a sensor and controller with the same name.

Exact steps for others to reproduce the error
Based on a (as simple as possible) attached .blend file with minimum amount of steps

Inspect the names of the logic bricks

Expected behaviour: both logic bricks are named Startup
Observed behaviour: the controller is named Startup1

You can rename the controller to Startup, and see that Blender allows this just fine.

**System Information** Ubuntu 14.10, GeForce 460. **Blender Version** Broken: 2.72b & 2f637004d57b4220e483dc60f72edc86b88d3102 **Short description of error** `bpy.ops.logic.controller_add(type='PYTHON', name='Startup')` will create a controller that is named `Startup1` when there is already another logic brick with the name `Sensor`. However, in the GUI itself, it is perfectly possible to have both a sensor and controller with the same name. **Exact steps for others to reproduce the error** Based on a (as simple as possible) attached .blend file with minimum amount of steps - Open the attached Blend file [logic_bricks_bug_report.blend](https://archive.blender.org/developer/F130476/logic_bricks_bug_report.blend) - Run the script in the bottom panel # Inspect the names of the logic bricks *Expected behaviour*: both logic bricks are named `Startup` *Observed behaviour*: the controller is named `Startup1` You can rename the controller to `Startup`, and see that Blender allows this just fine.

Changed status to: 'Open'

Changed status to: 'Open'

Added subscriber: @sybrenstuvel

Added subscriber: @sybrenstuvel

I just figured out this doesn't just happen with logic bricks within one object. It also occurs when adding bricks to multiple objects. For example, when there are two cubes Cube and Cube.001, and this code is executed:

import bpy

bpy.ops.logic.sensor_add(type='ALWAYS', name='SENS-Startup', object='Cube')
bpy.ops.logic.controller_add(type='PYTHON', name='CTRL-Startup', object='Cube')

bpy.ops.logic.sensor_add(type='ALWAYS', name='SENS-Startup', object='Cube.001')
bpy.ops.logic.controller_add(type='PYTHON', name='CTRL-Startup', object='Cube.001')

Afterward, Cube has SENS-Startup, and Cube.001 has SENS-Startup1. Same for the controllers.

This makes it cumbersome to programmatically create new controllers, and then directly access them, as the numeric suffix needs to be found and eliminated.

I just figured out this doesn't just happen with logic bricks within one object. It also occurs when adding bricks to multiple objects. For example, when there are two cubes `Cube` and `Cube.001`, and this code is executed: ``` import bpy bpy.ops.logic.sensor_add(type='ALWAYS', name='SENS-Startup', object='Cube') bpy.ops.logic.controller_add(type='PYTHON', name='CTRL-Startup', object='Cube') bpy.ops.logic.sensor_add(type='ALWAYS', name='SENS-Startup', object='Cube.001') bpy.ops.logic.controller_add(type='PYTHON', name='CTRL-Startup', object='Cube.001') ``` Afterward, `Cube` has `SENS-Startup`, and `Cube.001` has `SENS-Startup1`. Same for the controllers. This makes it cumbersome to programmatically create new controllers, and then directly access them, as the numeric suffix needs to be found and eliminated.

This issue was referenced by 072d80a9de

This issue was referenced by 072d80a9de3adef632b8637649b169c4a895c1b9

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Closed by commit 072d80a9de.

Closed by commit 072d80a9de.
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
3 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#42858
No description provided.