บทที่ 6 รัน Analyze
ก่อนรัน Analyze
ก่อนสั่ง RunAnalysis ต้องเข้าใจ 3 สิ่ง:
- Lock/Unlock Model — ETABS ต้อง lock โมเดลก่อน analyze ได้
- Load Case vs Load Combination — เลือกให้ถูกก่อนอ่านผล
- Output Case Setup — ต้องเลือกว่าจะดู results ของ case/combo ไหน
Lock / Unlock Model
ETABS มี 2 สถานะ:
| สถานะ | อธิบาย | ทำอะไรได้ |
|---|---|---|
| Unlocked | แก้ไขโมเดลได้ | เพิ่ม/ลบ element, เปลี่ยน section |
| Locked | ล็อคโมเดลสำหรับ analysis | รัน analyze, อ่าน results |
# ตรวจสถานะปัจจุบันlocked = sap_model.GetModelIsLocked()print(f"🔒 Model locked: {locked}")
# ถ้าต้องการแก้โมเดลก่อน → unlock# sap_model.SetModelIsLocked(False)
# เมื่อพร้อม analyze → ไม่ต้อง lock เอง# RunAnalysis จะ lock ให้อัตโนมัติรัน Analysis
print("⏳ กำลังรัน Analysis...")
ret = sap_model.Analyze.RunAnalysis()
if ret == 0: print("✅ Analysis สำเร็จ!")else: print(f"❌ Analysis ล้มเหลว (ret={ret})")Load Case vs Load Combination
| ประเภท | อธิบาย | ตัวอย่าง |
|---|---|---|
| Load Case | กรณีแรงจริง (ตรง) | DEAD, LIVE, EQX, EQY, WIND |
| Load Combination | การรวม Load Case ตามมาตรฐาน | 1.4D, 1.2D+1.6L, 1.0D+1.0E |
อ่านรายชื่อ Load Cases
ret, case_count, case_names = sap_model.LoadCases.GetNameList()check(ret, "LoadCases.GetNameList")
print(f"\n📋 Load Cases ({case_count}):")for name in case_names: print(f" • {name}")อ่านรายชื่อ Load Combinations
ret, combo_count, combo_names = sap_model.RespCombo.GetNameList()check(ret, "RespCombo.GetNameList")
print(f"\n📋 Load Combos ({combo_count}):")for name in combo_names: print(f" • {name}")ตั้งค่า Output Case (สำคัญมาก!)
Pattern: Deselect All → Select เฉพาะที่ต้องการ
# 1. ยกเลิกทุก case/combo ออกจาก outputret = sap_model.Results.Setup.DeselectAllCasesAndCombosForOutput()check(ret, "DeselectAll")
# 2. เลือก Load Case ที่ต้องการret = sap_model.Results.Setup.SetCaseSelectedForOutput("DEAD", True)check(ret, "SetCaseSelectedForOutput(DEAD)")
ret = sap_model.Results.Setup.SetCaseSelectedForOutput("LIVE", True)check(ret, "SetCaseSelectedForOutput(LIVE)")
# 3. หรือเลือก Load Comboret = sap_model.Results.Setup.SetComboSelectedForOutput("1.2D+1.6L", True)check(ret, "SetComboSelectedForOutput(1.2D+1.6L)")
print("✅ Output cases ตั้งค่าเรียบร้อย")เลือกทุก Case/Combo
# เลือกทุก casefor name in case_names: sap_model.Results.Setup.SetCaseSelectedForOutput(name, True)
# เลือกทุก combofor name in combo_names: sap_model.Results.Setup.SetComboSelectedForOutput(name, True)ตัวอย่างเต็ม: Analyze แล้วเตรียม Output
# === ขั้นตอน Analyze ===print("═══════════════════════════════")print(" STEP: Analyze & Setup Output ")print("═══════════════════════════════")
# 1. รัน Analysisprint("\n⏳ Running analysis...")ret = sap_model.Analyze.RunAnalysis()if ret != 0: print(f"❌ Analysis failed (ret={ret})") print(" → ตรวจสอบ: มี support/restraint หรือไม่") print(" → ตรวจสอบ: มี load บน element หรือไม่") print(" → ตรวจสอบ: ดู ETABS Analysis Log") exit(1)print("✅ Analysis completed")
# 2. ตั้งค่า Outputsap_model.Results.Setup.DeselectAllCasesAndCombosForOutput()sap_model.Results.Setup.SetCaseSelectedForOutput("DEAD", True)print("✅ Output case: DEAD selected")
# พร้อมอ่าน Results ในบทถัดไปAnalysis Options (ขั้นสูง)
ETABS รองรับหลายประเภท analysis:
| ประเภท | อธิบาย | เมื่อใช้ |
|---|---|---|
| Linear Static | วิเคราะห์เชิงเส้นตรง | งานทั่วไป |
| P-Delta | รวมผลกระทบ P-Delta | อาคารสูง |
| Nonlinear | วิเคราะห์ไม่เชิงเส้น | วิเคราะห์ขั้นสูง |
| Modal | วิเคราะห์ mode shape | แผ่นดินไหว |
| Response Spectrum | วิเคราะห์ spectral | แผ่นดินไหว |
การตั้งค่าเหล่านี้ทำผ่าน ETABS GUI ก่อน แล้ว API จะรัน analysis ตามการตั้งค่าที่มีอยู่
Analysis Log
เมื่อ analysis ล้มเหลว ให้ตรวจ log file:
%USERPROFILE%\ETABS Analysis\[Model Name]\[Model Name].LOGหรือหาจาก ETABS: Analyze → Show Analysis Log
Log จะแสดง:
- ❌ FATAL — ร้ายแรง: model unstable, no restraint
- ⚠️ WARNING — ควรตรวจ: unconnected joint, zero stiffness
- ℹ️ INFO — ข้อมูลทั่วไป: DOF count, solve time
Checklist
- กด
RunAnalysis()แล้ว return0 -
DeselectAllCasesAndCombosForOutput()แล้ว - เลือก case/combo ที่ต้องการแล้ว
- ตรวจ Analysis Log ว่าไม่มี WARNING/FATAL
- พร้อมอ่าน Results ในบทถัดไป