Solved

Blender 2.5x python script to combine objects in scene

Posted on 2010-09-24
4
1,511 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 500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This article will show the steps for installing Python on Ubuntu Operating System. I have created a virtual machine with Ubuntu Operating system 8.10 and this installing process also works with upgraded version of Ubuntu OS. For installing Py…
Sequence is something that used to store data in it in very simple words. Let us just create a list first. To create a list first of all we need to give a name to our list which I have taken as “COURSE” followed by equals sign and finally enclosed …
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 while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

742 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