something unexpected while using function ReplaceNode

General discussion about TexGen.

Moderators: Martin, Developers

Post Reply
LijunGu
Regular
Posts: 30
Joined: Mon Jun 01, 2020 4:49 am

something unexpected while using function ReplaceNode

Post by LijunGu »

Hello Dr. Louise,

There is one unexpected thing when using function ReplaceNode.
ReplaceNode.JPG
ReplaceNode.JPG (43.9 KiB) Viewed 3794 times
Below is my test script:

nx=4
ny=4
sx=3.0
sy=2.0
h_warp=0.4
w_warp=2.0
h_weft=0.5
w_weft=2.5
Layer_weft=4
Layer_warp=3
rwarp=0
rbind=1
#---------------------------------------------------------------------
# modelling
#---------------------------------------------------------------------
weave = CTextileLayerToLayer(nx, ny, sy, sx, h_warp, h_weft, Layer_warp)
weave.SetWarpRatio(rwarp)
weave.SetBinderRatio(rbind)

weave.SetupLayers( Layer_warp, Layer_weft, Layer_warp)

weave.SetYYarnWidths(w_weft)
weave.SetWarpYarnWidths(w_warp)
weave.SetBinderYarnWidths(w_warp)
weave.SetBinderYarnHeights(h_warp)

# assign the z-positions to the binder yarns
P = [
[0,1,2,1], [2,1,0,1], [1,2,1,0], [1,0,1,2],
]
for i in xrange(0, nx):
offset=0
for j in range(0, ny):
weave.SetBinderPosition(j, i , P[offset])
offset=offset+1


weave.SetWarpYarnPower( 0.6)
weave.SetWeftYarnPower( 0.8)
weave.SetBinderYarnPower( 0.8)

for i in range(4):
weave.SetXYarnWidths(i, w_warp)
weave.SetXYarnHeights(i, h_warp)
weave.SetXYarnSpacings(i, sy)

for i in range(4):
weave.SetYYarnWidths(i, w_weft)
weave.SetYYarnHeights(i, h_weft)
weave.SetYYarnSpacings(i, sx)

domain = CDomainPlanes(XYZ(0,0,-2*sz),XYZ(4*sx,4*sy,5))
weave.AssignDomain(domain)

iyarn=weave.GetYarn(27)
node=iyarn.GetNode(0)
coor=node.GetPosition()
modi_z=coor.z+0.5
Newnode=CNode(XYZ(coor.x,coor.y,modi_z))
iyarn.ReplaceNode(0,Newnode)

AddTextile("test", weave)

Do you know what's going on here?

Have a nice day for you and your team!
louisepb
Project Leader
Posts: 998
Joined: Tue Dec 08, 2009 2:27 pm
Location: Nottingham

Re: something unexpected while using function ReplaceNode

Post by louisepb »

Hello,

I haven't run your script but the textiles generated by the wizard are set up to be repeated using a repeat vector. In order for the yarn to be repeated and continuous the first and last nodes in the yarn need to be generated so that they are offset by the repeat. In the example you show the x and z coordinates would be the same but the last node would have a y coordinate of y_yarn0+ y_repeat.

Hope that helps,
Louise
Post Reply