Skip to content

Commit 6b2d4dc

Browse files
Merge pull request #2 from shuhrat-kobulov/dev
feat: starting write full documentation
2 parents 52e3f5f + 2f74d32 commit 6b2d4dc

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Welcome to the Python scripting for DIgSILENT. This documentation will teach you
88
2. [Getting Started](#getting-started)
99
3. [Basic Scripting](#basic-scripting)
1010
4. [Troubleshooting](#troubleshooting)
11+
5. [Contributing](contributing.md)
12+
6. [Start Learning](documentation/README.md)
1113

1214
---
1315

documentation/README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Python Scripting in DIgSILENT
2+
3+
Welcome to the Python scripting for DIgSILENT. This documentation will teach you how to leverage Python for automating tasks in DIgSILENT PowerFactory.
4+
5+
## Table of Contents
6+
7+
1. [Connect to PowerFactory Application](#connect-to-powerfactory-application)
8+
9+
---
10+
11+
## Connect to PowerFactory Application
12+
13+
Before you can perform any operations within DIgSILENT PowerFactory using Python, you need to establish a connection to the PowerFactory application. This connection allows your Python script to interact with PowerFactory's objects and functionalities.
14+
15+
### Steps to Connect:
16+
17+
1. **Import the PowerFactory Module**: PowerFactory provides a Python module that facilitates interaction with its environment. Begin by importing this module in your script.
18+
```python
19+
import sys
20+
sys.path.append(r"C:\\Program Files\\DIgSILENT\\PowerFactory 2022 SP2\\Python\\3.8")
21+
import powerfactory
22+
```
23+
2. **Initialize the PowerFactory Application**: Use the GetApplication() method to initialize and obtain a reference to the PowerFactory application instance.
24+
25+
```python
26+
app = powerfactory.GetApplication()
27+
28+
if not app:
29+
raise Exception("Could not connect to PowerFactory application.")
30+
else:
31+
print("Connected to PowerFactory successfully.")
32+
```
33+
34+
### Example:
35+
36+
Here's a complete example that connects to the PowerFactory application and verifies the connection:
37+
38+
```python
39+
import sys
40+
sys.path.append(r"C:\\Program Files\\DIgSILENT\\PowerFactory 2022 SP2\\Python\\3.8")
41+
import powerfactory
42+
43+
app = powerfactory.GetApplication()
44+
45+
if not app:
46+
raise Exception("Could not connect to PowerFactory application.")
47+
else:
48+
print("Connected to PowerFactory successfully.")
49+
```

0 commit comments

Comments
 (0)