Coupling TexGen geometry

General discussion about TexGen.

Moderators: Martin, Developers

Post Reply
dyeyanie
Regular
Posts: 154
Joined: Thu Oct 06, 2011 10:39 am

Coupling TexGen geometry

Post by dyeyanie »

Hi Louise,

I have another Q here. Is there any application that allow me to couple two or three of fibre patterns in a screen? Instead of generating it manually, could it be like "copy and paste" concept to generate another type of fibre pattern between the 2 patterns.

Cheers,
Yanie
louisepb
Project Leader
Posts: 998
Joined: Tue Dec 08, 2009 2:27 pm
Location: Nottingham

Re: Coupling TexGen geometry

Post by louisepb »

Hi Yanie,

Not entirely clear what you mean here but if you just want to copy and paste one or more yarns then you can select the yarn (shift + select for more than one) and then use the "Duplicate Yarn" button at the bottom of the Outliner window. The duplicate yarn(s) is created in the same position as the originals so it's not immediately apparent that it's actually created more yarns.

If that's not what you meant let me know!

Louise
dyeyanie
Regular
Posts: 154
Joined: Thu Oct 06, 2011 10:39 am

Re: Coupling TexGen geometry

Post by dyeyanie »

Hi Louise,

Sorry if you don't really get what I'm trying to say. Let me put this way. I would like to duplicate yarn fibre which is from another file. for example, I have Fibre A on the screen and I open another file (fibre B) and I will get two open files now. I would like to bring the fibre B geometry into fibre A geometry which are from two different files to become another geometry which generated from these two files. it's like from 2 becomes 1.

Yanie
louisepb
Project Leader
Posts: 998
Joined: Tue Dec 08, 2009 2:27 pm
Location: Nottingham

Re: Coupling TexGen geometry

Post by louisepb »

Hi Yanie,

I see what you mean now. There isn't a way to do this in the user interface. Assuming you created your textile in the user interface rather than using a script( in which case you could just edit your scripts) then I think the easiest thing would be to edit the tg3 file. You could take the <yarn> sections from one and add them to the other. You'd have to make sure that the yarn index wasn't duplicated - just rename it so you get a sequence of indices.

Louise
dyeyanie
Regular
Posts: 154
Joined: Thu Oct 06, 2011 10:39 am

Re: Coupling TexGen geometry

Post by dyeyanie »

Hi Louise,

Thanks for your idea. However, if I modify the <yarn section> and save the changes, the file will be in the .txt file. How could I get the .tg3 file in this case? As for yarn index, it means that every time I change my yarn section, I have to rename the yarn index, right?

Yanie
louisepb
Project Leader
Posts: 998
Joined: Tue Dec 08, 2009 2:27 pm
Location: Nottingham

Re: Coupling TexGen geometry

Post by louisepb »

Hi Yanie,

The tg3 file is just a renamed xml file. Rename your file with a .tg3 extension and it should work fine.

For each <yarn index = "n" .....
<\yarn>
section you need to change n to specify the yarn index. Anything within the rest of that block will refer to that particular yarn.

Louise
dyeyanie
Regular
Posts: 154
Joined: Thu Oct 06, 2011 10:39 am

Re: Coupling TexGen geometry

Post by dyeyanie »

Hi Louise,

I'm trying to modify the XML file for another design pattern. Is it possible for me to create a loop of command in XML? Meaning to say for the next iteration it is automatically generated by the loop.

Yanie
louisepb
Project Leader
Posts: 998
Joined: Tue Dec 08, 2009 2:27 pm
Location: Nottingham

Re: Coupling TexGen geometry

Post by louisepb »

Hi Yanie,

XML is a markup language not a programming language. It simply gives a human and machine readable way of transporting data. There's a good tutorial here: http://www.w3schools.com/xml/default.asp

If you want to use loops to create textiles then you'll need to write a Python script. There's a scripting guide on the TexGen webpage here: http://texgen.sourceforge.net/index.php/Scripting_Guide

Louise
dyeyanie
Regular
Posts: 154
Joined: Thu Oct 06, 2011 10:39 am

Re: Coupling TexGen geometry

Post by dyeyanie »

Hi Louise,

I've tried to generate one and it works. The problem now is on PatternCell and PatternElement value. I'm trying to modify this to the current pattern that I have. How could i command this in python?Or are they have been included in the source code?

Yanie
louisepb
Project Leader
Posts: 998
Joined: Tue Dec 08, 2009 2:27 pm
Location: Nottingham

Re: Coupling TexGen geometry

Post by louisepb »

Hi Yanie,

The pattern cell and pattern element values are stored in the CTextileWeave2D class. They are protected variables so you cannot set them directly. You need to use the SwapPosition or SwapAll functions. See here: http://texgen.sourceforge.net/api/class ... ve2_d.html

An example of generating a 2D weave using a script is given here: http://texgen.sourceforge.net/index.php ... ate_Models

Louise
Post Reply