Solved

Blender 2.5x python script to combine objects in scene

Posted on 2010-09-24
4
1,480 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Using bootstrap with french text 13 75
Python script details 2 61
data scientists and AI 17 68
how to split multiple lines delimiter : 8 53
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…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
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…

772 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

12 Experts available now in Live!

Get 1:1 Help Now