TXLWizard Examples

Introductory Example

Introduction

The following code demonstrates an introductory example usage of the TXLWizard for generating TXL files with python code.

The code can be found in the file Content/Example_Introduction.py. The resulting SVG image is shown in Figure Generated SVG Image.

Have a look at more advanced examples in Sections Simple Example and Advanced Example and at the Python Module Reference.

Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
###########################################
# Import Libraries / Initialize TXLWriter #
###########################################

# Import TXLWriter, the main class for generating TXL Output
import TXLWizard.TXLWriter

# Import Pre-Defined Shapes / Structures wrapped in functions
import TXLWizard.ShapeLibrary.Label

# Initialize TXLWriter
TXLWriter = TXLWizard.TXLWriter.TXLWriter()

#####################
# Define Structures #
#####################

## Sample Label ##

# Give the sample a nice label
SampleLabelObject = TXLWizard.ShapeLibrary.Label.GetLabel(
    TXLWriter,
    Text='This is my text',
    OriginPoint=[-310, 240],
    FontSize=50,
    StrokeWidth=5,
    RoundCaps=True,  # Set to False to improve e-Beam performance
    Layer=1
)

## User Structure: Circle ##

# Create Content Structure for Circle with ID `MyCircle`
CircleStructure = TXLWriter.AddContentStructure('MyCircle')

# Add a `Pattern` of type `Circle`
CircleStructure.AddPattern(
    'Circle',
    Center=[0, 0],
    Radius=150,
    Layer=2
)

#########################
# Generate Output Files #
#########################

# Note: The suffix (.txl, .html, .svg) will be appended automatically
TXLWriter.GenerateFiles('Masks/Example_Introduction')

Generated SVG Image

../_images/Example_Introduction.png

Generated SVG Image for Content/Example_Introduction.py

Simple Example

Introduction

The following code demonstrates a simple example usage of the TXLWizard for generating TXL files with python code.

The code can be found in the file Content/Example_Simple.py. The resulting SVG image is shown in Figure Generated SVG Image.

A more advanced example is shown in Section Advanced Example

Code

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
####################
# Import Libraries #
####################

# Import TXLWriter, the main class for generating TXL Output
import TXLWizard.TXLWriter

# Import Pre-Defined Shapes / Structures wrapped in functions
import TXLWizard.ShapeLibrary.EndpointDetectionWindows
import TXLWizard.ShapeLibrary.Label

# Import math module for calculations
import math

#################################
# Sample / Structure Parameters #
#################################

# Define all sample parameters
SampleParameters = {
    'Width': 8e3,
    'Height': 8e3,
    'Label': 'Simple Demo',
}

# Define all structure parameters
StructureParameters = {
    'Circle': {
        'Radius': 50,
        'Layer': 3
    },
    'CircleArray': {
        'Columns': 6,
        'Rows': 5,
        'ArrayXOffset': 500,
        'ArrayYOffset': -500,
        'ArrayOrigin': [0.75e3, 3e3],
        'Label': 'R{i}C{j}',
    }
}

########################
# Initialize TXLWriter #
########################
TXLWriter = TXLWizard.TXLWriter.TXLWriter(
    GridWidth=SampleParameters['Width'],
    GridHeight=SampleParameters['Height']
)

#####################
# Define Structures #
#####################

## Sample Label ##

# Give the sample a nice label
SampleLabelObject = TXLWizard.ShapeLibrary.Label.GetLabel(
    TXLWriter,
    Text=SampleParameters['Label'],
    OriginPoint=[
        0.5e3, 1. * SampleParameters['Height'] / 2. - 500
    ],
    FontSize=150,
    StrokeWidth=20,
    RoundCaps=True,  # Set to False to improve e-Beam performance
    Layer=1
)

## Endpoint Detection ##

# Use Pre-Defined Endpoint Detection Windows
TXLWizard.ShapeLibrary.EndpointDetectionWindows.GetEndpointDetectionWindows(
    TXLWriter, Layer=1)

## User Structure: Circle ##

# Create Definition Structure for Circle that will be reused
CircleStructure = TXLWriter.AddDefinitionStructure('MyCircleID')
CircleStructure.AddPattern(
    'Circle',
    Center=[0, 0],
    Radius=StructureParameters['Circle']['Radius'],
    Layer=StructureParameters['Circle']['Layer']

)

# Create array of the definition structure above
CircleArray = TXLWriter.AddContentStructure('MyCircleArray')
CircleArray.AddPattern(
    'Array',
    ReferencedStructureID=CircleStructure.ID,
    OriginPoint=StructureParameters['CircleArray']['ArrayOrigin'],
    PositionDelta1=[
        StructureParameters['CircleArray']['ArrayXOffset'], 0
    ],
    PositionDelta2=[
        0, StructureParameters['CircleArray']['ArrayYOffset']
    ],
    Repetitions1=StructureParameters['CircleArray']['Columns'],
    Repetitions2=StructureParameters['CircleArray']['Rows']
)

#########################
# Generate Output Files #
#########################

# Note: The suffix (.txl, .html, .svg) will be appended automatically
TXLWriter.GenerateFiles('Masks/Example_Simple')

Generated SVG Image

../_images/Example_Simple.png

Generated SVG Image for Content/Example_Simple.py

TXLImport Example

Introduction

The following code demonstrates a simple example usage of the TXLWizard for importing existing TXL files and adding an array of labels.

The code can be found in the file Content/Example_ImportTXLFile.py. The resulting SVG image is shown in Figure Generated SVG Image.

A more advanced example is shown in Section Advanced Example

Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
####################
# Import Libraries #
####################

# Import TXLWriter, the main class for generating TXL Output
import TXLWizard.TXLWriter

# Import Pre-Defined Shapes / Structures wrapped in functions
import TXLWizard.ShapeLibrary.LabelArray

#################################
# Sample / Structure Parameters #
#################################

# Define all sample parameters
SampleParameters = {
    'Width': 8e3,
    'Height': 8e3,
    'Label': 'Simple Demo',
}

# Define all structure parameters
StructureParameters = {
    'CircleArray': {
        'Columns': 6,
        'Rows': 5,
        'ArrayXOffset': 500,
        'ArrayYOffset': -500,
        'ArrayOrigin': [0.75e3, 3e3],
        'Label': 'R{j}C{i}',  # {i} and {j} will be replaced
        # by str.format() with the corresponding auto-incremented index
        'LabelXOffset': 0,
        'LabelYOffset': 100,
    }
}

########################
# Initialize TXLWriter #
########################
TXLWriter = TXLWizard.TXLWriter.TXLWriter(
    GridWidth=SampleParameters['Width'],
    GridHeight=SampleParameters['Height']
)

# Import existing TXL file
TXLWriter.ImportTXLFile('Masks/Example_Simple.txl')

# label each array element
TXLWizard.ShapeLibrary.LabelArray.GetLabelArray(
    TXLWriter,
    StructureParameters['CircleArray']['Label'],
    OriginPoint=[
        StructureParameters['CircleArray']['ArrayOrigin'][0]
        + StructureParameters['CircleArray']['LabelXOffset'],
        StructureParameters['CircleArray']['ArrayOrigin'][1]
        + StructureParameters['CircleArray']['LabelYOffset']
    ],
    PositionDelta1=[
        StructureParameters['CircleArray']['ArrayXOffset'], 0
    ],
    PositionDelta2=[
        0, StructureParameters['CircleArray']['ArrayYOffset']
    ],
    Repetitions1=StructureParameters['CircleArray']['Columns'],
    Repetitions2=StructureParameters['CircleArray']['Rows']
)

#########################
# Generate Output Files #
#########################

# Note: The suffix (.txl, .html, .svg) will be appended automatically
TXLWriter.GenerateFiles('Masks/Example_ImportTXLFile')

Generated SVG Image

../_images/Example_ImportTXLFile.png

Generated SVG Image for Content/Example_ImportTXLFile.py

Advanced Example

Introduction

The following code demonstrates an advanced example usage of the TXLWizard for generating TXL files with python code.

The code can be found in the file Content/Example_Advanced.py. The resulting SVG image is shown in Figure Generated SVG Image.

Code

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
####################
# Import Libraries #
####################

# Import TXLWriter, the main class for generating TXL Output
import TXLWizard.TXLWriter

# Import Pre-Defined Shapes / Structures wrapped in functions
import TXLWizard.ShapeLibrary.EndpointDetectionWindows
import TXLWizard.ShapeLibrary.Label
import TXLWizard.ShapeLibrary.LabelArray
import TXLWizard.ShapeLibrary.AlignmentMarkers
import TXLWizard.ShapeLibrary.CornerCube

# Import math module for calculations
import math


#################################
# Sample / Structure Parameters #
#################################

# Define all sample parameters
SampleParameters = {
    'Width': 8e3,
    'Height': 8e3,
    'Label': 'GOI Demo CornerCube',
}

# Define all structure parameters
StructureParameters = {
    'CornerCube': {
        'BridgeLength':40,
        'ParabolaFocus': 45,
        'XCutoff': 45,
        'AirGapX': 15,
        'AirGapY': 5,
        'LabelXOffset': 0,
        'LabelYOffset': 150,
        'Label': 'R{i}C{j}', # {i} and {j} will be replaced
                               # by str.format() with the corresponding row / column index
        'Layer': 2
    },
    'Circle': {
        'Radius': 25,
        'Layer': 3
    },
    'CornerCubeArray': {
        'Columns': 6,
        'Rows': 3,
        'ArrayXOffset': 500,
        'ArrayYOffset': -500,
        'ArrayOrigin': [0.75e3, 3e3]
    }
}


########################
# Initialize TXLWriter #
########################
TXLWriter = TXLWizard.TXLWriter.TXLWriter(
    GridWidth=SampleParameters['Width'],
    GridHeight=SampleParameters['Height'],
    Precision=6 #increase the precision / resolution to 0.000001 (10^-6)
)

#####################
# Define Structures #
#####################

## Sample Label ##

# Give the sample a nice label...
SampleLabelObject = TXLWizard.ShapeLibrary.Label.GetLabel(
    TXLWriter,
    Text=SampleParameters['Label'],
    OriginPoint=[
        0.5e3, 1. * SampleParameters['Height'] / 2. - 500
    ],
    FontSize=150,
    StrokeWidth=20,
    RoundCaps=False,# Set to False to improve e-Beam performance
    Layer=1
)
# ...and some other information
Alphabet = TXLWizard.ShapeLibrary.Label.GetLabel(
    TXLWriter,
    Text='abcdefghijklmnopqrstuvwxyz0123456789 megamega ggg ah extraaaa rischaaaar',
    OriginPoint=[
        0.5e3, 1. * SampleParameters['Height'] / 2. - 600
    ],
    FontSize=50,
    StrokeWidth=3,
    RoundCaps=False, # Set to False to improve e-Beam performance
    Layer=1
)

## Endpoint Detection ##

# Use Pre-Defined Endpoint Detection Windows
TXLWizard.ShapeLibrary.EndpointDetectionWindows.GetEndpointDetectionWindows(
    TXLWriter, Layer=1
)

## Alignment Markers ##

# Use Pre-Defined Alignment Markers
TXLWizard.ShapeLibrary.AlignmentMarkers.GetAlignmentMarkers(
    TXLWriter, Layer=1
)


## User Structure: Corner Cube ##

# Create Definition Structure for Corner Cube that will be reused
CornerCubeDefinition = TXLWizard.ShapeLibrary.CornerCube.GetCornerCube(
    TXLWriter,
    ParabolaFocus=StructureParameters['CornerCube']['ParabolaFocus'],
    XCutoff=StructureParameters['CornerCube']['XCutoff'],
    AirGapX=StructureParameters['CornerCube']['AirGapX'],
    AirGapY=StructureParameters['CornerCube']['AirGapY'],
    Layer=StructureParameters['CornerCube']['Layer']
)

# Create Definition Structure for combination of cornercube and additional circle
FullCornerCubeNoRotation = TXLWriter.AddDefinitionStructure('FullCornerCubeNoRotation')
FullCornerCubeNoRotation.AddPattern(
    'Reference',
    ReferencedStructureID=CornerCubeDefinition.ID,
    OriginPoint=[1. * StructureParameters['CornerCube']['BridgeLength'] / 2., 0]
)
FullCornerCubeNoRotation.AddPattern(
    'Circle',
    Center=[0, 0],
    Radius=StructureParameters['Circle']['Radius'],
    Layer=StructureParameters['Circle']['Layer']
)

# Create definition structure with rotation of entire referenced structure
FullCornerCube = TXLWriter.AddDefinitionStructure('FullCornerCube',
                                                  RotationAngle=45)
FullCornerCube.AddPattern(
    'Reference',
    ReferencedStructureID=FullCornerCubeNoRotation.ID,
    OriginPoint=[0, 0]
)

# Create array of the definition structure above
CornerCubeArrayFine = TXLWriter.AddContentStructure('CornerCubeArrayFine')
CornerCubeArrayFine.AddPattern(
    'Array',
    ReferencedStructureID=FullCornerCube.ID,
    OriginPoint=StructureParameters['CornerCubeArray']['ArrayOrigin'],
    PositionDelta1=[
        StructureParameters['CornerCubeArray']['ArrayXOffset'], 0
    ],
    PositionDelta2=[
        0, StructureParameters['CornerCubeArray']['ArrayYOffset']
    ],
    Repetitions1=StructureParameters['CornerCubeArray']['Columns'],
    Repetitions2=StructureParameters['CornerCubeArray']['Rows']
)

# Add a label array to label each element of the array pattern above
TXLWizard.ShapeLibrary.LabelArray.GetLabelArray(
    TXLWriter,
    StructureParameters['CornerCube']['Label'],
    OriginPoint=[
        StructureParameters['CornerCubeArray']['ArrayOrigin'][0]
        + StructureParameters['CornerCube']['LabelXOffset'],
        StructureParameters['CornerCubeArray']['ArrayOrigin'][1]
        + StructureParameters['CornerCube']['LabelYOffset']
    ],
    PositionDelta1=[
        StructureParameters['CornerCubeArray']['ArrayXOffset'], 0
    ],
    PositionDelta2=[
        0, StructureParameters['CornerCubeArray']['ArrayYOffset']
    ],
    Repetitions1=StructureParameters['CornerCubeArray']['Columns'],
    Repetitions2=StructureParameters['CornerCubeArray']['Rows'],
    FontSize=40,
    StrokeWidth=3,
    RoundCaps=False,# Set to False to improve e-Beam performance
    Layer=1,
    RotationAngle=45
)



#########################
# Generate Output Files #
#########################

# Note: The suffix (.txl, .html, .svg) will be appended automatically
TXLWriter.GenerateFiles('Masks/Example_Advanced')

Generated SVG Image

../_images/Example_Advanced.png

Generated SVG Image for Content/Example_Advanced.py