Using Blender Python to create maille.
View previous topic | View next topic >
Post new topic Reply to topic
M.A.I.L. Forum Index -> Knitting Circle
   
Author Message

Joined: January 17, 2013
Posts: 373
Submissions: 5
Location: Probably in the garage...

Reply with quote
Posted on Thu Oct 17, 2013 8:51 pm
Link to Post: Link to Post

After a few quick tests it seems that using an array while helpful for creating the initial chain, seems to affect the physics by treating the whole array as one solid object.

Here's what I did.

Created a Torus, added an Array modifier, increased the Count to 10.
Added Collisions and Rigid Body to the torus as before, duplicated the tori and rotated them 90 degrees and offset them so they all intersect. Tried applying the Col and RB before making into an array, didn't change the behavior.
Created a stationary ring to hold the chain in space. Moved it into place so it's linked with the first torus.
When I play the animation only the first ring behaves as it should the rest of the array just hangs off the side of that ring.

Maybe I'm missing something but off the top it seems like array's and physics don't mix well.

Once you have a single unit for the weave you want, say a fivelet for E4in1 just duplicate it, move it over and line it up, now grab both sheets and repeat. Your sheet will double in size each time you do this.

I made an E8in2 sheet with 2356 rings last night in a few minutes. Now I just have to stretch it out and make sure I don't have any stitching errors.
To stretch out a sheet add a plane bigger than your sheet that will serve as a table. I like to incline the plane a bit so gravity helps pull the sheet taunt.

Using a plane as a table keeps the physics on the rings to a minimum, stopping them from breaking and pulling through each other vs just hanging them from a stationary ring or two.


Mostly Harmless

Joined: September 24, 2012
Posts: 93
Submissions: 1
Location: Stockholm, Sweden

E4-1 Blender Script
Reply with quote
Posted on Tue Oct 22, 2013 10:32 am || Last edited by Carolides on Wed Oct 30, 2013 1:42 pm; edited 1 time in total
Link to Post: Link to Post

Removed old Code.

Joined: February 7, 2012
Posts: 99
Submissions: 1

Reply with quote
Posted on Tue Oct 22, 2013 3:18 pm
Link to Post: Link to Post

Ah yes, my bad. Array is an object modifier, so of course all the rings would count as a single object. Still should work for a top row you want to be static for the rest to hang off of, but unless you find a way to split the rings into individual objects all at once after applying physics, it may be a bust.
I wouldn't be surprised if there were a way to separate parts of a mesh that are not connected to each other, but I don't know of it if it exists.

Joined: January 17, 2013
Posts: 373
Submissions: 5
Location: Probably in the garage...

Reply with quote
Posted on Tue Oct 22, 2013 6:35 pm
Link to Post: Link to Post

First off I have one fairly significant item to address with my previous instructions.

Collisions do NOT need to be enabled. Turning on Rigid Body alone is enough.

I haven't spent much time with arrays but as I learn other methods of doing things I'm thinking I can figure out a way to lay out the rings using an array, make them individual objects then apply the Rigid Body to them all. I'll play around this afternoon.

I've figured out how to give the rings a saw cut look without too much work.

Check out my latest J4in1 sheet pre-gravity with saw cut titanium rings on a purple mirror with a tree in the background.



I've managed to get a few different weaves laid-out, Byz, 2in1, 2in2, E4in1, E6in1, E8in2, J4in1, J6in1, J8in1 and a few others. Once I re-do them with the saw cut rings I'll post them for you all to play with along with some fun ways of tweaking them.


Mostly Harmless

Joined: September 30, 2012
Posts: 255
Submissions: 13
Location: Sweden

Reply with quote
Posted on Tue Oct 22, 2013 9:41 pm
Link to Post: Link to Post

As an everyday user of Blender I must confess that I've actually been looking to try this myself but never gotten around to it. I might actually do it now!


"When in doubt... C4" - Jamie Hyneman

My YouTube channel: http://www.youtube.com/wpa09
My band: http://www.facebook.com/carnosus

"This is an art form, and we love to be recognized for our own work, and we'd all hope not to be confused with someone else."
- Charon, March 27, 2009

Joined: January 17, 2013
Posts: 373
Submissions: 5
Location: Probably in the garage...

Reply with quote
Posted on Tue Oct 22, 2013 10:16 pm
Link to Post: Link to Post

Carolides: I'm not sure if I've missed something...When I run your script it creates a bunch of blue rings along with 4 red ones but they are all laying flat. Sorta looks like a waffle, when animated all but 3 of the blue rings just fall to the ground.
Otherwise that seems like a real easy way to share base weaves.


Mostly Harmless

Joined: September 24, 2012
Posts: 93
Submissions: 1
Location: Stockholm, Sweden

Reply with quote
Posted on Wed Oct 23, 2013 4:29 am
Link to Post: Link to Post

Seems to be a Blender bugg.

All should fall down except the red.

BR
C

Joined: January 17, 2013
Posts: 373
Submissions: 5
Location: Probably in the garage...

Reply with quote
Posted on Wed Oct 23, 2013 2:00 pm
Link to Post: Link to Post

Here's an image of what I get after running the script. The rings are there, they just don't seem to have any rotation assigned to them.



From a bit of digging I've done this morning it looks like adding say

"bpy.context.active_object.rotation_euler=[0.25, 0.4, 0]"

to the red rings applies the rotation to the rings but I think more loops will be needed to stager and link the rings properly.

I added
"bpy.context.active_object.rotation_euler=[-1, 0.5, 9]"
to the blue rings and now they link properly with the red rings.

I know the angles are not correct for E4in1 but without more loops it's not going to layout properly.

If you want to pull the object data from something you've already created, go to the console and type (not including the outer quotes)
"Ring = bpy.data.objects["Torus.007"]" press Enter, Torus.007 is the ring I want to inspect, the Scene list (top right) show all the object names.
Next, type
"Ring.rotation_euler" press Enter.
You should see something like this.
Euler((1.570796251296997, -1.6406104564666748, -8.837557174956601e-07), 'XYZ')
Now if you type.
"bpy.context.active_object.rotation_euler=[1, 0.5, 9]"
the object will rotate to the new values.

I'm out of time this morning but here's what I get since assigning the rotation values.



Mostly Harmless

Joined: September 24, 2012
Posts: 93
Submissions: 1
Location: Stockholm, Sweden

Reply with quote
Posted on Wed Oct 23, 2013 5:43 pm
Link to Post: Link to Post

Damn copy paste.
I will update the post with the correct code.

Joined: February 7, 2012
Posts: 99
Submissions: 1

Reply with quote
Posted on Thu Oct 24, 2013 1:11 am
Link to Post: Link to Post

I don't know, man; looks more like Krumkake to me.

Joined: January 17, 2013
Posts: 373
Submissions: 5
Location: Probably in the garage...

Reply with quote
Posted on Thu Oct 24, 2013 2:22 am
Link to Post: Link to Post

The loops are fine just add

"bpy.context.active_object.rotation_euler=[0, 1.83, 0]" to red
"bpy.context.active_object.rotation_euler=[0, 0.26, 0]" to blue 1
"bpy.context.active_object.rotation_euler=[0, 0.-26, 0]" to blue 2
"bpy.context.active_object.rotation_euler=[0, 0.26, 0]" to blue 3

Works like a charm, making a nice sheet of E4in1.

To add rows and columns change

i_loopindex_outer = -3
i_loopindex_inner = -3

to say

i_loopindex_outer = -8
i_loopindex_inner = -8

to get an 8x8 or 64 ring sheet.


Mostly Harmless

Joined: September 24, 2012
Posts: 93
Submissions: 1
Location: Stockholm, Sweden

Reply with quote
Posted on Thu Oct 24, 2013 8:12 am || Last edited by Carolides on Wed Oct 30, 2013 1:42 pm; edited 1 time in total
Link to Post: Link to Post

Removed old code

Joined: September 24, 2012
Posts: 93
Submissions: 1
Location: Stockholm, Sweden

Reply with quote
Posted on Thu Oct 24, 2013 8:17 am
Link to Post: Link to Post

Ported JPL3.

Suspect i ported the wrong JPL 3 file. Seems static to me. The rings spiral nicely but intersect and AR seems to be 3.4.

Code:
#
# Initial code by Zlosk (mailler@zlosk.com) 11-18-2002 for POV-Ray
# Ported by Carolides (Changed some variable names so they make sense to me
# Use as you please but not commercially
#

# Imports
import bpy
import math
from bpy import context
from math import cos, sin, radians, atan, asin, pi

# Declare and lock layers
bpy.context.scene.layers[0] = False
bpy.context.scene.layers[2] = True

#declare Main_Ring_WireDia      = .080;
#declare Main_Ring_ID           = 3.274 * Main_Ring_WireDia;
#declare dx                     = 1.5914 * Main_Ring_WireDia;
# Declare ring sizes
f_Main_Ring_Wire_Diameter = 0.1
f_Main_Ring_Inner_Diameter = 3.274 * f_Main_Ring_Wire_Diameter
f_dx = 1.5914 * f_Main_Ring_Wire_Diameter


i_Ring_Multiple = 10
i_Infinite_Dist_Multiple = 40
i_start = 1
i_number_of_rings = 20

# Perform secondary calcs
f_Main_Ring_Wire_Diameter = i_Ring_Multiple * f_Main_Ring_Wire_Diameter
f_Main_Ring_Inner_Diameter = i_Ring_Multiple * f_Main_Ring_Inner_Diameter
f_dx = i_Ring_Multiple * f_dx


print ('f_dx: ' + str(f_dx))

def makeMaterial(name, diffuse, specular, alpha):
    mat = bpy.data.materials.new(name)
    mat.diffuse_color = diffuse
    mat.diffuse_shader = 'LAMBERT'
    mat.diffuse_intensity = 1.0
    mat.specular_color = specular
    mat.specular_shader = 'COOKTORR'
    mat.specular_intensity = 0.5
    mat.alpha = alpha
    mat.ambient = 1
    return mat
 
def setMaterial(ob, mat):
    me = ob.data
    me.materials.append(mat)

obj_Torus = bpy.ops.mesh.primitive_torus_add

mat_white = makeMaterial('White', (1,1,1), (1,1,1), 1)

for x in range(1, i_number_of_rings):
    obj_Torus(location=(i_start*f_dx, 0.0, 0.0), rotation=((-120 * i_start + 15), 0, 12.1), major_segments=48, minor_segments=48, minor_radius=f_Main_Ring_Wire_Diameter / 2, major_radius=(f_Main_Ring_Inner_Diameter + f_Main_Ring_Wire_Diameter) / 2)
    setMaterial(bpy.context.object, mat_white)
    bpy.ops.rigidbody.object_add(type='ACTIVE')
    bpy.ops.object.modifier_add(type='COLLISION')
    bpy.context.object.rigid_body.collision_shape = 'MESH'
    bpy.context.object.rigid_body.collision_margin = 0.001
    i_start = i_start + 1
#           
   

Joined: August 05, 2010
Posts: 623
Submissions: 28
Location: Bar Harbor, ME, USA

Reply with quote
Posted on Thu Oct 24, 2013 4:12 pm
Link to Post: Link to Post

Carolides wrote:
The rings spiral nicely but intersect and AR seems to be 3.4.


Could grab my equations, as they seem to work for AR2.8-3.1. I've also noticed that sometimes smoothness of the torus also affect how well they intersect. 3.4 seems a bit high for fusing to occur already.


while(!project.isFinished())
project.addRing();
// Maille Code V2.0 T7.1 R5.6 Eo.n Fper MFe.s Wsm Caws G0.8-1.6 I2.4-8.0 Pn Dcdejst Xw1 S07

Joined: September 24, 2012
Posts: 93
Submissions: 1
Location: Stockholm, Sweden

Reply with quote
Posted on Thu Oct 24, 2013 5:14 pm
Link to Post: Link to Post

BTW
Is there any intrest in the subject? So i don't "bump" the thread in vain.

BR
C

Post new topic Reply to topic
Jump to:  
Page 2 of 7. Goto page Previous  1, 2, 3, 4, 5, 6, 7  Next
All times are GMT. The time now is Tue Apr 07, 2020 9:56 am
M.A.I.L. Forum Index -> Knitting Circle
Display posts from previous: