Skip to main content

Sap2000 API python interface

Project description

Sap2000py

pypiDownloadsDocumentation Statusgithub starslicensecode grade

Sap2000py is a python module to interact with Sap2000 API

This Demo below shows how to interact with SAP2000 using the Sap2000py library. The project includes complete examples of creating and manipulating SAP2000 models, running analyses, and exporting results to Excel.

Documents

You can find the latest documentation here

Or you can find documents for all versions here.

Contents

Installation

Using pip:

pip install Sap2000py

Usage

Below are detailed instructions for using Sap2000pyDemo.py.

Setting the Model Path

At the beginning of the script, set the path to your model file:

from pathlib import Path
#full path to the model
ModelPath = Path('.\Test\Test.sdb')

Creating and Opening a SAP2000 Project

Create a Sap2000py object and open the SAP2000 program:

from Sap2000py import Saproject

Sap = Saproject()
Sap.openSap()
Sap.File.Open(ModelPath)

Model Information

Get basic information about your SAP2000 project:

Sap.getSapVersion()
Sap.getProjectInfo()
Sap.getUnits()

Make changes to the model:

# Set the project information with field and value
Sap.setProjectInfo("Author","Gou Lingyun")
Sap.setProjectInfo("Description","This is a test model")

# or you can set project information with a dictionary
Sap.setProjectInfo(info_dict={"Author":"Gou Lingyun","Description":"This is a test model"})

# Set the units of the model
Sap.setUnits("KN_m_C")

Adding Materials and Elements

Add materials and elements to the model:

# Add China Common Material Set·
Sap.Scripts.AddCommonMaterialSet(standard = "JTG")

# Add Joints and Elements
joint_coord = np.array([[0,0,0], [10,0,0], [20,0,0], [30,0,0]])
Sap.Scripts.AddJoints(joint_coord)
Sap.Scripts.AddElements([[1,2], [2,3], [3,4]])

Analysis

Run a modal analysis:

Sap.Scripts.Analyze.RemoveCases("All")
Sap.Scripts.Analyze.AddCases(Casename = ['DEAD', 'MODAL'])
Sap.Scripts.Analyze.RunAll()

Post-processing

Export analysis results to an Excel file:

note: the following code is just an example, you can modify it according to your needs.

filename = 'F:\\python\\Sap2000\\Models\\Test.xlsx'
wb = openpyxl.load_workbook(filename)
ws = wb.worksheets[0]

Sap.Scripts.SelectCombo_Case(["DEAD"])
Name, EleAbsForce, __, __ = Sap.Scripts.GetResults.ElementJointForce_by_Group("PierBottom")
Sap.Scripts.writecell(ws, EleAbsForce[:,[2]], "D22")

wb.save(filename)

Saving and Closing

Save the project and close the SAP2000 program:

Sap.File.Save()
Sap.closeSap()

Dependencies

  • python>=3.9

This project requires the following Python libraries:

  • numpy
  • os
  • openpyxl
  • comtypes>=1.1.11
  • itertools
  • rich
  • loguru
  • pathlib
  • json
  • sectionproperties>=3.3.0

For more information, please check Sap2000py Demo and Build Continuous Bridge Demo.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sap2000py-0.1.6.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sap2000py-0.1.6-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file sap2000py-0.1.6.tar.gz.

File metadata

  • Download URL: sap2000py-0.1.6.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for sap2000py-0.1.6.tar.gz
Algorithm Hash digest
SHA256 552be2c48af025ab457917bd18250fecfa226b5a5f701b8cbb0d7b1de4a57f31
MD5 06f8cc740675888848271d5eb410b33d
BLAKE2b-256 ab8958dca9d0fe0636aae8d383fd0c991d1b87e120e59ae03d5be83815658829

See more details on using hashes here.

File details

Details for the file sap2000py-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: sap2000py-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for sap2000py-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 696ebcb23152fa5e62e72e7ca8c66b24e4af085503e9a1a4a85b381c858e622a
MD5 9a505c14f230ed5f8a160ab057b0a54e
BLAKE2b-256 30282f4730d8ba0b90fa68d15b64d170175bd4eb4e1a1ec1ea12e0cc04114a7b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page