Solved

Blender 2.5x python script to combine objects in scene

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
The problem with the movement of the serpent (snake game) 1 771
merging 2 mysql databases with java 7 58
Python Install On Mac Yosemite 8 118
linux crontab output 3 65
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…
Strings in Python are the set of characters that, once defined, cannot be changed by any other method like replace. Even if we use the replace method it still does not modify the original string that we use, but just copies the string and then modif…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
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…

932 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now