advanced shrinkwrap

hi there,

ive been working on a problem now with the help of a few people but this seems to be super difficult to do so im going to put it out here.
what i want to do is this:
http://www.pasteall.org/pic/46779

i have an interconnectivity/ ‘connection graph’ script which gives me square tubes that i want to drape over the ramp of my building. im wondering if theres some way to model this/ edit the following code to make these lines drape (on the z axis only) over the ramp i have. i have 247 objects that the interconnection script utilises so im not going to include them in the file because this would take forever! but if there is a way to do what im talking about pleaaaasseee get back to me :slight_smile:
im also including a blender file with the two components im talking about, the birds nest was just a visual example of what im trying to achieve.
any help would be amazingly appreciated :slight_smile:
heres the blend file:
http://www.pasteall.org/blend/19953

heres the script that gave me the tubes:

import bpy
import bmesh

from bpy.props import IntProperty, FloatProperty
from math import pi, sin, cos
from mathutils import Vector, Matrix

def z_up_matrix(n):
    """Get a rotation matrix that aligns given vector upwards."""
    b=n.xy.length
    l=n.length
    if b>0:
        return Matrix((
            (n.x*n.z/(b*l), n.y*n.z/(b*l), -b/l),
            (       -n.y/b,         n.x/b,    0),
            (            0,             0,    0)))
    else: #no need for rotation
        return Matrix((
            (1,         0, 0),
            (0, 1 if n.z>0 else -1, 0),
            (0,         0, 0)))

class Interconnect(bpy.types.Operator):
    """Connect all selected object by edges of a new mesh"""
    bl_idname = "mesh.interconnection_add"
    bl_label = "Interconnect"
    bl_options = {'REGISTER', 'UNDO'}

    width = FloatProperty(
            name="Width",
            description="Tube Width",
            default=0.05
            )
    sides = IntProperty(
            name="Sides",
            description="Count of sides of each tube",
            min=3, max=42,
            default=4
            )

    def execute(self, context):
        name = "Interconnection"
        mesh = bpy.data.meshes.new(name)
        bm = bmesh.new()

        for obj in context.selected_objects:
            bm.verts.new(obj.location)
        endpoints = [obj.location for obj in context.selected_objects]
        n, w = self.sides, self.width
        circle = [Vector((cos((2*i+1)*pi/n)*w, sin((2*i+1)*pi/n)*w, 0)) for i in range(n)]
        
        for ia, a in enumerate(endpoints):
            for b in endpoints[ia+1:]:
                rotation = z_up_matrix(b-a).transposed()
                cylinder = list()
                for point in circle:
                    cylinder.append(bm.verts.new(rotation*point+a))
                    cylinder.append(bm.verts.new(rotation*(point)+b))
                for i in range(n):
                    indices = (2*i, 2*i+1, (2*i+3)%(2*n), (2*i+2)%(2*n))
                    bm.faces.new([cylinder[index] for index in indices])
        bm.to_mesh(mesh)
        mesh.update()

        ob = bpy.data.objects.new(name, mesh)
        context.scene.objects.link(ob)
        return {'FINISHED'}

def register():
    bpy.utils.register_class(Interconnect)

def unregister():
    bpy.utils.unregister_class(Interconnect)

if __name__ == "__main__":
    register()

so ive been thinking on this some more and i had a thought. i was wondering maybe if it would be easier to tell the interconnection/ connectivity graph to first of all make flat planes instead of tubes.
then, would it be possible to tell the code that every time that the plane has gone say 5m in a direction on the xy axis to make a cut? that way, i would easily be able to shrinkwrap the thing over my ramp. when id finished shrink wrapping id simply manually cut the edges that were over the sides off, and use the extrude tool to turn the plane into tubes.
does this sound closer to a solution?
edit: i would need to be able to control the width (even if it was just inside the code itself) of the planes being made. but this is the same idea as this part of the code isnt it? except its a flat plane.


 width = FloatProperty(             name="Width",             description="Tube Width",             default=0.05

and maybe somewhere in here is where youd put the thing telling blender to make a cut every 1metre?


def z_up_matrix(n): “”“Get a rotation matrix that aligns given vector upwards.”"" b=n.xy.length l=n.length if b>0: return Matrix(( (n.xn.z/(bl), n.yn.z/(bl), -b/l), ( -n.y/b, n.x/b, 0), ( 0, 0, 0))) else: #no need for rotation return Matrix(( (1, 0, 0), (0, 1 if n.z>0 else -1, 0), (0, 0, 0)))