lines generated with python
Dude this is awesome!
cool. Not big fan of the cube object but the lines chaos is nice. Maybe a frontal view would do?
Just had a though, I think it would be cool if that lattice had an emission shader applied to it.
First picture has emission applied to lines
Interesting result! It’s possible to share the python code? I think can be very useful to “starters” as me, if it’s not much complicated.
norm. try Sverchok for this kind of art
import random, math
two = 1
#add_cube = bpy.ops.mesh.primitive_plane_add
add_sphere = bpy.ops.mesh.primitive_uv_sphere_add
add_cyl = bpy.ops.mesh.primitive_cylinder_add
x1 = random.random() * 20
y1 = random.random() * 20
z1 = random.random() * 20
add_sphere(segments=6, ring_count=6, size=1, view_align=False, enter_editmode=False, location=(x1, y1, z1), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
bpy.context.object.name = “Sphere_” + “{}”.format(one) + “{}".format(two)
bpy.ops.transform.resize(value=(0.1, 0.1, 0.1), constraint_axis=(False, False, False), constraint_orientation=‘GLOBAL’, mirror=False, proportional=‘DISABLED’, proportional_edit_falloff=‘SMOOTH’, proportional_size=1)
bpy.context.object.cycles_visibility.camera = False
for one in range(1,300,1):
x2 = random.random() * 20
y2 = random.random() * 20
z2 = random.random() * 20
#
add_sphere(segments=6, ring_count=6, size=1, view_align=False, enter_editmode=False, location=(x2, y2, z2), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
bpy.context.object.name = "Cube” + “{}”.format(one) + “{}".format(two)
bpy.ops.transform.resize(value=(0.1, 0.1, 0.1), constraint_axis=(False, False, False), constraint_orientation=‘GLOBAL’, mirror=False, proportional=‘DISABLED’, proportional_edit_falloff=‘SMOOTH’, proportional_size=1)
bpy.context.object.cycles_visibility.camera = False
#################
#
add_cyl(vertices=6, view_align=False, enter_editmode=False, location=(0, 0, 0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
bpy.context.object.name = "Cyl” + “{}”.format(one) + “_{}”.format(two)
bpy.ops.transform.resize(value=(0.025, 0.025, 0.1), constraint_axis=(False, False, False), constraint_orientation=‘GLOBAL’, mirror=False, proportional=‘DISABLED’, proportional_edit_falloff=‘SMOOTH’, proportional_size=1)
bpy.context.object.cycles_visibility.camera = False
####
#
if x1 <= x2 and y1 <= y2 and z1 <= z2:
garums_x_y = sqrt(pow(x2 - x1,2) + pow(y2 - y1 ,2))
garums = sqrt(pow(garums_x_y,2) + pow(z2 - z1,2))
bpy.context.object.dimensions[2] = garums
#
bpy.context.scene.cursor_location = (0.0, 0.0, -garums/2)
bpy.ops.object.origin_set(type=‘ORIGIN_CURSOR’)
#aaa
bpy.ops.transform.translate(value=(x1, y1, z1 + (garums/2)), constraint_axis=(False, False, False), constraint_orientation=‘GLOBAL’, mirror=False, proportional=‘DISABLED’, proportional_edit_falloff=‘SMOOTH’, proportional_size=1, release_confirm=True)
#
bpy.context.object.rotation_euler = (0.0174532 * (270 + math.degrees(math.acos((garums_x_y)/(garums)))), 0, 0.0174532 * (270 + math.degrees(math.atan((y2 - y1)/(x2 - x1)))))
if x1 >= x2 and y1 >= y2 and z1 >= z2:
garums_x_y = sqrt(pow(x1 - x2,2) + pow(y1 - y2 ,2))
garums = sqrt(pow(garums_x_y,2) + pow(z1 - z2,2))
bpy.context.object.dimensions[2] = garums
#
bpy.context.scene.cursor_location = (0.0, 0.0, -garums/2)
bpy.ops.object.origin_set(type=‘ORIGIN_CURSOR’)
#aaa
bpy.ops.transform.translate(value=(x2, y2, z2 + (garums/2)), constraint_axis=(False, False, False), constraint_orientation=‘GLOBAL’, mirror=False, proportional=‘DISABLED’, proportional_edit_falloff=‘SMOOTH’, proportional_size=1, release_confirm=True)
#
bpy.context.object.rotation_euler = (0.0174532 * (270 + math.degrees(math.acos((garums_x_y)/(garums)))), 0, 0.0174532 * (270 + math.degrees(math.atan((y1 - y2)/(x1 - x2)))))
if x1 > x2 and y1 <= y2 and z1 <= z2:
garums_x_y = sqrt(pow(x2 - x1,2) + pow(y2 - y1 ,2))
garums = sqrt(pow(garums_x_y,2) + pow(z2 - z1,2))
bpy.context.object.dimensions[2] = garums
#
bpy.context.scene.cursor_location = (0.0, 0.0, -garums/2)
bpy.ops.object.origin_set(type=‘ORIGIN_CURSOR’)
#aaa
bpy.ops.transform.translate(value=(x1, y1, z1 + (garums/2)), constraint_axis=(False, False, False), constraint_orientation=‘GLOBAL’, mirror=False, proportional=‘DISABLED’, proportional_edit_falloff=‘SMOOTH’, proportional_size=1, release_confirm=True)
#
bpy.context.object.rotation_euler = (0.0174532 * (270 + math.degrees(math.acos((garums_x_y)/(garums)))), 0, 0.0174532 * (90 + math.degrees(math.atan((y2 - y1)/(x2 - x1)))))
if x1 <= x2 and y1 > y2 and z1 <= z2:
garums_x_y = sqrt(pow(x2 - x1,2) + pow(y2 - y1 ,2))
garums = sqrt(pow(garums_x_y,2) + pow(z2 - z1,2))
bpy.context.object.dimensions[2] = garums
#
bpy.context.scene.cursor_location = (0.0, 0.0, -garums/2)
bpy.ops.object.origin_set(type=‘ORIGIN_CURSOR’)
#aaa
bpy.ops.transform.translate(value=(x1, y1, z1 + (garums/2)), constraint_axis=(False, False, False), constraint_orientation=‘GLOBAL’, mirror=False, proportional=‘DISABLED’, proportional_edit_falloff=‘SMOOTH’, proportional_size=1, release_confirm=True)
#
bpy.context.object.rotation_euler = (0.0174532 * (270 + math.degrees(math.acos((garums_x_y)/(garums)))), 0, 0.0174532 * (270 + math.degrees(math.atan((y2 - y1)/(x2 - x1)))))
if x1 <= x2 and y1 <= y2 and z1 > z2:
garums_x_y = sqrt(pow(x2 - x1,2) + pow(y2 - y1 ,2))
garums = sqrt(pow(garums_x_y,2) + pow(z2 - z1,2))
bpy.context.object.dimensions[2] = garums
#
bpy.context.scene.cursor_location = (0.0, 0.0, -garums/2)
bpy.ops.object.origin_set(type=‘ORIGIN_CURSOR’)
#aaa
bpy.ops.transform.translate(value=(x1, y1, z1 + (garums/2)), constraint_axis=(False, False, False), constraint_orientation=‘GLOBAL’, mirror=False, proportional=‘DISABLED’, proportional_edit_falloff=‘SMOOTH’, proportional_size=1, release_confirm=True)
#
bpy.context.object.rotation_euler = (0.0174532 * (270 + math.degrees(math.acos((garums_x_y)/(garums)))), 0.0174532 * 180, 0.0174532 * (270 + math.degrees(math.atan((y2 - y1)/(x2 - x1)))))
if x1 > x2 and y1 > y2 and z1 <= z2:
garums_x_y = sqrt(pow(x2 - x1,2) + pow(y2 - y1 ,2))
garums = sqrt(pow(garums_x_y,2) + pow(z2 - z1,2))
bpy.context.object.dimensions[2] = garums
#
bpy.context.scene.cursor_location = (0.0, 0.0, -garums/2)
bpy.ops.object.origin_set(type=‘ORIGIN_CURSOR’)
#aaa
bpy.ops.transform.translate(value=(x1, y1, z1 + (garums/2)), constraint_axis=(False, False, False), constraint_orientation=‘GLOBAL’, mirror=False, proportional=‘DISABLED’, proportional_edit_falloff=‘SMOOTH’, proportional_size=1, release_confirm=True)
#
bpy.context.object.rotation_euler = (0.0174532 * (270 + math.degrees(math.acos((garums_x_y)/(garums)))), 0, 0.0174532 * (90 + math.degrees(math.atan((y2 - y1)/(x2 - x1)))))
if x1 <= x2 and y1 > y2 and z1 > z2:
garums_x_y = sqrt(pow(x2 - x1,2) + pow(y2 - y1 ,2))
garums = sqrt(pow(garums_x_y,2) + pow(z2 - z1,2))
bpy.context.object.dimensions[2] = garums
#
bpy.context.scene.cursor_location = (0.0, 0.0, -garums/2)
bpy.ops.object.origin_set(type=‘ORIGIN_CURSOR’)
#aaa
bpy.ops.transform.translate(value=(x1, y1, z1 + (garums/2)), constraint_axis=(False, False, False), constraint_orientation=‘GLOBAL’, mirror=False, proportional=‘DISABLED’, proportional_edit_falloff=‘SMOOTH’, proportional_size=1, release_confirm=True)
#
bpy.context.object.rotation_euler = (0.0174532 * (270 + math.degrees(math.acos((garums_x_y)/(garums)))), 0.0174532 * 180, 0.0174532 * (270 + math.degrees(math.atan((y2 - y1)/(x2 - x1)))))
if x1 > x2 and y1 <= y2 and z1 > z2:
garums_x_y = sqrt(pow(x2 - x1,2) + pow(y2 - y1 ,2))
garums = sqrt(pow(garums_x_y,2) + pow(z2 - z1,2))
bpy.context.object.dimensions[2] = garums
#
bpy.context.scene.cursor_location = (0.0, 0.0, -garums/2)
bpy.ops.object.origin_set(type=‘ORIGIN_CURSOR’)
#aaa
bpy.ops.transform.translate(value=(x1, y1, z1 + (garums/2)), constraint_axis=(False, False, False), constraint_orientation=‘GLOBAL’, mirror=False, proportional=‘DISABLED’, proportional_edit_falloff=‘SMOOTH’, proportional_size=1, release_confirm=True)
#
bpy.context.object.rotation_euler = (0.0174532 * (90 + math.degrees(math.acos((garums_x_y)/(garums)))), 0, 0.0174532 * (270 + math.degrees(math.atan((y2 - y1)/(x2 - x1)))))
x1 = x2
y1 = y2
z1 = z2
First line: Well, how hard could it be?
Last line: :spin:
Very nice concept.
Yes, i figured out the indentation. I had to add from math import sqrt…strangely the console said sqrt is not defined; same as variables one and two (from bpy.context.object.name = “Sphere_” + “{}”.format(one) + “_{}”.format(two) ; i don’t understand much the second part of this line).
My problem now is that i am very rusty with trigonometry anyway thank you for sharing the code.
When I copy code form Eclipse and paste in Blender Python console - I did not get any error…
You can try:
line 10 - bpy.context.object.name = “Sphere_” + “0” + “_{}”.format(two)
and
before sqrt and pow put math. like
garums_x_y = math.sqrt(math.pow(x2 - x1,2) + math.pow(y2 - y1 ,2))
garums = math.sqrt(math.pow(garums_x_y,2) + math.pow(z2 - z1,2))