# Sketch

<img src="./media/FilesAddSketch.png" width="250">

Click **Files**, then **Add**, and then select **Sketch**.

This adds a new sketch layer to your model, allowing you to place custom objects without directly changing the model itself.

You can open multiple sketch tabs, but only one sketch is displayed at a time. Click **3D** in the bottom-left corner to return to the model.

<table>
<tr><th>Button</th><th>Description</th></tr>
<tr><td>

<img src="./media/ButtonCancel.png" width="44" height="44">

</td><td>

**Delete** the selected sketch item.

</td></tr>
<tr><td>

<img src="./media/ButtonCreateLink.png" width="44" height="44"><img src="./media/image83.jpg" width="44" height="44">

</td><td>

Convert 3D view objects to sketch items, which hides the source object, or clone them, which keeps the original visible. During conversion or cloning, you are prompted to choose between **referencing** and **copying**.

- **Referencing** links the **Sketch** item to the 3D object by its ID, maintaining its appearance despite model changes.
- **Copying** creates a new independent sketch item with normal behaviour.
 

</td></tr>
<tr><td>

<img src="./media/ButtonUndo.png" width="44" height="44">

</td><td>

**Undo** the last change to the tree.

</td></tr>
<tr><td>

<img src="./media/ButtonRedo.png" width="44" height="44">

</td><td>

**Redo** the last undone change to the tree.

</td></tr>
</table>

### Adding and Editing Objects

To add an object, first select it from the menu on the right. You can then drag and drop it into position.

<img src="./media/SketchObjects.png" width="250">

There are five object categories:

* **Basic structure** (ground plate, column, steel, slab)
* **Basic shapes** (cube, vertical/horizontal equipment, sphere)
* **Piping** (pipe, valve, ball valve, strainer, flange, etc.)
* **Platform**
* **Custom objects**

You can still use the standard functions in the left-hand menu. In addition, the sketch tab menu provides further options for editing the selected object.

### Example

#### Basic Structures and Shapes

Basic structures and shapes have a default scale and editing options that depend on their function:

<table>
<tr><th>Object</th><th>Default scale</th><th>Scaling options</th><th>Property to choose from</th></tr>
<tr><td>

Ground plate

</td><td>

10 x 10 m

</td><td>

X, Y & Z

</td><td>

-

</td></tr>
<tr><td>

Column

</td><td>

0.3 x 0.3 x 3 m

</td><td>

Height only

</td><td>

Profile type

</td></tr>
<tr><td>

Steel

</td><td>

0.05 x 0.05 x X m

</td><td>

Length only

</td><td>

Profile type

</td></tr>
<tr><td>

Slab

</td><td>

1 x 1 x 0.2 m

</td><td>

X, Y & Z

</td><td>

-

</td></tr>
<tr><td>

Cube

</td><td>

1 x 1 x 1 m

</td><td>

X, Y & Z

</td><td>

-

</td></tr>
<tr><td>

Sphere

</td><td>

0.1 m

</td><td>

Z

</td><td>

-

</td></tr>
<tr><td>

Vertical / horizontal equipment

</td><td>

2 x 1 m

</td><td>

X, Y & Z

</td><td>

-

</td></tr>
<tr><td>

Pipe

</td><td>

1 m, DN 50

</td><td>

Length only

</td><td>

Length and diameter

</td></tr>
</table>

#### Scaling Objects in Dependence to Others

<table>
<tr><td>

<img src="./media/image124.png" width="104" height="113">

</td><td>

If you want an object's dimensions to match the position of another object, select the object, click the scale icon, and then click and hold one of the semi-spheres on the selected object. When you move the mouse pointer over another object in the model, a green circle with crosshairs appears. The crosshairs indicate the X, Y, and Z coordinates at which the scaling will end.

</td></tr>
</table>

### Piping

<table>
<tr><td>

<img src="./media/image125.jpg" width="44" height="44">

</td><td>

When placing a pipe, you automatically get additional options that allow you to create a pipe run and connect it to other pipes or Symbol Designer objects with piping connectors.

</td></tr>
</table>

<table>
<tr><td Rowspan="3"><img src="./media/image126.png" width="72" height="115">

</td><td>

The pipes diameter can be chosen from a drop-down list in the properties.

</td></tr>
<tr><td>

You can add a 90° angle to the end of the pipe run by dragging the half-sphere, and you can move or lengthen the pipe by dragging the coloured arrows.

</td></tr>
<tr><td>

In rotation mode, you can drag the curved arrows to change the angle of the pipe. Pressing **Ctrl** makes the pipe end point towards the mouse position.

</td></tr>
</table>

### Creating a Pipe Run 

<table>
<tr><td colspan=2>The easiest way to create a pipe run is to click to where your pipe should start.

</td></tr>
<tr><td>

<img src="./media/image127.png" width="138" height="120">

</td><td>

<img src="./media/image128.png" width="164" height="148">

</td></tr>
</table>

This adds a horizontal or vertical pipe, depending on the orientation of the surface.
By dragging one of the semi-spheres, you can continue the pipe with a 90° angle connected by a bend.

> You need enough space for a bend. Otherwise bends will be displayed in red.

<img src="./media/image129.png" width="200" height="84">

<table>
<tr><td>

<img src="./media/image130.png" width="140" height="126">

</td><td>

You can add additional pipes between bends or loop pipes back on themselves. 

</td></tr>
</table>

#### Moving and Deleting Pipes

If you select a pipe, you can move it by dragging the directional arrows.

If you want to delete a pipe, you are asked whether you want to delete only that section or all connected sections as well.

#### Adding Piping Equipment

Valves and similar items can only be added to pipes that are sketch items. Select a piece of equipment and click the part of the pipe where you want to place it. You can then move it to the required position on the pipe.

> Some pipe equipment has optional properties you can choose from.

### Platforms

<table>
<tr><td>

<img src="./media/image131.jpg" width="44" height="44">

</td><td>

Start by placing the platform. Click the **Platform** icon and then click any location in the model, or drag the button into the 3D space.

</td></tr>
</table>
 
<img src="./media/image132.png" width="165" height="240"> 
To select the whole platform, select any part of it and then click that selected part again.

The Platform can be moved and scaled as a whole, but its columns and slabs can also be moved, scaled, and changed independently.

<img src="./media/image133.png" width="271" height="88">

The platform attributes include buttons for increasing or decreasing the number of columns and rows. Deleted platform objects can be reactivated with the **Activate** button. You cannot reactivate individual objects, so unnecessary parts must be deleted again.

### Custom Objects

Custom objects in the **.obj** format can be placed like other **Sketch** items. Click the button and select the object to be created in the file browser.

### Adding Objects from the Catalogue

When loading a model, UDiTH looks for a **Catalogue** folder with subfolders for objects, for example `Architectural`. The **Catalogue** folder must be in the same location as the **Data** folder.

<img src="./media/SketchObjectsCatalogue.png" width="200" height="">

> The 3D **Catalogue** in UDiTH also supports **.obj** (Wavefront) files.

The UDiTH **Catalogue** includes **.obj** or **.xls** files with corresponding **.jpg** or **.png** images. The **UDiTHsketchitemindex.txt** list file, located in the model's **Data** folder, contains all available items. The default **Catalogue** includes common plant parts such as pumps and vessels, which are available as regular objects. Although objects can be scaled, only parametric symbols retain the correct proportions.

#### Adding Objects to the Catalogue

To expand the UDiTH **Catalogue**, add any **.obj** file together with an optional **.jpg** or **.png** image. UDiTH automatically includes these items when the model is loaded, provided they are valid and correctly listed in **UDiTHsketchitemindex.txt**. Both absolute and relative paths are supported, including **#include**.

Example:

Catalogue/Ladder/ladder1.obj

/Ladder/ladder2.obj

\#include D:\\yourindex.txt

Using **#include**, objects can be stored in multiple locations as required. The included text file works in the same way as **UDiTHsketchitemindex.txt** and can also contain additional includes.

The creation of a **UDiTHsketchitemindex.txt** file can be automated by
creating a **.bat** file with the following lines of code:

\@echo off

for /f \"delims=\" %%i in (\'CD\') Do set wdrive=%%i

Setlocal EnableDelayedExpansion

if exist UDiTHsketchitemindex.txt del UDiTHsketchitemindex.txt

for /r %%a in (\*.obj,\*.xlsx) do (

SET out=%%a

rem set out=!out: =%%20!

set out=!out:d:\\\_DemoPlant\\\_\_work\\20_config\\=!

rem set out=!out:\\=/!

set out=!out:%wdrive%=Catalogue!

echo !out! \>\> UDiTHsketchitemindex.txt

)

Executing this batch file in the root folder of the catalogue that contains all subfolders and objects will delete any existing UDiTHsketchitemindex.txt file and create a new one containing all \*.obj and all \*.xlsx files in all subfolders.

#### Adding Parametric Symbols to the Catalogue

Parametric symbols are created using **3D SymbolDesigner**.

These symbols can contain attributes that change the appearance of an object, allowing complex objects such as the vehicle crane shown below, with movable parts, to be designed. The white spheres in the images represent movable parts and can be dragged to change certain attributes of a symbol, for example raising the crane. For a detailed explanation of how to create symbols, please refer to the **3D SymbolDesigner** manual.

To add parametric symbols to the catalogue, add the relevant **.xlsx** file created by **SymbolDesigner** to **UDiTHsketchitemindex.txt**, for example:

<img src="./media/image135.png" width="300" height="263"> <img src="./media/image136.png" width="300" height="263">

### Converting Objects from the 3D Model

In this example, a tank is moved and connected to an existing pipeline.

<img src="./media/image139.png" width="601" height="338">

Select the tank and its nozzles and open the **Convert** menu. Click the first button, **Convert 3D object to sketch item**, and choose **Reference**, because the original tank is to be moved.

<img src="./media/image140.png" width="601" height="370">

Click **Move** and drag the red and green arrows until the tank is next to the pipeline.

<img src="./media/image141.png" width="600" height="386">

Select the pipeline you want to connect to the tank, open the **Convert** menu, and click the last button, **Convert 3D view objects to piping**.

<img src="./media/image142.png" width="545" height="445">
