2
$\begingroup$

I'm very new to Blender and I try to model a database (tables and connections between them), but I'm having problems with the connections. What's the "easiest" way to create those lines? A visual representation of what I'm talking about (replace the "red line" with the "blue line", so the 1st table is connected to the 4th one without crossing the 2nd table):

enter image description here

I'm creating the model by creating an .obj file in python then import it in Blender. Plus Kudos if you can show me a code for this problem, because currently I'm just creating a cube between the tables (the 4-4 vertices is at the center of the tables), but it's "aligned" only on the Y axis (if I rotate the connected table around the other table, making it aligned on the X axis, the cube becomes a plain because of the vertices' coordinates).

I know/think I have to use armatures, but I couldn't make it to work.

Thanks for the hints/help!

$\endgroup$
  • $\begingroup$ I'm not sure what you mean by "connection", ho should it appear? a red line? should it be animated when columns change height or position? $\endgroup$ – m.ardito Jan 3 '18 at 9:42
  • $\begingroup$ Sorry for the misleading "example", no, it doesn't have to be red (it's really not important, though I was thinking making the lines with cubes or cylinder), I just tried to highlight one connection from the image. So the goal is to be able to "grab" the line, and move a little bit. The line should also follow both tables, so if I move one of the tables, the line should "stick" to it. $\endgroup$ – Arklur Jan 3 '18 at 12:05
  • $\begingroup$ Definitely use curves, best to use a Bezier in this instance I'd say $\endgroup$ – VRM Jan 3 '18 at 12:53
  • $\begingroup$ Related: blender.stackexchange.com/q/41957/26640 $\endgroup$ – Scott Milner Jan 3 '18 at 14:39
  • $\begingroup$ For the python answer, look at the script made for this answer $\endgroup$ – sambler Jan 5 '18 at 23:02
2
$\begingroup$

One rough way could be using two empties for every "connection" shape, each hooked at one of the shape ends. Ten set a "copy location" constraint for each empty to its "column", it works like this:

enter image description here

Edit: as you noted, the shape of the mesh (cylinder above but also cube has same issue) is stretched by its movement.

I found another way that seems to work without this issue: using a a curve to make the connection and a bezier circle to give it a "solid" shape:

enter image description here

It is made much like above but you create a hook to a new empty selecting one of the curve (2 control points, shape straightened before, and set to handle type "vector") end, then using again CTRLH to make the hook menu appear, then selecting "new empty object".

enter image description here

As above, the empties have "copy location" constraints to each cube, but this time the "connection bar" is not stretched anymore, whatever the columns movement...

enter image description here

Of course it works also with scaling (here using a convenient transform pivot mode: cursor)

enter image description here

note: if you prefer a "squared" connector, just model the bezier circle to a square shape (or whatever), the connector profile is immediately updated

edit2: since you are missing some step, I tried a complete workflow (I hope it's not too long for this site):

start with the two "columns"

enter image description here

then in top view, place the cursor between them, and add a bezier

enter image description here

you will get this enter image description here

edit the bezier enter image description here

select both control points and scale them to zero over Y axis with SY0

(this will make the bezier a straight line)

enter image description here

then in object mode rotate 90° over Z with RZ90

enter image description here

note: here I also edited the bezier to have identical and symmetrical handles (it could be not necessary...), and then made both control points as "vector": select both, press V then choose "vector". This is needed.

enter image description here

now in front view you see

enter image description here

or (object mode):

enter image description here

now you need to add a hook to a new empty where each control point is, so select one of them, and press CTRLH and choose "hook to new empty object"

enter image description here

you'll get this

enter image description here

repeat for the other control point: now you have two empties hooked bt each bezier's control point

enter image description here

select one empty, and add a "copy location" constraint

enter image description here

with one cube as target

enter image description here

as you see instantly the empty copies the right cube position (object origin), and the bezier's control point follows (hooked to the empty)

enter image description here

now do the same for the other empty

enter image description here

as you see this is already working... but the connector is "invisible", because it's just a curve...

enter image description here

you need to bevel this curve with another "curve", so add a "bezier circle" in top view

enter image description here

you get this

enter image description here

if you set this object as bevel object of the "connector" bezier

enter image description here

the "connector" become solid, a visible cylinder shape

enter image description here

since it's quite big, scale the original bezier circle to your taste

enter image description here

and now is prettier

enter image description here

should you wish a different bevel profile (eg: a square) you always need a curve object, so you could transform the bezier circle into a bezier square: in edit mode, press V and select "vector"

enter image description here

you'll get this

enter image description here

and as you see the connector is now squared!

enter image description here

Here is the test file:

Have fun!

|improve this answer|||||
$\endgroup$
  • $\begingroup$ Hm...maybe it's just the gif, but aren't the "lines" change their shape? One of my problems is it should keep it, so the lines don't look like a plane if you place the tables in a specific way but always look like a cube/cuboid, has the same width/depth always. $\endgroup$ – Arklur Jan 3 '18 at 12:48
  • $\begingroup$ yes, true... perhaps there's a way... $\endgroup$ – m.ardito Jan 3 '18 at 13:07
  • $\begingroup$ I found another way, it seems better... edited the answer. $\endgroup$ – m.ardito Jan 3 '18 at 14:24
  • $\begingroup$ I've just read your edited answer and it looks great! I'm really new to Blender, so there are a few things I don't know hot to do (yet), but I'll accept your answer because it looks very promising, thank you very much! $\endgroup$ – Arklur Jan 4 '18 at 5:18
  • 1
    $\begingroup$ OK, good. I edited it again and added step-by-step workflow to setup this, and also a test file: have fun! $\endgroup$ – m.ardito Jan 4 '18 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.