0
$\begingroup$

I'm trying to create a script for automatic handrails. For extruding my edges I have tried converting them to curve and applying bevel, however I'm not satisfied with results, I wish the top rail wasn't rotated 45 degrees, and all beams were equal sizes (first and last are thinner at the top). I struggle with changing that, and I am not sure if thats the best approach to my problem. As pictured I would like to have something more square. I have also tried applying skin on edges, however the results were somehow worse than this.

Edges

Convert to curve + bevel:

Convert to curve + bevel

Here's what I would like to achieve:

What I would like to achieve

My script for reference, Maybe someone will find it useful, It just automates part of the work

# Creates vertical bars (edges) on selected vertices in edit mode

import bpy
import bmesh 
from mathutils import Vector

beam_height = 1

obj = bpy.context.object
bpy.ops.object.mode_set(mode = 'OBJECT')

verts_ind = [i.index for i in obj.data.vertices if i.select]
bpy.ops.object.mode_set(mode = 'EDIT')

for index, i in enumerate(verts_ind):
    local_co = obj.data.vertices[i].co
    transformed_co = Vector((local_co.x, local_co.y, local_co.z + beam_height)) 
    bpy.ops.object.mode_set(mode = 'OBJECT')
    Verts = [local_co, transformed_co]
    Edges = [[0, 1]]
    profile_mesh = bpy.data.meshes.new("Edge")
    profile_mesh.from_pydata(Verts, Edges, [])
    profile_mesh.update()
    bpy.ops.object.mode_set(mode = 'OBJECT')
    profile_object = bpy.data.objects.new("Base_Profile", profile_mesh)
    bpy.context.collection.objects.link(profile_object)
    
    
bpy.ops.object.mode_set(mode = 'OBJECT')
$\endgroup$
2
  • $\begingroup$ Hello and welcome. It's not clear what your expected result is. Please attach a screenshot of the final result you want. Model it manually and show how you want it to look after script execution. $\endgroup$
    – Harry McKenzie
    Commented Apr 20, 2023 at 1:26
  • $\begingroup$ I modelled it on the third picture $\endgroup$
    – mikazz
    Commented Apr 20, 2023 at 2:54

0

You must log in to answer this question.

Browse other questions tagged .