User Guide

From TexGen
Revision as of 12:01, 31 October 2006 by WikiSysop (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Introduction

There are several ways to interface with TexGen. The two main methods from the user's point of view are as follows:

As with all applications the advantage of using a GUI is that it is easy to use. The advantage of using the Python interface is that performing batch jobs is much easier. A third alternative is to interface with TexGen is C++, however this is beyond the scope of this tutorial.

Graphical User Interface

In order for the GUI to function the same version of Python that was embedded in TexGen must be installed on the computer. Furthermore the following files must be within the same folder as the executable:

TexGenCore.dll
Completer.py
TexGen.py
TexGenVTK.py
TexGenExport.py
_TexGen.pyd
_TexGenVTK.pyd
_TexGenExport.pyd

Python Interface

Python is a high level interpreted programming language. In the case of TexGen it is used as a scripting language to allow easy access to TexGen functionality. Python has been embedded in the TexGen GUI which allows the GUI to run python scripts. It is not the goal of this guide to teach you how to program in Python. There are many resources online for that. A few of them are listed below:

You will not need an advanced knowledge of Python in order to write simple TexGen scripts. However, bear in mind that Python is a very powerful language with many libraries included for performing common tasks. I suggest you try to follow through the example below and if you get stuck refer to one of the documents above.

Example Script

In this example, we will create a simple 2x2 plain weave model with a Python script. The first step is to create an instance of the CTextileWeave2D class and give it a name, weave:

weave = CTextileWeave2D(2, 2, 1, 0.2, True)

The CTextileWeave2D class takes 5 parameters in the order shown below:

  • Number of weft yarns in the unit cell
  • Number of warp yarns in the unit cell
  • Spacing between the yarns
  • Thickness of the fabrics
  • Refine model (True/False)

The only parameter that really needs an explanation here is the Refine model option, this controls wether or not the interference correction algorithm will be applied to keep the yarn volumes from intersecting which is a common problem.

This is the bare minimum information necessary to create a 2D woven fabric. In the following steps we will add more information to create the model the way we want it.

Let's set the weave pattern, this determines whether a warp or weft yarn will appear on top at a particular cross over. Cross overs are arranged in 2d grid of size specified above. To swap the positions of the weft and warp yarns, we call the function SwapPosition with the coordinates of the cross over. In order to create a plain weave we need to do this twice on two diagonally opposite cross overs like so:

weave.SwapPosition(0, 0)
weave.SwapPosition(1, 1)

Now lets add our weave model to the database of models so that TexGen can render it:

AddTextile(weave)