MCPcopy Create free account
hub / github.com/HeisenbergJY1/PySap2000 / LoadPattern

Class LoadPattern

loading/load_pattern.py:95–294  ·  view source on GitHub ↗

Load pattern definition. Wraps SAP2000 `LoadPatterns`. Attributes: name: Load pattern name load_type: Load type (`LoadPatternType`) self_weight_multiplier: Self-weight multiplier add_load_case: Whether to automatically create a corresponding linear

Source from the content-addressed store, hash-verified

93
94@dataclass
95class LoadPattern:
96 """
97 Load pattern definition.
98
99 Wraps SAP2000 `LoadPatterns`.
100
101 Attributes:
102 name: Load pattern name
103 load_type: Load type (`LoadPatternType`)
104 self_weight_multiplier: Self-weight multiplier
105 add_load_case: Whether to automatically create a corresponding linear static load case
106 """
107 name: str = ""
108 load_type: LoadPatternType = LoadPatternType.OTHER
109 self_weight_multiplier: float = 0.0
110 add_load_case: bool = True
111
112 _object_type: ClassVar[str] = "LoadPatterns"
113
114 def _create(self, model) -> int:
115 """
116 Create a load pattern.
117
118 Args:
119 model: SAP2000 SapModel object
120
121 Returns:
122 `0` if successful, `-1` if it already exists.
123 """
124 # Check whether the load pattern already exists.
125 if self.name:
126 try:
127 existing = self.get_name_list(model)
128 if self.name in existing:
129 return -1
130 except Exception:
131 pass
132
133 result = model.LoadPatterns.Add(
134 self.name,
135 int(self.load_type),
136 self.self_weight_multiplier,
137 self.add_load_case
138 )
139 return com_ret(result)
140
141 def _get(self, model) -> int:
142 """
143 Retrieve load pattern data from the model.
144
145 Args:
146 model: SAP2000 SapModel object
147
148 Returns:
149 `0` if successful.
150 """
151 # Get the load pattern type.
152 result = model.LoadPatterns.GetLoadType(self.name, 0)

Callers 6

ensure_load_patternFunction · 0.90
test_set_load_typeMethod · 0.90
test_rename_patternMethod · 0.90

Calls

no outgoing calls

Tested by 6

ensure_load_patternFunction · 0.72
test_set_load_typeMethod · 0.72
test_rename_patternMethod · 0.72