Hi,
I am working with the stability automation tool to automatically add a damage case to my maxsurf stability model, and then populate the tank status based on whether it is damaged or intact. This is all being driven by a piece of VBA code.
At the moment I can add the new damage case with my desired damage case title.
However when it comes to editing the tanks to update the status (damaged or intact), I am struggling.
I am looking at the functions below to help define the tank status based on which damage case is selected.
I keep getting an error suggesting I have a "Bad Index", even though the tank name(ie tank 2) is correct or the tank row is correct (ie row 2). Below is the line of code simplified suggesting I want to change the row 2 tank definition for the active damage case = damaged.
hmApp1.DamagedPercent(2) = 100 <---corresponds to "Damaged"
or
hmApp1.DamagedPercent("Tank 2") = 100 <---corresponds to "Damaged"
Any ideas would be appreciated.
Thanks.
Hi Oliver,
What have you defined hmApp1 as? is it set to be ...stabApp.Design.DamageCases(2)
Do you have partial flooding enabled in your model? Case | Enable Partial Flooding.
Note that there is also a Boolean choice for IsDamaged, more suitable for cases where you aren't using partial flooding.
Here is my test code, if that helps:
============================
Dim stabApp As New BentleyStability.Application
Sub testDamage()
Dim thisTank As Tank
'stabApp.Design.DamageCases(1).IsDamaged(1) = True '--> this will give an error becasue damage case 1 is actually the "all intact" base case and we can't set anything damaged.stabApp.Design.DamageCases(2).DamagedPercent(1) = 100 'this worksstabApp.Design.DamageCases(2).IsDamaged(1) = True 'is better syntax if you aren't using partial flooding.
'I often use For Each loops, not that I've defined thisTank earlier on.For Each thisTank In stabApp.Design.Tanks stabApp.Design.DamageCases(2).IsDamagedByName(thisTank.Name) = TrueNext
End Sub
================================
Answer Verified By: Oliver Cooper