The cartographic stylization engine in Topobase provides far better line stylization than AutoCAD can provide. For example, instead of just a single line with a pattern, thickness and color, you can have multiple lines of various thicknesses, with various embellishments and different joining and capping options. So, if you forgo fidelity when exporting data to a .dwg, you can take advantage of some excellent capabilities for line symbolization.
It is assumed that you have added layers using enhanced stylization, or set up the layer templates as described in Annotation Layers to automatically use enhanced stylization.
Start with a couple of standard line styles, one for a gas pipeline and one for a railway. These are standard linestyles that can be found in acad.lin, the AutoCAD line pattern definition file. They are named GAS_LINE and TRACKS respectively. Each has been given a little line thickness and a color. To be clear, what is shown in the image to the right are not AutoCAD lines, but rather linear features that have been symbolized to look like AutoCAD lines. There are discrepancies; for example, AutoCAD would not thicken the 'GAS' text when a polyline is given a width.
To put some context to these explorations, let's vary one thing at a time, starting with the geometry for the gas line. Let's say you wanted two parallel lines to run unbroken along each side of the linestring. If you open the pipeline layer file with a text editor you will see something like this (after formatting):
...
<SimpleSymbolDefinition>
<Name>GAS_LINE</Name>
<Graphics>
<Path>
<Geometry>M 6.5,0 l 0.166666666666667,0 M 6.66666666666667,0 ... </Geometry>
<LineColor>%LINECOLOR%</LineColor>
<LineWeight>%LINEWEIGHT%</LineWeight>
<LineWeightScalable>false</LineWeightScalable>
</Path>
<Path>
<Geometry>M 0,0 L 5,0 </Geometry>
<LineColor>%LINECOLOR%</LineColor>
<LineWeight>%LINEWEIGHT%</LineWeight>
<LineWeightScalable>false</LineWeightScalable>
</Path>
</Graphics>
<LineUsage>
<Repeat>9.5</Repeat>
</LineUsage>
...
The <Geometry> element for the paths are a bunch of M (move to) and L (line to) operations as described in Enhanced Stylization - Flow Direction, with the added caveat that lower case L means the target coordinates are relative to the current location.
The first <Path> element, the complicated one, draws the 'GAS' text and the second <Path> element draws the lines between the text. As I said, this is only an approximation to the linetype in the acad.lin file, so the 'GAS' text is drawn with a whole lot of little segments, and not an embedded shape like in the AutoCAD line style.
The symbolization basically draws a line from 0,0 to 5,0 (the second <Path> element) and then draws a few lines that look like the word 'GAS' within a bounding box of approximately 6.0,-0.5 to 8.6667,0.5 (the first <Path> element), and then repeats the whole process at 9.5 unit intervals (the <Repeat> value). So to draw parallel lines above and below the 'GAS' text, one would have to offset them more than 0.5 units, say 0.7 units, and to make them look continuous they would need to be 9.5 units long, so that the repetition by the next symbolization will join with the first.
Thus, we modify the second <Path> <Geometry> element to be two lines:
<Geometry>M 0,0.7 L 9.5,0.7 M 0,-0.7 L 9.5,-0.7</Geometry>
which gives the result shown to the right.
If you're not happy with the font of the 'GAS' text either (really, who uses STANDARD text anymore), you can replace the drawn text with a real piece of text. The <Text> element has a lot of options. You will need a <Content> element with the word 'GAS' in it and a <FontName> element with a valid font name like 'Swiss 721 Black BT'. The available font names can be obtained from the list shown in the Windows Control Panel by double-clicking the Fonts icon.
Beyond that, to emulate the existing style we will need a <Height> element to set the height to 1.0, and <PositionX> and <PositionY> elements to set the position. The default horizontal alignment mode is Center and the default vertical alignment mode is Halfline, so the necessary position coordinates are 7.33335,0.0 (in the middle of the bounding box of the original text). To set the font color to be the same as the line color, add a <TextColor> element with a value of %LINECOLOR% so that setting the line color also sets the text color.

So the first <Path> element is replaced with:
<Text>
<Content>'GAS'</Content>
<FontName>'Swiss 721 Black BT'</FontName>
<Height>1.0</Height>
<PositionX>7.33335</PositionX>
<PositionY>0.0</PositionY>
<TextColor>%LINECOLOR%</TextColor>
</Text>
which gives the result shown to the right.
If the 'GAS' text repeats too often, the repeat interval can be extended, say to 20, but then the path elements for the (parallel) lines and probably the position elements for the text would also need to be altered.
Turning now to the railway line style, if we wanted to have the symbolization look more like train tracks, we could also change the single central line to a double parallel line as above. Opening the railway layer file you find symbolization like this:
<Graphics>
<Path>
<Geometry>M 1.5,0 l 0,2.5 M 1.5,0 l 0,-2.5 </Geometry>
<LineColor>%LINECOLOR%</LineColor>
<LineWeight>%LINEWEIGHT%</LineWeight>
<LineWeightScalable>false</LineWeightScalable>
</Path>
<Path>
<Geometry>M 0,0 L 1.5,0 M 1.5,0 L 3,0 </Geometry>
<LineColor>%LINECOLOR%</LineColor>
<LineWeight>%LINEWEIGHT%</LineWeight>
<LineWeightScalable>false</LineWeightScalable>
</Path>
</Graphics>
<LineUsage>
<Repeat>3</Repeat>
</LineUsage>
The first <Path> element draws the railway ties 2.5 units to left and right, while the second <Path> element draws the central line (actually in two segments, but this is redundant). So, let's change the central line to be two parallel lines offset by 1.9. Then the second path <Geometry> element becomes:
<Geometry>M 0,1.9 L 3.0,1.9 M 0,-1.9 L 3,-1.9</Geometry>
which gives the results on the right.
Although it's possible to increase the line thickness so that the railway ties look like railway ties, this would also thicken the railway rails. To get thick railway ties without thick rails one can change the geometry of the first path to outline the ties as rectangles with a thickness of 0.6:
<Geometry>M 1.2,0 l 0,2.5 l 0.6,0 l 0,-5 l -0.6,0 Z</Geometry>
The result is shown to the right.
To fill the outline though, a few more tricks are required. First, a <FillColor> element must be added to the path for the railway ties, so the final <Path> element is as follows:
<Path>
<Geometry>M 1.2,0 l 0,2.5 l 0.6,0 l 0,-5 l -0.6,0 Z</Geometry>
<LineColor>%LINECOLOR%</LineColor>
<LineWeight>%LINEWEIGHT%</LineWeight>
<FillColor>%FILLCOLOR%</FillColor>
<LineWeightScalable>false</LineWeightScalable>
</Path>
Then the FILLCOLOR parameter must be itemized in the <ParameterDefinition> element. This <Parameter> element can be copied from a point layer that already has this element.
<Parameter>
<Identifier>FILLCOLOR</Identifier>
<DefaultValue>0xffffffff</DefaultValue>
<DisplayName>&Fill Color</DisplayName>
<Description>Fill Color</Description>
<DataType>FillColor</DataType>
</Parameter>
Finally, in order to be able to set the parameter from the Style and Label Editor user interface, the <ParameterOverrides> element needs to have an additional <Override> element to set the fill color for the linestyle:
<Override>
<SymbolName>TRACKS</SymbolName>
<ParameterIdentifier>FILLCOLOR</ParameterIdentifier>
<ParameterValue>0xFFFF0000</ParameterValue>
</Override>
The results are shown to the right.
At this point you can click on the Expression builder for the FillColor parameter and create an expression to stylize the fill color value of the ties. For example you might want to theme the ties based on material.
The expression shown on the right would provide that. The LOOKUP function has a first parameter of the attribute to use (TIE) and a second parameter of the default (0xFFFF0000) color. Note that the color format is 0x to indicate a hexadecimal value followed by two hexadecimal characters for each of alpha, red, green and blue values. So, in this example, the first FF indicates a fully opaque alpha, and the second FF is full red, and the following two pairs of zeros indicate no green or blue, so the color is red like the outline lines. The rest of the parameters to LOOKUP are index and value pairs. In this case, if the TIE attribute is 'Concrete' then use 0xFF00FF00 (full alpha, no red, full green and no blue), and if it is 'Wood' then use 0xFF0000FF (full alpha, no red or green and full blue) - green for concrete and blue for wood. By setting the alpha values to smaller values (e.g. 77) you can get transparent fills. The point symbol in the images in this post has a value of CC for alpha.
This is the symbolization for wood ties:
The resulting layer files are available for download, in case they might be useful as an example.
AUTODESK DOES NOT GUARANTEE THAT YOU WILL BE ABLE TO SUCCESSFULLY DOWNLOAD OR IMPLEMENT ANY SAMPLE CODE. SAMPLE CODE IS SUBJECT TO CHANGE WITHOUT NOTICE TO YOU.
AUTODESK PROVIDES SAMPLE CODE "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE. IN NO EVENT SHALL AUTODESK OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS
OF DATA, OR LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, THAT MAY OCCUR AS A RESULT OF IMPLEMENTING OR USING ANY SAMPLE CODE, EVEN IF AUTODESK OR ITS SUPPLIERS
HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
Download Sample Display Model