2
$\begingroup$

I am doing some modeling to illustrate a specific math geometry. I want to create a tilted line through a point cable_aufpunkt.

import bpy
import numpy as np

cabel_rot_x = 5 * np.pi / 180  # 5° rotation around x axis
cable_rot_y = 3 * np.pi / 180  # 3° rotation around y axis
cable_len = 20  # in meter
cable_radius = .03
cable_depth = .5
cable_dist = .55

cable_aufpunkt = np.array([cable_dist, cable_depth, 0])
bpy.ops.mesh.primitive_cylinder_add(location=cable_aufpunkt,
                                    scale=(cable_radius, cable_radius, cable_len),
                                    rotation=(cabel_rot_x, cable_rot_y, np.pi / 2))

However, this line does not touch the point which I specified as location. It got rotated away from it by the rotation=(). I would like for the object to revolve around its median point. How can I do that? Is that even possible at creation time, or do I need to move and rotate it after creating it?

$\endgroup$
4
  • $\begingroup$ try to rotate in a second op, after creation. $\endgroup$
    – high_byte
    Oct 16, 2021 at 11:02
  • $\begingroup$ May find these useful. The default origin of a cyl is its median. Object rotation uses origin as pivot. blender.stackexchange.com/a/214497/15543 blender.stackexchange.com/a/214678/15543 $\endgroup$
    – batFINGER
    Oct 16, 2021 at 14:23
  • $\begingroup$ @HananBeer what rotation command would be the right one? $\endgroup$ Oct 16, 2021 at 16:50
  • 1
    $\begingroup$ I think you want bpy.ops.transform.rotate(value=3.14) (~pi to rotate 180 degrees) $\endgroup$
    – high_byte
    Oct 16, 2021 at 19:51

0

You must log in to answer this question.

Browse other questions tagged .