# Creating Structure Type

Structure types are loaded dynamically and custom ones can be created in the 'structure directory. To open this directory run: EneRailroad::Template.open_dir(:structure_type).

## Create Directory (And define ID)

Each structure type template is saved in a sub directory named as its ID. This directory's name must start with your initial or some other rather unique character combination, followed by an underscore (_), to prevent name collisions.

IDs without leading initials (such as 'bridge' rather than 'ene_bridge') are reserved for the structures shipped with the extension (and 'ene_' prefix is already reserved by me, Eneroth3). Using such an ID for your own structure may lead to it being overwritten when updating the extension.

Create a sub directory with the chosen ID as name to save the files in.

## Making the Model

Basically a structure consists of extrusions (yellow), arrayed elements (red) and endings (green). Tunnel portals and bridge heads are typically endings.

Create a model named 'model.skp' in the directory you just created. For backward compatibility save models as Sketchup version 8.

The extrusion profile, arrayed elements and endings are drawn as groups in this model. The groups are identified by attributes. Their position within the model doesn't matter for the plugin, however how the internal geometry is positioned in relation to the groups' local coordinate systems is vital.

### Extrusion Profiles

Each face in this group must be alone in its own group. By separating faces to individual groups unnecessary vertices from edges binding other faces can be avoided, reducing the number of faces created in the extrusion.

these one-face-groups can be painted with a material or left without so the user can paint the structure as a whole themselves (e.g. painted metal bridge). The faces should be drawn in the profile group's x-z plane with the front of the face pointing towards negative y. When making a tunnel ceiling however the face can be oriented the other way so the front faces are oriented towards the inside when extruded. The x axis represents the top of rails plane.

To make the plugin recognize the extrusion profile group, add the attribute by selecting the group and run:

Sketchup.active_model.selection.first.set_attribute "ene_railroad_template_part", "type", "extrusion_profile"

### Arrayed Elements

Groups (or components) can be arrayed along the structures, e.g. pillars. There can be multiple arrayed groups for the same structure type.

Also in these groups x axis represents the top of rail plane.

To make the plugin recognize the arrayed groups, add the attribute by selecting each one of them and run:

Sketchup.active_model.selection.first.set_attribute "ene_railroad_template_part", "type", "arrayed"

To set the target distance between each copy of the group, run:

Sketchup.active_model.selection.first.set_attribute "ene_railroad_template_part", "distance", 1.m

Replace '1' with the length in meters or replace '1.m' with the length in inches. Use point (.) as decimal separator.

### Endings

Groups (or components) can also be added at the end of structures (e.g. tunnel portal or bridge head).

Endings are typically based on the extrusion profile model with the faces push-pulled towards negative y. It's also possible to do it the other way around; starting with the ending and copy faces from its x-z plane to use for the extrusions. Positive y is where the rest of the structure will be.

To make the plugin recognize the ending group, add the attribute by selecting the group and run:

Sketchup.active_model.selection.first.set_attribute "ene_railroad_template_part", "type", "ending"

### Double Tracks

For double track bridges, tunnels and other structures, draw the structure for the rightmost track (furthest towards positive x). This makes the Add Structure Tool more consistent. A double track bridge should for instance be extended by the track's center distance towards negative x. A platform should be drawn at positive x. By keeping this consistent the user can always add the structure along the right side of a double track railroad.

## Create/Update Information

To create or edit structure information run EneRailroad::Template.edit_properties in the Ruby console.

### Naming Convention

To make it easier to find the structure in the alphabetic list the name should be a comma-separated list as following:

- Type (e.g. Bridge, Platform, Tunnel)
- Construction if relevant (mostly for bridges, e.g. Vaulted, Truss, Beam)
- Material if relevant, (e.g Stone, Brick, Steel)
- Additional information if relevant, (e.g. Aerodynamic)
- "Double" if the track structure is drawn to hold 2 tracks

Examples:

- Tunnel, Stone
- Tunnel, Concrete, Aerodynamic (ICE), Double
- Bridge, Beam, Steel, Double

### Corresponding Track Type

If the structure requires a special track type, e.g. with track ballast adapted for its width, reference to it by ID (not name). Otherwise leave field blank.

### Corresponding Signal Type

ID of signal type to use by default for this structure, blank if no preference, or "<NO SIGNALS>" if this structure should be without signals.

### Parallel Distance

If structure is made to hold multiple parallel tracks, write the center distance between them. Otherwise leave field blank.

### Track Number

If structure is made to hold multiple parallel tracks, write the number of them. Otherwise leave field blank.

### Height Offset

How far above the ground the track is by default, typically used for viaducts and elevated tracks.

## Create Preview Image

To create the preview image of the structure, open preview.skp in the structure directory. Draw a structure that either has no, one or both ends visible inside the viewport depending on what's relevant. If the structure is made to cover multiple tracks you can center it at the track in the model with move tool to make it centered in the preview image.

The closer to 1362 * 610 the viewport size is, the better line thickness will match those of templates shipped with the plugin. My Viewport Resizer can be used to achieve this.

The scene in the model makes the preview match other previews. If it doesn't show what's relevant you can move the camera. To make the view visually match other previews you can have another instance of the file open with the default camera location to compare the view with.

Hide Hidden Geometry to hide the track.

Run this code in console to save preview image:

EneRailroad::Template.create_preview

## Distributing Structure

The whole folder for the structure type can easily be compressed, shared, and decompressed in someone else's structure folder.

Copyright © Julia Christina Eneroth 2015.