What I would like to achieve using python is,
Z = 0.0
Y = 0.0
Vertex 0 = -1.0
vertex 1 = 1.0
Rotation on y axis (top view)
Point of rotation is either Vertex 0, mid-point or Vertex1
The angle is user specified and point of rotation also (just hard coded)
Line should remain same length when angle is adjusted
When the distance between the 2 vertices is adjusted (I.E. V0 = 0.5 and V1 = 1.5 the angle should remain the same)
In the screenshot I tried to make example
First line (example) is straight 0 degrees
Second line (example) is 45 degrees angle and V0 = -1.0 and V1 = 1
Third line (example) is also 45 degrees angle but v0 = -1 and V1 = 0.
I just want to draw 2 vertices including an edge (3 might also be good so the vertex in the middle can be used as point of rotation) and change the angle of the edge.
But when the distance between the 2 vertices becomes smaller or bigger the angle should remain the same.
Important is that the vertices always stays on the given X axis grid point. Y axis needs to be recalculated to get the specified angle.
I would like to ask some help regarding mathutils and vectors (edges) At the moment I use this code to add 2 vertices (1 edge) But I would like to be able to adjust the angle of this line in such a way that no matter the distance between the 2 vertices the angle will always be fixed. I.E. 10 degrees or whatever I input as user. I search this forum and internet but could not find any similar to my question
import bpy import bmesh import mathutils from mathutils import Vector from bpy.types import Operator from bpy_extras.object_utils import AddObjectHelper, object_data_add from bpy.props import FloatVectorProperty verts = [(1, 1, 0), (-1, 1, 0)] mesh = bpy.data.meshes.new("mesh") # add a new mesh obj = bpy.data.objects.new("MyObject", mesh) # add a new object using the mesh scene = bpy.context.scene bpy.context.collection.objects.link(obj) # put the object into the scene (link) bpy.context.view_layer.objects.active = obj # set as the active object in the scene bpy.context.active_object.select_set(state=True) # select object mesh = bpy.context.object.data bm = bmesh.new() for v in verts: bm.verts.new(v) # add a new vert bm.edges.new(bm.verts) # make the bmesh the object's mesh bm.to_mesh(mesh) bm.free() # always do this when finished
The code below wil just draw a straight line from 1 to -1 (x axis) I would like to get an angle like the picture
it is important that the vertices stay in same line (x axis) as seen on the screenshot. So rotating the line would not give the result I am after.
As seen in the screenshot V1 and V2 are still on the same grid line in the x direction