Python Module not appended when appending an object with bpy.obs.wm.append #53960

Closed
opened 2018-01-31 12:13:44 +01:00 by Jeremy Nicola · 8 comments

System Information
Ubuntu Linux 16.04, 64bits
Graphic card Intel HD Graphics 530

Blender Version
Broken: 2.76b, 2.79a

Short description of error
Appending an object that has a controller using a Python module from an external file will append the object but not the Python module (the text).
Please not that if the controller is using a Python script instead of a module, the script is added correctly.

Exact steps for others to reproduce the error

  • Download the attached env.blend file which contains a cube with

    • an always sensor connected to a Python controller using a script named Script_A
    • an always sensor connected to a Python controller using a module named module_a
    • On the image you can see the two Python texts are included in the .blend file before import.png
  • From a new Blender file, in the Python console, append the cube with bpy.ops.wm.append

    • py.ops.wm.append(directory="/path/to/env.blend/Object/", autoselect=True, files=[{'name': 'Cube'}])
    • you can see the Python "Script_A" text is included in the file, the Python "module_a" module is not after import.png

Is this the expected behaviour? I would like to know before implementing a specific workaround for our use-case (the MORSE robot simulator).

**System Information** Ubuntu Linux 16.04, 64bits Graphic card Intel HD Graphics 530 **Blender Version** Broken: 2.76b, 2.79a **Short description of error** Appending an object that has a controller using a Python module from an external file will append the object but not the Python module (the text). Please not that if the controller is using a Python script instead of a module, the script is added correctly. **Exact steps for others to reproduce the error** - Download the attached [env.blend](https://archive.blender.org/developer/F2057117/env.blend) file which contains a cube with - an always sensor connected to a Python controller using a script named Script_A - an always sensor connected to a Python controller using a module named module_a - On the image you can see the two Python texts are included in the .blend file ![before import.png](https://archive.blender.org/developer/F2057134/before_import.png) - **From a new Blender file**, in the Python console, append the cube with bpy.ops.wm.append - py.ops.wm.append(directory="/path/to/env.blend/Object/", autoselect=True, files=[{'name': 'Cube'}]) - you can see the Python "Script_A" text is included in the file, the Python "module_a" module is not ![after import.png](https://archive.blender.org/developer/F2057184/after_import.png) Is this the expected behaviour? I would like to know before implementing a specific workaround for our use-case (the [MORSE ](https://www.openrobots.org/morse/doc/stable/morse.html) robot simulator).
Author

Added subscriber: @JeremyNicola

Added subscriber: @JeremyNicola
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

I guess this is expected behaviour. A module doesnt have to be a textblock (more naturally python code would just somewhere be in a file on the Pythonpath in that case).
And afaiks the module string entry is being kept intact, so the controller should actually keep working once appended (if the module code is external).

In the special case the module is actually a real textblock in the source blenderfile: that would actually be possible to implement [I mean appending that datablock as well], but more of a TODO (which I am not even sure would be desiarable in all cases - would need more thought...)

I would tend to close this report as 'not a bug' but would like to hear a second opinion to be sure

I guess this is expected behaviour. A module doesnt have to be a textblock (more naturally python code would just somewhere be in a file on the Pythonpath in that case). And afaiks the module string entry is being kept intact, so the controller should actually keep working once appended (if the module code is external). In the special case the module is actually a real textblock in the source blenderfile: that would actually be possible to implement [I mean appending that datablock as well], but more of a TODO (which I am not even sure would be desiarable in all cases - would need more thought...) I would tend to close this report as 'not a bug' but would like to hear a second opinion to be sure
Member

Added subscriber: @mont29

Added subscriber: @mont29
Member

@mont29: kindly asking for a thought

@mont29: kindly asking for a thought

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Bastien Montagne self-assigned this 2018-01-31 19:42:47 +01:00

Yep, as @lichtwerk said, there is absolutely no way for Blender to guess where this module would come from, it’s just assumed to be 'somewhere' in our py path, that’s all. Append/link can definitively not deal with that, they only deal with relations between actual data-blocks anyway.

Yep, as @lichtwerk said, there is absolutely no way for Blender to guess where this module would come from, it’s just assumed to be 'somewhere' in our py path, that’s all. Append/link can definitively not deal with that, they only deal with relations between actual data-blocks anyway.
Author

But wouldn't it be sane and simple to just check :

  • if the Python text is a module
  • if its associated text is in the Texts
    then import the associated text?

Or at least provide an option "autoimport_modules"? I might help if needed.

From a naive user perspective, that really does not make sense to not have a Python module imported when it is written in the .blend

But wouldn't it be sane and simple to just check : - if the Python text is a module - if its associated text is in the Texts then import the associated text? Or at least provide an option "autoimport_modules"? I might help if needed. From a naive user perspective, that really does not make sense to not have a Python module imported when it is written in the .blend
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#53960
No description provided.