 # Calculate inclination of a roof valley with Python

Ivan @ 02 / 06 / 2021 @ Blog / ArchiCAD / BIM и CAD / Программирование
( / )

Время чтения: ~ 4 мин.

Извините, этот текст не доступен на русском языке. So I started with this:

```height = 60
print("Height: ", height)

length = input("Enter roof valley inclination: ")
print(height / int(length) * 100)```

I thought it would be ok to get arguments from input stream, but it doesn’t work in sublime. So I made a variant with getting the height value from arguments:

```import sys

height = sys.argv
print("Height: ", height)

length = input("Enter roof valley inclination: ")
print(int(height) / int(length) * 100)```

Then I thought it be better to be totally made on the arguments, as it turned to be the fastest and more agile way:

```import sys

height = sys.argv
length = sys.argv
print("Height: ", height)
print("Roof valley length: ", length)
print(int(height) / int(length) * 100)
```

This one is to be run like this: `python "D:\Yandex Disc\YandexDisk\roofValleyInclinations.py" 60 11250`, where 60 is the overall height of the roof pitch and the valley’s 11250 is length. So the script is called from command prompt. To make the command prompt window stay on top, I used the AutoHotkey app with this kind of script: `^SPACE:: Winset, AlwaysOnTop, , A`, so <ctrl>+<space> makes the current window stay on top of all other.

And finally (hopefully), I decided to make a version that allows calculation inside the parameters, like this: `python "D:\Yandex Disc\YandexDisk\roofValleyInclinations.py" 460-407 10597`, as I got tired of subtracting it by hand.

Here is the code:

```import sys

height = sys.argv
length = sys.argv

height = eval(height)
length = eval(length)

print("Height: ", height)
print("Roof valley length: ", length)
print(abs(int(height)) / abs(int(length)) * 100)```

So now I can call it like this: `python "D:\Yandex Disc\YandexDisk\roofValleyInclinations.py" 460-407 10597`

BTW, I have found a great thing to run code in Sublime: it adds the command prompt right into sublime. The thing is called Terminus and can be installed via package manager. Looks like this: Works well with above mentioned hotkeys app to put it on top.

BTW, It would be wonderful, if I could make a label in ArchiCAD that would output the roof valley inclinations, but I have no idea how to do it.

### Может быть интересно:  Instagram
VK