Skip to content

Commit

Permalink
Merge pull request #5 from rpakishore/Dev240308
Browse files Browse the repository at this point in the history
Dev240308
  • Loading branch information
rpakishore authored Apr 18, 2024
2 parents 0cd0dc7 + ef584ba commit d536610
Show file tree
Hide file tree
Showing 21 changed files with 604 additions and 74 deletions.
432 changes: 406 additions & 26 deletions README.md

Large diffs are not rendered by default.

36 changes: 30 additions & 6 deletions documentation/Layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- [Point](#point)
- [Frame](#frame)
- [Database](#database)
- [Select](#select)
- [Loads](#loads)
- [Load Patterns](#load-patterns)
- [Load Cases](#load-cases)
Expand Down Expand Up @@ -49,6 +50,7 @@ sap.unhide() #Unhides SAP2000 window
sap.ishidden #Check if window is hidden
sap.version #Returns SAP2000 version number
sap.api_version #Returns Sap0API version number
sap.exit(save=False) #Exit the application

sap.save(r'\Path\to\save\file.sdb')
```
Expand Down Expand Up @@ -123,6 +125,13 @@ points.select(name='1') #Select a single point
points.align(axis='Z', ordinate = 100) #Align selected points
points.deselect(name='1') #Deselect a single point

# Extrude point to frame
points.extrude(
point_name='3',
property_name='FSec1',
dx=0, dy=144, dz=0,
num_frames=3
)
points.merge(tolerance=2) #Merge points that are within tol
points.change_coord(name='1', x=0, y=0, z=0)#Change point coordinate
```
Expand Down Expand Up @@ -153,6 +162,15 @@ frames.divide_by_ratio(name='3',ratio=0.3)#Divide at selected ratio
frames.join('2','3') #Join Colinear frames
frames.change_points(name='1', point1='1', point2='3') #Change connected points of frame

# Extrude frames to area
frames.extrude(
frame_name='8',
property_name='Default',
dx=0, dy=144, dz=0,
num_areas=3,
del_frame=True
)

# Get frame properties
frames.Prop.rename(old_name="FSEC1", new_name="MySection") #Rename frame property
frames.Prop.total() #Total # of defined frame properties
Expand All @@ -178,20 +196,24 @@ tables.update(TableKey='Material Properties 01 - General', data=df, apply=True)
```

## Select
elect = sap.Select

select.all() #Select all objects
select.clear() #Deselect all objects
Usage Examples:

select.constraint(name='Diaph1')#Select points in constraint
```python
select = sap.Select

select.all() #Select all objects
select.clear() #Deselect all objects

select.constraint(name='Diaph1') #Select points in constraint
select.constraint(name='Diaph1', reverse=True) #Deselect points in constraint

select.invert() #Invert selections
select.selected #Returns list of selected objects
select.previous() #restores the previous selection

#Selection based on plane
select.in_plane(pointname='1', plane='XY') #Select in XY plane
select.in_plane(pointname='1', plane='XY') #Select in XY plane
select.in_plane(pointname='2', plane='YZ', reverse=False) #Deselect

#Select by property
Expand All @@ -202,6 +224,8 @@ select.property(type='Link', name='GAP1', reverse=True)
select.property(type='Material', name='A992Fy50')
select.property(type='Solid', name='SOLID1', reverse=True)
select.property(type='Tendon', name='TEN1')
```

## Loads

Control the definition and assignments of loads.
Expand Down Expand Up @@ -297,7 +321,7 @@ analyze = sap.Analyze
analyze.create_model() #Create analysis model
analyze.run() #Runs the analysis
analyze.case_status() #retrieves the status for all load cases.
analyze.get_run_status() #retrieves the run flags for all cases
analyze.get_run_flag() #retrieves the run flags for all cases
analyze.set_run_flag(case='MODAL', status=True) # Set case to run
analyze.get_solver() #Get solver info

Expand Down
37 changes: 30 additions & 7 deletions documentation/Usage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"sap.ishidden #Check if window is hidden\n",
"sap.version #Returns SAP2000 version number\n",
"sap.api_version #Returns Sap0API version number\n",
"sap.exit(save=False) #Exit the application\n",
"\n",
"sap.save(r'\\Path\\to\\save\\file.sdb')"
]
Expand Down Expand Up @@ -145,6 +146,13 @@
"points.align(axis='Z', ordinate = 100) #Align selected points\n",
"points.deselect(name='1') #Deselect a single point\n",
"\n",
"# Extrude point to frame\n",
"points.extrude(\n",
" point_name='3',\n",
" property_name='FSec1',\n",
" dx=0, dy=144, dz=0,\n",
" num_frames=3\n",
")\n",
"points.merge(tolerance=2) #Merge points that are within tol\n",
"points.change_coord(name='1', x=0, y=0, z=0)#Change point coordinate"
]
Expand Down Expand Up @@ -183,6 +191,15 @@
"frames.join('2','3') #Join Colinear frames\n",
"frames.change_points(name='1', point1='1', point2='3') #Change connected points of frame\n",
"\n",
"# Extrude frames to area\n",
"frames.extrude(\n",
" frame_name='8',\n",
" property_name='Default',\n",
" dx=0, dy=144, dz=0,\n",
" num_areas=3,\n",
" del_frame=True\n",
")\n",
"\n",
"# Get frame properties\n",
"frames.Prop.rename(old_name=\"FSEC1\", new_name=\"MySection\") #Rename frame property\n",
"frames.Prop.total() #Total # of defined frame properties"
Expand Down Expand Up @@ -223,23 +240,29 @@
]
},
{
"cell_type": "markdown",
"metadata": {},
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": [
"select = sap.Select\n",
"\n",
"select.all() #Select all objects\n",
"select.clear() #Deselect all objects\n",
"select.all() #Select all objects\n",
"select.clear() #Deselect all objects\n",
"\n",
"select.constraint(name='Diaph1')#Select points in constraint\n",
"select.constraint(name='Diaph1') #Select points in constraint\n",
"select.constraint(name='Diaph1', reverse=True) #Deselect points in constraint\n",
"\n",
"select.invert() #Invert selections\n",
"select.selected #Returns list of selected objects\n",
"select.previous() #restores the previous selection\n",
"\n",
"#Selection based on plane\n",
"select.in_plane(pointname='1', plane='XY') #Select in XY plane\n",
"select.in_plane(pointname='1', plane='XY') #Select in XY plane\n",
"select.in_plane(pointname='2', plane='YZ', reverse=False) #Deselect\n",
"\n",
"#Select by property\n",
Expand Down Expand Up @@ -399,7 +422,7 @@
"analyze.create_model() #Create analysis model\n",
"analyze.run() #Runs the analysis\n",
"analyze.case_status() #retrieves the status for all load cases.\n",
"analyze.get_run_status() #retrieves the run flags for all cases\n",
"analyze.get_run_flag() #retrieves the run flags for all cases\n",
"analyze.set_run_flag(case='MODAL', status=True) # Set case to run\n",
"analyze.get_solver() #Get solver info\n",
"\n",
Expand Down
7 changes: 3 additions & 4 deletions documentation/Usage/GUI.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,19 @@ The package not comes pre-compiled with the streamlit package.
- Install dependencies

```bash
pip install flit && flit install
pip install flit && flit install --extras gui
```

- Launch the app run

```bash
python -m streamlit run Start_Here.py
gui
```

- Alternatively, In windows launch by executing the script

```cmd
cd scripts
run.bat
python -m streamlit run Start_Here.py
```

- Open up the SAP2000 model of your choice and click `Attach to Model`
Expand Down
3 changes: 2 additions & 1 deletion documentation/assets/mindmap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 8 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ dynamic = ["version", "description"]
dependencies = [
"comtypes==1.2.0",
"forallpeople==2.6.7",
"pandas==2.1.3",
"rich==13.7.0",
"typer[all]==0.9.0"
"pandas==2.1.3"
]

[project.optional-dependencies]
Expand All @@ -32,6 +30,11 @@ gui = [
"hilti_profis==0.0.3"
]

cli = [
"rich==13.7.0",
"typer[all]==0.9.0"
]

test = [
"pytest==7.4.3"
]
Expand All @@ -40,4 +43,5 @@ test = [
Home = "https://github.com/rpakishore/ak_sap"

[project.scripts]
app="ak_sap.gui.cli_app:app"
gui="ak_sap.gui.gui_app:app"
update-doc="ak_sap.cli.update_doc:app"
6 changes: 3 additions & 3 deletions src/ak_sap/Analyze/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def case_status(self) -> dict:
Returns:
list[dict]: Cases and their current status.
"""
return case_status(ret=self.__Analyze.GetCaseStatus()), 0
return case_status(ret=self.__Analyze.GetCaseStatus()), 0 # type: ignore

@smooth_sap_do
def get_run_flag(self) -> dict:
Expand All @@ -38,7 +38,7 @@ def get_run_flag(self) -> dict:
Returns:
dict: Loadcases and their run flags
"""
return get_run_flag(ret=self.__Analyze.GetRunCaseFlag()), 0
return get_run_flag(ret=self.__Analyze.GetRunCaseFlag()), 0 # type: ignore

@smooth_sap_do
def set_run_flag(self, case: str, status: bool):
Expand All @@ -57,7 +57,7 @@ def get_solver(self) -> dict:
Returns:
dict: Solver Info
"""
return get_solver(ret = self.__Analyze.GetSolverOption_3()), 0
return get_solver(ret = self.__Analyze.GetSolverOption_3()), 0 # type: ignore

@smooth_sap_do
def set_solver(self,
Expand Down
1 change: 1 addition & 0 deletions src/ak_sap/Loads/Modal/Eigen/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
class Eigen(MasterClass):
def __init__(self, mySapObject) -> None:
super().__init__(mySapObject=mySapObject)
assert self.SapModel is not None
self.ModalEigen = self.SapModel.LoadCases.ModalEigen

def __str__(self) -> str:
Expand Down
1 change: 1 addition & 0 deletions src/ak_sap/Loads/Modal/Ritz/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
class Ritz(MasterClass):
def __init__(self, mySapObject) -> None:
super().__init__(mySapObject=mySapObject)
assert self.SapModel is not None
self.ModalRitz = self.SapModel.LoadCases.ModalRitz

def __str__(self) -> str:
Expand Down
25 changes: 23 additions & 2 deletions src/ak_sap/Object/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@ def __init__(self, mySapObject) -> None:
super().__init__(mySapObject=mySapObject, ElemObj=mySapObject.SapModel.FrameObj)

self.__EditFrame = mySapObject.SapModel.EditFrame
self.__EditGeneral = mySapObject.SapModel.EditGeneral
self.__FrameObj = mySapObject.SapModel.FrameObj

self.Prop = Prop(mySapObject=mySapObject)

@smooth_sap_do
def get_section(self, name: str) -> str:
self.check_obj_legal(name=name)
_ret = self.ElemObj.GetSection(name)
_ret = self.__FrameObj.GetSection(name)
return (_ret[0], _ret[-1]) # type: ignore

@smooth_sap_do
def get_points(self, name: str) -> tuple[str]:
"""retrieves the names of the point objects at each end of a specified frame object."""
#self.check_obj_legal(name=name)
return self.ElemObj.GetPoints(name)
return self.__FrameObj.GetPoints(name)

@smooth_sap_do
def divide_by_distance(self, name: str, dist: float, Iend: bool=True) -> tuple[str]:
Expand Down Expand Up @@ -77,6 +80,24 @@ def change_points(self, name: str, point1: str, point2: str) -> bool:
"""
return self.__EditFrame.ChangeConnectivity(name, point1, point2)

@smooth_sap_do
def extrude(self, frame_name: str, dx: float, dy: float, dz: float, num_areas: int, property_name: str|None = None, del_frame: bool=False) -> list[str]:
"""Creates new area objects by linearly extruding a specified frame obj.
Args:
frame_name (str): Name of existing frame to extrude
dx (float): x offset.
dy (float): y offset.
dz (float): z offset.
num_areas (int): number of area objects to create
property_name (str | None, optional): Name of a defined area section property to be used for the new obj. Defaults to None.
del_frame(bool, optional): If this item is True, the straight frame object indicated by the Name item is deleted after the extrusion is complete. Defaults to False.
Returns:
list[str]: array of the name of each area object created
"""
return self.__EditGeneral.ExtrudeFrameToAreaLinear(frame_name, property_name, dx, dy, dz, num_areas, del_frame)

class Prop:
def __init__(self, mySapObject) -> None:
self.__mySapObject=mySapObject.SapModel
Expand Down
2 changes: 1 addition & 1 deletion src/ak_sap/Object/obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def move_selected(self, dx: float, dy: float, dz: float) -> bool:
dy (float): y offsets
dz (float): z offsets
"""
self.__EditGeneral.Move(dx, dy, dz)
return self.__EditGeneral.Move(dx, dy, dz)

@smooth_sap_do
def copy(self, dx: float, dy: float, dz: float, num: int) -> tuple:
Expand Down
22 changes: 20 additions & 2 deletions src/ak_sap/Object/point.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def __init__(self, mySapObject) -> None:
super().__init__(mySapObject=mySapObject, ElemObj=mySapObject.SapModel.PointObj)
self.__EditPoint = mySapObject.SapModel.EditPoint
self.__PointObj = mySapObject.SapModel.PointObj
self.__EditGeneral = mySapObject.SapModel.EditGeneral

@smooth_sap_do
def add_by_coord(self, point: tuple[float, float, float], name: str='', coord_sys: str = 'Global') -> str:
Expand All @@ -18,7 +19,7 @@ def add_by_coord(self, point: tuple[float, float, float], name: str='', coord_sy
name (str, optional): Custom name for point. Defaults to ''.
coord_sys (str, optional): Name of coordinate system. Defaults to 'Global'.
"""
return self.ElemObj.AddCartesian(*point, '', name, coord_sys)
return self.__PointObj.AddCartesian(*point, '', name, coord_sys)

@smooth_sap_do
def align(self, axis: Literal['X', 'Y', 'Z'], ordinate: float) -> tuple:
Expand Down Expand Up @@ -73,4 +74,21 @@ def change_coord(self, name: str, x: float, y: float, z: float) -> bool:
Returns:
bool: Success
"""
return self.__EditPoint.ChangeCoordinates_1(name, x, y, z)
return self.__EditPoint.ChangeCoordinates_1(name, x, y, z)

@smooth_sap_do
def extrude(self, point_name: str, dx: float, dy: float, dz: float, num_frames: int, property_name: str|None = None) -> list[str]:
"""Creates new frame objects by linearly extruding a specified point obj. into frame objects.
Args:
point_name (str): Name of existing point to extrude
dx (float): x offset.
dy (float): y offset.
dz (float): z offset.
num_frames (int): number of frame objects to create
property_name (str | None, optional): Name of a defined frame section property to be used for the new frame obj. Defaults to None.
Returns:
list[str]: array of the name of each frame object created
"""
return self.__EditGeneral.ExtrudePointToFrameLinear(point_name, property_name, dx, dy, dz, num_frames)
Loading

0 comments on commit d536610

Please sign in to comment.