This repository has been archived on 2026-10-29. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
geometry-script/book/src/api/basics/modules.md

38 lines
1.1 KiB
Markdown
Raw Normal View History

2022-11-15 12:59:28 -05:00
# Modules
The first step when writing is script is importing the `geometry_script` module. There a are a few ways of doing this:
## Import All Names (Recommended)
This will import every type and function available into your script. It can make it easy to discover what's available with code completion, and makes the scripts more terse.
```python
from geometry_script import *
cube(...) # Available globally
my_geo: Geometry # All types available as well
```
## Import Specific Names
This will import only the specified names from the module:
```python
from geometry_script import cube, Geometry
cube(...) # Available from import
my_geo: Geometry
```
## Namespaced Import
This will import every type and function, and place them behind the namespace. You can use the module name, or provide your own.
```python
import geometry_script
geometry_script.cube(...) # Prefix with the namespace
my_geo: geometry_script.Geometry
```
```python
import geometry_script as gs
gs.cube(...) # Prefix with the custom name
my_geo: gs.Geometry
```
Now that you have Geometry Script imported in some way, let's create a tree.