[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Blender 2.5x python script to combine objects in scene

Posted on 2010-09-24
4
Medium Priority
?
1,545 Views
Last Modified: 2013-12-21
I am using blender 2.54.

Please write a python script that would place 3d model of simple object such as a box ( named item.blend) on the ground floor of main scene file ( named main.blend) . Main scene can be any simple scene (like a really simple room) that has ground floor.

Please also include the .blend files in your solution. Again these are really simple scenes or you may already have such .blend files.

The script must run from the command line ( Not starting blender UI and typing the script within blender UI).

Please provide solution if you have python programming experience with blender.

This is not a homework project. I am learning 3d programming in the context of blender.

 
0
Comment
Question by:zenguru
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
4 Comments
 
LVL 9

Expert Comment

by:zaghaghi
ID: 33777853
Hi you can use this code:

hope this works.
import bpy

blendfilepath = "/tmp/untitled.blend"
objectname = "Cube"

res = bpy.ops.wm.link_append(directory=blendfilepath + "/Object/",filename=objectname, link=False, instance_groups=False)
if list(res)[0] == 'FINISHED':
    print("Successfully imported!")
else:
    print("There was an error!")

Open in new window

0
 
LVL 9

Accepted Solution

by:
zaghaghi earned 2000 total points
ID: 33777922
Also if you have multiple Objects and want to import them, first create a group and add all objects to that group. then in 4th line use name of the created group instead of "Cube" and in 6th line use "/Group/" instead of "/Object/".
0
 
LVL 9

Expert Comment

by:zaghaghi
ID: 33777966
For example if i had 3 Objects in "Cubes" group in a.blend then i can use this code
res = bpy.ops.wm.link_append(directory=blendfilepath + "/Group/",filename="Cubes", link=False, instance_groups=False)

Open in new window

0
 
LVL 9

Expert Comment

by:zaghaghi
ID: 33777978
As python API of blender 2.5 is currenly unstable use http://www.blender.org/documentation/250PythonDoc/bpy.ops.wm.html#bpy.ops.wm.link_append for future refs.
0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Less strange, but still introduction This introduction was added (1st August, 2011) to reflect some reactions.  Firstly, the term basics in the title of the article...  As any other word, it is a symbol with meaning attached to the word by some a…
As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question