Skip to main content

Python bindings for the TexGen textile geometry modeller

Project description

pytexgen

PyPI version Python License: GPL v2 Platform

Python bindings for TexGen — an open-source geometric textile modelling software package developed at the University of Nottingham for obtaining engineering properties of woven textiles and textile composites.

pytexgen brings the full power of the TexGen C++ engine to Python, enabling scripted creation, analysis, and export of textile geometries for computational mechanics workflows.

Features

  • Comprehensive textile modelling — 2D weaves, 3D weaves, angle interlocks, layer-to-layer, orthogonal weaves, knits, and braids
  • Sheared geometries — model fabrics under in-plane shear deformation with CShearedTextileWeave2D
  • Flexible yarn definition — full control over yarn paths, interpolation (cubic, linear, Bezier), and cross-sections (ellipse, lenticular, rectangle, polygon, power ellipse, and more)
  • Mesh generation — rectangular voxel, sheared voxel, staggered voxel, rotated voxel, octree voxel, tetrahedral (CTetgenMesh), and surface shell meshes
  • FEA export — direct export to Abaqus (.inp) and ANSYS formats with periodic boundary conditions
  • XML serialization — save and reload complete textile models as .tg3 / .tgx files
  • Geometric analysis — fibre volume fraction, yarn path queries, interference detection, and domain clipping
  • Cross-platform — pre-built wheels for Linux (x86_64, aarch64), macOS (x86_64, arm64), and Windows (x86_64)

Installation

pip install pytexgen

Requires Python 3.8+. Pre-built binary wheels are provided for all major platforms — no compiler or C++ dependencies needed.

Quick Start

2D Plain Weave

from pytexgen import *

weave = CTextileWeave2D(4, 4, 5.0, 2.0, False)
weave.SwapPosition(0, 3)
weave.SwapPosition(1, 2)
weave.SwapPosition(2, 1)
weave.SwapPosition(3, 0)
weave.SetYarnWidths(4.0)
weave.SetYarnHeights(0.8)
weave.AssignDefaultDomain()

name = AddTextile(weave)
SaveToXML("plain_weave.tg3", name, OUTPUT_STANDARD)

Sheared Weave with Voxel Mesh Export

import math
from pytexgen import *

shear_angle = math.radians(15)
textile = CShearedTextileWeave2D(2, 2, 1.0, 0.2, shear_angle, True, True)
textile.SwapPosition(1, 0)
textile.SwapPosition(0, 1)
textile.SetYarnWidths(0.8)
textile.SetYarnHeights(0.1)
textile.AssignDefaultDomain()

name = AddTextile(textile)

# Generate voxel mesh with periodic boundaries for Abaqus
voxel = CRectangularVoxelMesh("CPeriodicBoundaries")
voxel.SaveVoxelMesh(textile, "sheared_weave.inp", 48, 48, 24, True, True, 5, 0)

Custom Yarn Paths

from pytexgen import *

textile = CTextile()

yarn = CYarn()
yarn.AddNode(CNode(XYZ(0, 0, 0)))
yarn.AddNode(CNode(XYZ(5, 0, 2)))
yarn.AddNode(CNode(XYZ(10, 0, 0)))
yarn.AssignInterpolation(CInterpolationCubic())
yarn.AssignSection(CYarnSectionConstant(CSectionEllipse(2.0, 1.0)))
yarn.SetResolution(20)
yarn.AddRepeat(XYZ(10, 0, 0))
textile.AddYarn(yarn)

textile.AssignDomain(CDomainPlanes(XYZ(0, 0, -1), XYZ(10, 10, 3)))
AddTextile("custom", textile)

API Overview

Textile Classes

Class Description
CTextile Base class — build from individual yarns
CTextileWeave2D 2D woven textile with interlacing pattern
CShearedTextileWeave2D 2D weave under in-plane shear
CTextileWeave3D 3D woven textile (multi-layer)
CTextileOrthogonal Orthogonal 3D weave
CTextileAngleInterlock Angle interlock weave
CTextileLayerToLayer Layer-to-layer interlock weave
CTextileLayered Combine multiple textiles into layers

Cross-Sections

Class Shape
CSectionEllipse(w, h) Elliptical
CSectionLenticular(w, h) Lens-shaped
CSectionRectangle(w, h) Rectangular
CSectionPolygon(points) Arbitrary polygon
CSectionPowerEllipse(w, h, p) Superellipse
CSectionRotated(section, angle) Rotated variant

Mesh Generation

Class Description
CRectangularVoxelMesh(bc) Axis-aligned voxel mesh
CShearedVoxelMesh(bc) Voxel mesh for sheared textiles
CStaggeredVoxelMesh(bc) Staggered offset voxel mesh
CRotatedVoxelMesh(bc) Rotated coordinate voxel mesh
COctreeVoxelMesh(bc) Adaptive octree refinement
CTetgenMesh(min_size) Tetrahedral mesh via TetGen
CSurfaceMesh() Surface triangulation

Export Formats

Format Method Use Case
TexGen XML (.tg3) SaveToXML() Save/reload textile models
Abaqus (.inp) SaveVoxelMesh() / SaveTetgenMesh() Finite element analysis
ANSYS pytexgen.Ansys module ANSYS FEA
WiseTex pytexgen.WiseTex module Permeability analysis
FlowTex pytexgen.FlowTex module Flow simulation

Building from Source

git clone https://github.com/yufangjie1643/pytexgen.git
cd pytexgen
pip install scikit-build-core
pip install -e .

Requires CMake 3.17+, a C++ compiler, and SWIG.

Upstream Project

pytexgen is the Python packaging of TexGen, originally developed by Louise Brown and collaborators at the University of Nottingham, Composites Research Group.

For academic use, please cite:

Lin, H., Brown, L.P. and Long, A.C. (2011). Modelling and Simulating Textile Structures using TexGen. Advanced Materials Research, Vols. 331, pp 44-47.

License

GPL-2.0-or-later — see LICENSE for details.

Full documentation and more examples: GitHub

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pytexgen-1.0.1-cp314-cp314-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.14Windows x86-64

pytexgen-1.0.1-cp313-cp313-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.13Windows x86-64

pytexgen-1.0.1-cp312-cp312-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.12Windows x86-64

pytexgen-1.0.1-cp311-cp311-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.11Windows x86-64

pytexgen-1.0.1-cp310-cp310-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.10Windows x86-64

pytexgen-1.0.1-cp39-cp39-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.9Windows x86-64

pytexgen-1.0.1-cp38-cp38-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.8Windows x86-64

pytexgen-1.0.1-cp37-cp37m-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.7mWindows x86-64

File details

Details for the file pytexgen-1.0.1-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: pytexgen-1.0.1-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pytexgen-1.0.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 d2a79279dc347c7eed6abbe2fbaa5d2ca04ce9a5c95f682e87771cb9fb8a971d
MD5 aeced30b51132bde56b464913c8eb9db
BLAKE2b-256 300a5b10b159c50153ef216f3f88444fdda66e8ae52fd76afd7ada550947bb54

See more details on using hashes here.

File details

Details for the file pytexgen-1.0.1-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pytexgen-1.0.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pytexgen-1.0.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 cb22ef2db52242909be139d6b785d2bb7e94c6a129f394f9e3afde67a22495f0
MD5 339e50d77f91ddac87c3eab0a84836f3
BLAKE2b-256 a669fac002758ffe42dd3ba041e7da55b9edfebd43c2c7b3519619a9d08770f2

See more details on using hashes here.

File details

Details for the file pytexgen-1.0.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pytexgen-1.0.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pytexgen-1.0.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 1391094540397470a2f3ba18edf9f14e8e1013d6b8ed2394436135038524b0f4
MD5 dffa94ae15881324cca93525066fd85e
BLAKE2b-256 3d6b48a4154d6547b56dc998b0d32628954c14e6d70b2968a2a37b003b4e7cb2

See more details on using hashes here.

File details

Details for the file pytexgen-1.0.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pytexgen-1.0.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pytexgen-1.0.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 738c9aa518880fd84761cebb2a07b8859973e10b7647144cd25546687bf6b793
MD5 acbfdd7ada7496f9fc67b0327f8a8197
BLAKE2b-256 eee1f7c90bdb41129f3b527d01a9e12f777bd8dd66b5f80271fd9d0b27bae880

See more details on using hashes here.

File details

Details for the file pytexgen-1.0.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pytexgen-1.0.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pytexgen-1.0.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e8bcff3b1983645e8259bbccc0f36bd0a21b581a4f24663d7f2e32f1db6d7380
MD5 66dca34ce0c66a494bf7cb01d26e51c9
BLAKE2b-256 f422c4b5ad7f30891fe232be7d57690c13cb22373fa49539ed7baefd619bd7ed

See more details on using hashes here.

File details

Details for the file pytexgen-1.0.1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: pytexgen-1.0.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pytexgen-1.0.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 f31637399049ebffac6b52ecbde8f88a10c611a8681b6a2c15593293a22baaf5
MD5 8e7011f6b238bf8a6d4e47ae41724869
BLAKE2b-256 4c3b3a1934f83f8253c22cef6fdf88037d9b1cf39cdd43e012cf5a320241011c

See more details on using hashes here.

File details

Details for the file pytexgen-1.0.1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: pytexgen-1.0.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pytexgen-1.0.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 03f3bea2c6a4db28273a531e1f6b92d24764a90d1f6eff5e97701108c31a77c2
MD5 9e6c13f8728231f98ebc3efda11252db
BLAKE2b-256 85b1b24a0b3a0b06ad93bb86be360a17c51518d773085e8da4e5b27da258134a

See more details on using hashes here.

File details

Details for the file pytexgen-1.0.1-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: pytexgen-1.0.1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pytexgen-1.0.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 a89a3b22e4b6cc55599fce23f63d9e35dda35dc9d8f1a34da3b8e58055eb8bd0
MD5 f3b61e7ba4c1071d41bef8a341af852c
BLAKE2b-256 07036e555ebbc040ac277959c25a32b8863c2df399ca6c91da5ae058bf169e8e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page