Dedicated group, there are members"basic, intermediate and advanced" in blender 3d, for the growth and education of the Blender 3D software.

Post tutorial Report RSS Tutorial Python and Blender 3D: Aligning objects with their own scripts

Blender 3D Aligning objects with their own scripts

Posted by on - Basic Other

The use of custom scripts and routines 3d tools is a requirement to accelerate its work in 3D software, is using MAXScript in 3ds Max, Maya in Mel or Python in Softimage XSI. In Blender 3D can also use Python to add new tools and even create small routines that help to develop tools to automate modeling tasks. As always talk about this stuff, but had not published any tutorial on getting started with Python in Blender, I decided to create a video tutorial on modeling a common task, which is the alignment of objects.

Whenever we are creating scenarios or complex compositions using various objects, we need to align themselves on an axle, or simply organize 3D models as furniture. One of the quickest and simplest ways to do this is using Python.

How can we do this in Python?

To answer this question, I edited a separate two-part tutorial that shows the first steps with Python in Blender 3D, and create a routine that aligns selected objects based on the Y position of an element present in the 3D View.

The video covers the following subjects:

  • What is needed to import the Blender module for the script
  • How to capture information about objects in the 3D View
  • How to capture information only on selected objects
  • How to display the information in the auxiliary window in Blender 3D
  • How to change properties of objects using Python
  • How to create looping to automate the transformations

Of course, if you have some experience with scripting or software development, the explanation and objects are presented in the tutorial easier to follow and understand.

The logic presented in the tutorials is as follows, with option Blender.Objects.GetSelected () you can add the selected objects in the 3D View in a list. This list contains the names of objects. In the case of this script that aligns elements in relation to another, access to each of them is made by a go.

What is this for?

In a scripting language is is used to make repetitive tasks. In our example we could have written the statement that changes the Y positions of the objects in 3D View in two ways. A statement for each selected object as an object (0). LocY = meuObjeto.LocY, object (1). LocY = meuObjeto.LocY, object (2). LocY = meuObjeto.LocY.

The operation would be the same. As it is, we can say that a variable i must be compared with the number of indexes of the list objects, which in this case has the same number of selected objects in the 3D View. The advantage in using it is that no matter the number of selected objects, the script will always automatically add the required number of statements to move the 3D models.

Now you can make changes in this script to create their own routines. In other articles, I show how you can create an interface and working with custom tools using Python in Blender 3D.

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: