Hi all,
I’have some problems to create a script which uses a “continue untill” a criteria is met.
As example:
I have a total building weight of 100kN
For this building weight i want to determine how many pile i have to use.
So i start with 1 pile> load = 100/1=100kN i run the calculation of the pile including the steel design check en will get a ratio of 11.
Then test the ratio <1.0 for one pile this criteria is not met. So add 1 pile
2pilesà 100/2=50kN > ratio 7.5<1.0 add 1 pile
3pilesà 100/3=33.3kN> ratio 5<1.0 add 1 pile
4pilesà 100/2=25kN> ratio 3<1.0 add 1 pile
5pilesà 100/5=20kN> ratio 1.5<1.0 add 1 pile
6pilesà 100/6=16.6kN> ratio 0.99<1.0 done
This is what i’m trying to achive but i can’t find any examples which are related tot his(maybe i’m silly).
I hope someone of you can give me some support on how to write a code(python or else) that works fort his case.
@hack92.ss @Rafal.Gaweda @lukasz_koc1 @cool.stuff
In this topic you will find the steel design calculate function.
Thanks in advance
Gr Edward
Solved! Go to Solution.
Solved by 1234eddie. Go to Solution.
Hi @1234eddie !!!
Let's see if I can help you 🙂
Let's write the code in VBA (which is the most used language in FORUM) and then we convert it to Python 🙂
dim totalReaction as double
dim numPiles as integer
dim ratio as double
Dim data As IRobotReactionData
Set data = ReacServ.SumEx(cas.Number, Comp)
Cells(1, 1) = (data.FZ) / 1000 'kN.m
totalReaction = <value>
numPiles = 1
ratioLimit = 1
While (totalReaction/numPiles < ratioLimit)
'add another pile in RSAP model
'add pile in a RSAP node, like a list of possible nodes which may have a pile
'calculate new model
totalReactions = (data.FZ) / 1000 'kN.m (I'm not sure about this)
numPiles = numPiles + 1
Wend
Cells(1, 1) = (data.FZ) / 1000 'kN.m 'to update previous value
Does this help to start?
We can discuss it, if that help you 🙂
@cool.stuff thanks for your reply.
i saw i forgot something to mention. I’m only calculating the pile model, and not a complete structure.
See the 3 pictures below which contains the steps i described at the begin of the topic.
1 pile Total load 100kN(FZ), 10kNm due to NEN-EN excentricity, and 10kN horizontal force. Ratio is 2.81.
2 piles Total load 100kN/2=50kN(FZ), 10kNm/2=5kNm due to NEN-EN excentricity, and 10kN/2=5kN horizontal force. Ratio is 1.03.
3 piles Total load 100kN/3=33.34kN(FZ), 10kNm/3=3.34kNm due to NEN-EN excentricity, and 10kN/3=3.34kN horizontal force. Ratio is 0.61.
So i went on and started writing a simple script just to figure out how it should work. this is what i have so far.
this is the script inside the python node:
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#The inputs to this node will be stored as a list in the IN variables.
Belasting = IN[0]
Aantalpalen = IN[1]
Toelaatbaar = 10
nraantal = len(Aantalpalen)
i = 0
Paalbel = Belasting/Aantalpalen[i]
Unity = Paalbel/Toelaatbaar
Paalbelasting = []
aantal= []
for i in range(len(Aantalpalen)):
Paalbel = Belasting/Aantalpalen[i]
Unity = Paalbel/Toelaatbaar
aantal.append(Unity)
Paalbelasting.append(Paalbel)
#Assign your output to the OUT variable.
OUT = Unity, nraantal, aantal, Paalbelasting
But know i have to add the while function on this so my script will stop wen reaching the ratio/unity of 1. which is as you can see in the picture with 10 piles.
Does anyone of you know how to write the “while” in this script to get this working?
Thanks in advance
Gr Edward
Files are attached
Something like this? (I dont know if it is corret! I dont complete understand what is written)
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#The inputs to this node will be stored as a list in the IN variables.
Belasting = IN[0]
Aantalpalen = IN[1]
Toelaatbaar = 10
nraantal = len(Aantalpalen)
i = 0
Paalbel = Belasting/Aantalpalen[i]
Unity = Paalbel/Toelaatbaar
Paalbelasting = []
aantal= []
while unity > 1: #Maybe here, because 'unity' is computed in the line above, so the loop should be below it
for i in range(len(Aantalpalen)):
Paalbel = Belasting/Aantalpalen[i]
Unity = Paalbel/Toelaatbaar
aantal.append(Unity)
Paalbelasting.append(Paalbel)
#Assign your output to the OUT variable.
OUT = Unity, nraantal, aantal, Paalbelasting
@Rafal.Gaweda @cool.stuff thanks thank for your replies and thoughts.
I got my script solved.
Here it is. For everyone whos’s using this script(which has in my opinion a lot of potentional) keep in mind that i haven’t used a break function at the end, so if you have a structure where your “Unity” will never reach <1 the script will run forever.
This is the script. including the robot calculate and steel design calculate.
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
from System import Environment
user = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
clr.AddReferenceToFileAndPath(user +r"\Dynamo\Dynamo Core\1.3\packages\Structural Analysis for Dynamo\bin\RSA\Interop.RobotOM.dll")
from RobotOM import *
from System import Object
objects = IN[0]
LoadCaseID = IN[1]
ILRT = IN[2]
FYH = IN[3]
FZV = IN[4]
CX = IN[5]
Location = IN[6]
File = IN[7]
application = RobotApplicationClass()
project = application.Project
structure = project.Structure
labels = structure.Labels
loads = structure.Cases
i = 1
Unity = 1.1
Paalbelasting = []
allUC = []
while Unity>=1:
PaalbelH = FYH/i
PaalbelZ = FZV/i
PaalbelCX = CX/i
CreatedLoads = []
for j in range(len(LoadCaseID)):
cas = structure.Cases.Get(LoadCaseID[j])
simplecase = IRobotSimpleCase
simplecase = cas
rec = IRobotLoadRecord
IRobotLoadRecordMngr = simplecase.Records
count = IRobotLoadRecordMngr.Count
for k in range(count+1)[::-1]:
rec = simplecase.Records.Delete(k)
Uniform = []
Uniform.append(simplecase.Records.New(ILRT[j]))
LoadRecord = simplecase.Records.Get(Uniform[0])
LoadRecord.SetValue(0,0)
LoadRecord.SetValue(1,PaalbelH)
LoadRecord.SetValue(2,PaalbelZ)
LoadRecord.SetValue(3,PaalbelCX)
LoadRecord.Objects.FromText(objects[j])
CreatedLoads.append(LoadRecord.UniqueID)
application.Project.ViewMngr.Refresh()
calcEngine = project.CalcEngine
calcEngine.AutoGenerateModel = True
calcEngine.UseStatusWindow = True
calcEngine.Calculate()
RDMServer = IRDimServer
RDMServer = application.Kernel.GetExtension("RDimServer")
RDMServer.Mode = 1
RDmEngine = IRDimCalcEngine
RDmEngine = RDMServer.CalculEngine
RDMCalpar = IRDimCalcParam
RDMCalCnf = IRDimCalcConf
RDMCalpar = RDmEngine.GetCalcParam()
RDMCalCnf = RDmEngine.GetCalcConf()
RdmStream = IRDimStream
RdmStream = RDMServer.Connection.GetStream()
RdmStream.Clear()
RdmStream.WriteText("all")
RDMCalpar.SetObjsList(IRDimCalcParamVerifType.I_DCPVT_MEMBERS_VERIF, RdmStream)
RDMCalpar.SetLimitState(IRDimCalcParamLimitStateType.I_DCPLST_ULTIMATE,1)
RdmStream.Clear()
RdmStream.WriteText("1to7")
RDMCalpar.SetLoadsList(RdmStream)
RDmEngine.Solve(RdmStream)
RdmAllResObjType = IRDimAllResObjectType
RdmAllRes = IRDimAllRes
RdmAllRes = RDmEngine.Results()
RdmAllResObjType = 1
ObjCnt = RdmAllRes.ObjectsCount
RDmRetValue = IRDimMembCalcRetValue
RDmDetRes = IRDimDetailedRes
RDmDetRes = RdmAllRes.Get("1")
Case = RDmDetRes.GovernCaseName
Ratio = RDmDetRes.Ratio
RdmCodeRes = object
RdmCodeRes = RDmDetRes.CodeResults
Nbyrd = RdmCodeRes.BuckStrenNbyrd
Unity = Ratio
allUC.append(Unity)
i=i+1
aantalpalen = i-1
aantalp = str(aantalpalen)
project.SaveAs(Location+"\\"+ File + aantalp + ".rtd")
OUT = CreatedLoads, count, Unity, allUC, aantalpalen, Case, PaalbelH, PaalbelZ, PaalbelCX
Where is this script going to be used for:
I’m building a module for a client which will deliver a CPT and the vertical and horizontal load of a building. the module i’m building is to determine which is the best combination of number of piles in relation to it’s pile length. Considering all the check’s that has to be done conform the geotechnical eurocde 7.(that’s why the horizontal supports of the pile are Non-linear support based on the soil layers determined from the CPT).
If anyone of you have suggestions (maybe for the break function) or want to know more just aks.
thanks everybody.
gr Edward
file is attached