ข้ามไปยังเนื้อหา

บทที่ 6 รัน Analyze

ก่อนรัน Analyze

ก่อนสั่ง RunAnalysis ต้องเข้าใจ 3 สิ่ง:

  1. Lock/Unlock Model — ETABS ต้อง lock โมเดลก่อน analyze ได้
  2. Load Case vs Load Combination — เลือกให้ถูกก่อนอ่านผล
  3. 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 ออกจาก output
ret = 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 Combo
ret = sap_model.Results.Setup.SetComboSelectedForOutput("1.2D+1.6L", True)
check(ret, "SetComboSelectedForOutput(1.2D+1.6L)")
print("✅ Output cases ตั้งค่าเรียบร้อย")

เลือกทุก Case/Combo

# เลือกทุก case
for name in case_names:
sap_model.Results.Setup.SetCaseSelectedForOutput(name, True)
# เลือกทุก combo
for name in combo_names:
sap_model.Results.Setup.SetComboSelectedForOutput(name, True)

ตัวอย่างเต็ม: Analyze แล้วเตรียม Output

# === ขั้นตอน Analyze ===
print("═══════════════════════════════")
print(" STEP: Analyze & Setup Output ")
print("═══════════════════════════════")
# 1. รัน Analysis
print("\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. ตั้งค่า Output
sap_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: AnalyzeShow Analysis Log

Log จะแสดง:

  • FATAL — ร้ายแรง: model unstable, no restraint
  • ⚠️ WARNING — ควรตรวจ: unconnected joint, zero stiffness
  • ℹ️ INFO — ข้อมูลทั่วไป: DOF count, solve time

Checklist

  • กด RunAnalysis() แล้ว return 0
  • DeselectAllCasesAndCombosForOutput() แล้ว
  • เลือก case/combo ที่ต้องการแล้ว
  • ตรวจ Analysis Log ว่าไม่มี WARNING/FATAL
  • พร้อมอ่าน Results ในบทถัดไป