how to understand function SwapPosition

General discussion about TexGen.

Moderators: Martin, Developers

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

how to understand function SwapPosition

Post by LijunGu »

Hello Dr. Louise,

I don't know what's the mening of the parameters in function SwapPosition(x, y, ilevel1, ilevel2) after i checked the explanation during the question 'Adding yarn to a layer to layer interlock' in the forum.

Currently, my understanding is that:

x means columm of warp yarns, start from 0;
y means columm of weft yarns, start from 0;
iLevel1 means number of warp layer, start from 0;
iLevel2 means number of weft layer, start from 0;

I created a model using 'create 3D weave' panel in Weave.Try to undertsand this function, but didn't figure out.
analysis.JPG
analysis.JPG (118.42 KiB) Viewed 10202 times
Could you please give me some more detailed explanation about this function?


Thank you and 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: how to understand function SwapPosition

Post by louisepb »

Hello,

In order to understand this function you need to have understood how the 3D textiles work. Section 7.4 of the scripting guide describes the array of cells which contain the information about positions of warp and weft yarns in the textile. The SwapPosition function swaps the contents of the cell in the two levels at the x,y position given. So, if the function is called with parameter SwapPosition( 1, 2, 3, 4 ) cell at position 1,2 will be accessed. If the cell values at z position 3 and 4 are PATTERN3D_XYARN AND PATTERN3D_NOYARN then the function will swap these values so z value 3 has PATTERN_NOYARN after swapping.

Hope that helps,
Louise
LijunGu
Regular
Posts: 30
Joined: Mon Jun 01, 2020 4:49 am

Re: how to understand function SwapPosition

Post by LijunGu »

Hello,

how can i use the function 'SwapPosition' while weave created by CTextile()?
TexGen showing the error: TexGen 'CTextile' object has no attribute 'SwapPosition'

thank you and have a nice day!
louisepb
Project Leader
Posts: 998
Joined: Tue Dec 08, 2009 2:27 pm
Location: Nottingham

Re: how to understand function SwapPosition

Post by louisepb »

Hello,

Sorry for the slow reply, I hadn't noticed your new post.

The SwapPosition function is only implemented for the weave classes where the cell structure is used to define the textile. The CTextile class is the base class which simply contains a set of yarns. The inherited weave classes use the cell structure to build a set of yarns in the CTextile base class.

If you want to create a textile using just CTextile then you will need to define all of the positions for the nodes in the yarns yourself.

I hope that makes sense,
Louise
Post Reply