Just off by 0.00023445, time to brake out the python

So I have been quit busy doing the challenge. But it is a lot of work, there are a few small things that I want do complete before continuing to the next course seminar like:
Placing the roof and moving the wire gutters down a bit.
And I had trouble as a lot pieces where just off buy 0.00023445. And redoing half the building was braking my hart so…
I made a python script to round the position of the selected object to a tenth of a unit and thus making the whole construction flush once more …
I am posting it here in the hope someone else might find it help-full :slight_smile:

import bpy
import mathutils

print("Start run ...")

vec = mathutils.Vector((0.0, 0.0, 0.0))

for obj in bpy.context.selected_objects:
#    for coord in obj.matrix_world.to_translation():
#        print(coord.x)

    
    #print(round(obj.matrix_world.to_translation().x,1))
    print(obj.location.x)
    vec.x = round(obj.location.x,1)
    vec.y = round(obj.location.y,1)
    vec.z = round(obj.location.z,1)
    print(vec)
    obj.location = vec
    
    print("After Operation:")
    print(obj.location.x)



9 Likes

Looks good so far, unfortunately I have zero python experience. Their is supposed to be a part of the course dedicated to python programming for blender addons, but it has yet to be released.

Thanks for the complement. In my eyes python is one of the best and easiest programming languages to learn. I have good hopes on seeing quality course add on using python in the future.

well i was gonna do a very simple design, because im putting mine towards a different project, but seeing all these cool designs… idk i might have to step it up lol

Stepping it up is the way to some blender gains, bro!

When I see this kind of stuff, it in turn makes me step up.

So step it up! :smile:

1 Like

Privacy & Terms