Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ GPUCache
x64

.ruff_cache
.vscode/
,venv/
1 change: 1 addition & 0 deletions GSA/.NET API/python/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
3 changes: 3 additions & 0 deletions GSA/.NET API/python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Using the GSA .NET API with Python

This sample project is a command-line application that shows how to open a GSA file and iteration through the members on the Design Layer.
23 changes: 23 additions & 0 deletions GSA/.NET API/python/count-members/count-members.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import clr
from argparse import ArgumentParser

clr.AddReference(r"C:\Program Files\Oasys\GSA 10.2\GsaAPI")

import GsaAPI # noqa E402
from GsaAPI import MemberType # noqa E402

if __name__ == "__main__":
parser = ArgumentParser(description="Count the number of members in a GSA model")
parser.add_argument("input_filename", help="Input GSA file")
args = parser.parse_args()

model = GsaAPI.Model(args.input_filename)
print(f"Number of members: {len(model.Members())}")
print(f"Number of elements: {len(model.Elements())}")
print(f"Number of nodes: {len(model.Nodes())}")

for member_id, member in model.Members().items():
print(f"{member_id}: {member.Topology}")
topo = [int(n) for n in member.Topology.split(" ")]
print(f" ({model.Nodes()[topo[0]].Position.X}, {model.Nodes()[topo[0]].Position.Y}, {model.Nodes()[topo[0]].Position.Z}) -> \
({model.Nodes()[topo[1]].Position.X}, {model.Nodes()[topo[1]].Position.Y}, {model.Nodes()[topo[1]].Position.Z})")
9 changes: 9 additions & 0 deletions GSA/.NET API/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[project]
name = "python"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.9"
dependencies = [
"pythonnet>=3.0.5",
]
Loading
Loading