# Dynamo tips and frequently used code snippets

## DesignScript

### Multi level if:

```
Test ? a@@-1: b@-2;
```

### Convert float to integer:

```
x:int
```

## Reinstall

Ha nem engedi felrakni mert nyavalyog, hogy fent van már másik, akkor itt kell kitörölni registryben:

```
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Dynamo...
```

Or the fixit tool: https://support.microsoft.com/en-us/help/17588/windows-fix-problems-that-block-programs-being-installed-or-removed

## Python

### Import

```python
import clr
clr.AddReference("ProtoGeometry")
from Autodesk.DesignScript.Geometry import *

# Import RevitAPI
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
clr.AddReference("RevitAPIUI")
from Autodesk.Revit.UI import TaskDialog

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

# Import ToProtoType, ToRevitType geometry conversion extension methods
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
```

### Access the Document and App:

```python
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
```

### Hogy bevegye a listát és az egy darab elemet is:

```python
if isinstance(IN[0], list):
        views = UnwrapElement(IN[0])
else:
        views = [UnwrapElement(IN[0])]
```
