Skip to content

Commit

Permalink
frame edit options added
Browse files Browse the repository at this point in the history
  • Loading branch information
rpakishore committed Mar 7, 2024
1 parent fba0b65 commit e9b6dca
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 15 deletions.
15 changes: 12 additions & 3 deletions documentation/Layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,19 @@ frames.selected() #Yields selected frames
frames.all() #Lists all defined frames
frames.rename(old_name='1', new_name='1_1') #Rename frame
frames.check_obj_legal(name='1') #Asserts frame's existance
frames.get_section(frame_name='1') #Get the assigned Section name
frames.get_points(frame_name='1') #Get points connected to frame
frames.delete(name='1') #Delete frame
frames.get_section(name='1') #Get the assigned Section name
frames.get_points(name='1') #Get points connected to frame

#Manipulation
frames.delete(name='1') #Delete frame
frames.divide_by_distance(name='1',
dist=0.5,Iend=True) #Divide frame by distance
frames.divide_by_intersection(name='2') #Divide at selected intersections
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

# Get frame properties
frames.Prop.rename(old_name="FSEC1", new_name="MySection") #Rename frame property
frames.Prop.total() #Total # of defined frame properties
```
Expand Down
12 changes: 10 additions & 2 deletions documentation/Usage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,17 @@
"frames.all() #Lists all defined frames\n",
"frames.rename(old_name='1', new_name='1_1') #Rename frame\n",
"frames.check_obj_legal(name='1') #Asserts frame's existance\n",
"frames.get_section(frame_name='1') #Get the assigned Section name\n",
"frames.get_points(frame_name='1') #Get points connected to frame\n",
"frames.get_section(name='1') #Get the assigned Section name\n",
"frames.get_points(name='1') #Get points connected to frame\n",
"\n",
"#Manipulation\n",
"frames.delete(name='1') #Delete frame\n",
"frames.divide_by_distance(name='1',\n",
" dist=0.5,Iend=True) #Divide frame by distance\n",
"frames.divide_by_intersection(name='2') #Divide at selected intersections\n",
"frames.divide_by_ratio(name='3',ratio=0.3)#Divide at selected ratio\n",
"frames.join('2','3') #Join Colinear frames\n",
"frames.change_points(name='1', point1='1', point2='3') #Change connected points of frame\n",
"\n",
"# Get frame properties\n",
"frames.Prop.rename(old_name=\"FSEC1\", new_name=\"MySection\") #Rename frame property\n",
Expand Down
70 changes: 60 additions & 10 deletions src/ak_sap/Object/frame.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Literal

from ak_sap.utils import log
from ak_sap.utils.decorators import smooth_sap_do
from .helper import MasterObj
Expand All @@ -12,21 +10,73 @@ def __init__(self, mySapObject) -> None:
self.Prop = Prop(mySapObject=mySapObject)

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

@smooth_sap_do
def get_points(self, frame_name: str) -> tuple[str]:
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=frame_name)
return self.ElemObj.GetPoints(frame_name)
#self.check_obj_legal(name=name)
return self.ElemObj.GetPoints(name)

@smooth_sap_do
def divide_by_distance(self, name: str, dist: float, Iend: bool=True) -> tuple[str]:
"""divides straight frame objects into two objects at a location defined by the Dist and IEnd items.
Curved frame objects are not divided.
"""
return self.EditFrame.DivideAtDistance(name, dist, Iend)

@smooth_sap_do
def divide_by_intersection(self, name: str) -> tuple[str]:
"""divides straight frame objects at intersections with selected point objects, line objects, area edges and solid edges.
Curved frame objects are not divided.
Args:
name (str): Frame Name
Returns:
tuple[str]: array that includes the names of the new frame objects.
"""
return self.EditFrame.DivideAtIntersections(name)[1:]

@smooth_sap_do
def divide_by_distance(self, frame_name: str, dist: float, Iend: bool=True, num_divisions: int=1):
return self.EditFrame.DivideAtDistance(frame_name, dist, Iend)
def divide_by_ratio(self,name: str, ratio: float, num_frames: int=1) -> tuple[str]:
"""divides straight frame objects based on a specified Last/First length ratio.
Curved frame objects are not divided.
Args:
name (str): name of an existing straight frame object.
ratio (float): Last/First length ratio for the new frame objects.
num_frames (int, optional): frame object is divided into this number of new objects. Defaults to 1.
Returns:
tuple[str]: array that includes the names of the new frame objects.
"""
return self.EditFrame.DivideByRatio(name, num_frames, ratio)

@smooth_sap_do
def join(self, frame1: str, frame2: str) -> bool:
"""joins two straight frame objects that have a common end point and are colinear.
Args:
frame1 (str): name of an existing frame object to be joined. The new, joined frame object keeps this name.
frame2 (_type_): name of an existing frame object to be joined.
"""
return self.EditFrame.Join(frame1, frame2)

@smooth_sap_do
def change_points(self, name: str, point1: str, point2: str) -> bool:
"""modifies the connectivity of a frame object.
Args:
name (str): name of an existing frame object
point1 (str): name of the point object at the I-End of the frame object.
point2 (str): name of the point object at the J-End of the frame object.
"""
return self.EditFrame.ChangeConnectivity(name, point1, point2)

class Prop:
def __init__(self, mySapObject) -> None:
self.SapModel=mySapObject.SapModel
Expand Down

0 comments on commit e9b6dca

Please sign in to comment.