'-------------------------------------------------------------------------------- ' Sample script demonstrating fixed trim righting arm calculation in Orca3D ' Created By: Larry Leibman, DRS Defense Solutions Advanced Marine Technology Center ' Date: 7/28/2010 ' Revision: 1.0 '-------------------------------------------------------------------------------- Option Explicit FixedTrimRightingArms Sub FixedTrimRightingArms On Error Resume Next 'Get the Orca3D plug-in object Dim orcaPlugIn Set orcaPlugIn = Rhino.GetPluginObject("Orca3D") 'Declare/intialize variables Dim hydrostaticsList, hydrostatics, hydrostaticsArray Dim displacement, lcg, tcg, vcg, arrObjects Dim trimAngle, newLcg, lcb, vcb, heelAngle Dim mirror, heelLo, heelHi, heelInc 'Prompt user for required input displacement = Rhino.GetReal("Enter the displacement") lcg = Rhino.GetReal("Enter the lcg(" + Rhino.UnitSystemName + ")") tcg = Rhino.GetReal("Enter the tcg(" + Rhino.UnitSystemName + ")") vcg = Rhino.GetReal("Enter the vcg(" + Rhino.UnitSystemName + ")") mirror = Rhino.GetString("Mirror hull geometry", "yes") If Not IsNull(mirror) And StrComp(Left(mirror,1), "y") = 0 Then mirror = "Yes" End If 'Dim arrItems, arrDefaults, arrResults 'mirror = "No" 'arrItems = Array( "Mirror", "No", "Yes") 'arrDefaults = Array(True) 'arrResults = Rhino.GetBoolean("Mirror hull geometry?", arrItems, arrDefaults) 'If IsArray(arrResults) And arrResults(0) = True Then ' mirror = "Yes" 'End If heelLo = Rhino.GetInteger("Enter starting heel angle", 0) heelHi = Rhino.GetInteger("Enter ending heel angle", 180) heelInc = Rhino.GetInteger("Enter heel angle increment", 10) arrObjects = Rhino.GetObjects("Select surfaces, polysurfaces, and meshes to analyze", 56, True, True, True) If IsNull(displacement) Or IsNull(lcg) Or IsNull(tcg) Or IsNull(vcg) Or IsNull(arrObjects) Then Exit Sub End If Dim output output = "Displacement = " + CStr(displacement) + ", LCG = " + CStr(lcg) + ", TCG = " + CStr(tcg) + _ ", VCG = " + CStr(vcg) + ", Mirror = " + mirror + ", Heel Angles = " + CStr(heelLo) + "," + _ CStr(heelHi) + "," + CStr(heelInc) output = output & VbCrLf & VbCrLf + "Heel Angle (deg), Trim Angle (deg), Righting Arm (" + Rhino.UnitSystemName + ")" ' Compute hydrostatics with zero trim at specified heel angle Rhino.Command "-_OrcaHydrostatics Mirror=" + mirror + " Description ""Sample Hydrostatics Upright"" " + _ "LoadCase SinkageOptions SpecifyWeight " + CStr(displacement) + _ " TrimOptions SpecifyLCG " + CStr(lcg) + " HeelOptions SpecifyTCG " + _ CStr(tcg) + " VCG " + CStr(vcg) + " _enter RightingArms Compute=No _enter _enter" ' Retrieve LCB for zero trim hydrostatics If Not IsNull(orcaPlugIn) Then hydrostaticsList = orcaPlugIn.MostRecentStabilityResults End If If hydrostaticsList <> Nothing And IsArray(hydrostaticsList) Then For Each hydrostatics In hydrostaticsList trimAngle = hydrostatics.Trim Next End If 'Loop over heel angles computing fixed trim righting arms For heelAngle = heelLo To heelHi Step heelInc ' Compute hydrostatics with zero trim at specified heel angle Rhino.Command "-_OrcaHydrostatics Mirror=" + mirror + " Description ""Sample Hydrostatics Upright"" " + _ "LoadCase SinkageOptions SpecifyWeight " + CStr(displacement) + _ " TrimOptions SpecifyTrim " + CStr(trimAngle) + " HeelOptions SpecifyHeel " + _ CStr(heelAngle) + " VCG " + CStr(vcg) + " _enter RightingArms Compute=No _enter _enter" ' Retrieve LCB for zero trim hydrostatics If Not IsNull(orcaPlugIn) Then hydrostaticsList = orcaPlugIn.MostRecentStabilityResults End If Dim delta If hydrostaticsList <> Nothing And IsArray(hydrostaticsList) Then For Each hydrostatics In hydrostaticsList lcb = hydrostatics.LCB vcb = hydrostatics.VCB delta = (vcg - vcb) * Tan(Rhino.ToRadians(trimAngle)) newLcg = lcb - delta Next End If ' Compute rollover hydrostatics with lcg = lcb Rhino.Command "-_OrcaHydrostatics Mirror=" + mirror + " Description ""Sample Hydrostatics Righting Arm"" " + _ "LoadCase SinkageOptions SpecifyWeight " + CStr(displacement) + _ " TrimOptions SpecifyLCG " + CStr(newLcg) + _ " HeelOptions SpecifyHeel 0 VCG " + CStr(vcg) + " _enter RightingArms Compute=Yes HeelAngles " + _ CStr(heelAngle) + " _enter _enter" ' Retrieve righting arm for zero trim hydrostatics If Not IsNull(orcaPlugIn) Then hydrostaticsList = orcaPlugIn.MostRecentStabilityResults End If If hydrostaticsList <> Nothing And IsArray(hydrostaticsList) Then Dim iHydro iHydro = 0 For Each hydrostatics In hydrostaticsList iHydro = iHydro + 1 If iHydro = 2 Then output = output & VbCrLf + CStr(heelAngle) + ", " + CStr(hydrostatics.Trim) +_ ", " + CStr(hydrostatics.TransverseRightingArm) End If Next End If Next Rhino.TextOut output End Sub