I just started using TexGen and I am also very new to phyton.
I've already created the pattern for the binding yarns of my textile following the examples. I need to add another yarn very close to each binding yarn only on the top and bottom layers. Is that a way to set the position of that yarn using the same input as SetBinderPosition (1,1,0,0 for example) as opposed to the cartesian coordinates?
I've also been looking at the documentation AddXYarn seems good for this case, however, it is not very clear to me what the vector PATTERN3D means.
Code: Select all
#LayerToLayer
nx = 4# number of x (warp & binder) yarns
ny = 4#number of y (weft) yarns
sx = 1#x (warp / binder) yarn spacing
sy = 1#y (weft) yarn spacing
hx = 0.2#x (warp / binder) yarn heights
hy = 0.2#y ( weft) yarn heights
#number of layers
nweft = 5 #number of weft layers
nwarp = nweft -1 #number of warp layers
nbl = nweft - 2 #number of binder layers
#yarn dimensions and shape
wy = 0.8#width of yarns on y direction(weft)
wb = 0.4#binder yarn width
hb = 0.1#binder yarn heights
#create layer to layer textile
weave = CTextileLayerToLayer(nx,ny,sx,sy,hx,hy,nbl)
#setting ratio of warp to binder yarsn
rwarp = 0 #warp ratio
rbind = 1 #binder yarn ratio
weave.SetWarpRatio (rwarp)
weave.SetBinderRatio (rbind) #If the warp ratio is 0 then all yarns in the x direction will be binders
#setting up the layers
weave.SetupLayers(nwarp,nweft,nbl)
#set yarn dimensions: widths/heights
weave.SetYYarnWidths( wy )
weave.SetBinderYarnWidths( wb )
weave.SetBinderYarnHeights( hb )
#assign the z-positions to the binder yarns
P = [[0,3,2,1],[2,3,0,2],[3,0,2,2],[1,3,1,0]]
for y in xrange(0,nx):
offset = 0
for x in range(0,ny):
weave.SetBinderPosition(x,y,P[y][offset])
offset = offset + 1
#Pattern3D = [1,0,0]
#NewYarn = AddXYarn(1, Pattern3D)
# Create a new textile to contain the combination pattern
CombiTextile = CTextile()
# Get yarn pattern from the 3D weave
Pattern = weave.GetYarns()
#Add yarns to the combined textile
for Yarn in Pattern:
CombiTextile.AddYarn(Yarn)
#create the satin yarn
Yarnsatin = CYarn ()
#add nodes to the yarn
Yarnsatin.AddNode(CNode(XYZ(0,0,1)))
Yarnsatin.AddNode(CNode(XYZ(1,0,1)))
Yarnsatin.AddNode(CNode(XYZ(2,0,0)))
Yarnsatin.AddNode(CNode(XYZ(3,0,0)))
# Assign a constant cross-section all along the yarn of elliptical shape
Yarnsatin.AssignSection(CYarnSectionConstant(CSectionEllipse(0.4, 0.1)))
#adding the yarn to the textile
CombiTextile.AddYarn(Yarnsatin)
#add textile to database
AddTextile('Textile02',CombiTextile)