RSA Dynamo API python continue untill

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.
@Jonathan.Olesen @JacobSmall @alex.mcfadyen

in this topic you will find the steel design calculate function

thanks in advance

Gr Edward

well… I don’t have Robot skill (nor do I even have it installed), and Dynamo 1.3 is well into my rear view mirror, so I can’t test anything out for real. However what you’re after sounds feasible, but let me confirm the ‘goal’ here.

You want to rest the building on a slab, and support that slab on n piles and evaluate the whole design for compliance.

If so try adding a while loop on the code to make it execute repeatedly until the . Something like this (which isn’t real Python code and hasn’t been tested but was written from my phone which is hard to just get the forum formatting to work) should give you something to at least consider:

##After all the inputs are done
PileTests = [List, of, all, pile, layouts, you, want, to, test, in, the, order, you, want, to, test, them]

test = 0
ratio = 1000
max = Count(PileTests)
baseStructure = [the, super, structure, which, is, static, goes, here]

while test < max and ratio > 1: 
   pile = PileTests[test]
   ##add the pile to the design you're testing
   baseStructure.append(pile)
   ##do the structure evaluation here, returning the ratio as **analysisResult** and the resulting structure as 'resulting structure'
   ratio = result
if ratio < 1 :
   structure=baseStructure
else:
   structure="Results did not pass ratio test"
OUT = baseStructure

Two things to note.

First up, there are TWO escape clauses to my while loop to prevent infinite looping. The first will trigger a stop when you’ve evaluated all the pile layouts which you want to evaluate. The second will trigger a stop when the ratio is met. You need the first as you might never reach the 2nd, and the program could just keep testing until you force it to quit or it reaches the inevitable heat death of the universe…

Secondly, remember that this will take some time to execute. If your super structure takes 120 minutes to execute, then you’ll be evaluating up to (Substructure Evaluation Time + 120) * max minutes. In the example above you could be looking at around 1.5 days without a passing example (assuming ever word I used as a pile test fails and the sub structure adds ~7% to the calculation time on average).

I think that ideally you’d have a means of doing a the evaluation using a genetic algorithm to explore the design space as the location of the piles will matter as much as the count does, or you’d be able to apply machine learning to build a data set which learns from previous examples. The concern with 'evaluate in order until you get something which passes means that you might miss out on another passing design which could be better overall, and the actual design space is HUGE for something as simple as laying out piers in a rectangle. I know a lot of stuff is being looked into by various offices - I know Paul Kassabian’s team at SGH’s Boston office (his youtube channel is here) as they have done quite a bit of study on applying machine learning to this particular problem.

It is feasable but I worry that the placement of the piles does not matter in your case which sounds a little odd

Jacobs script is a way to go however you need to either load a model and add piles using script or script the entire model inside the loop which is not optimal using Robot at least as far as my experience go

1 Like

Hi @JacobSmall and @Jonathan.Olesen
thanks for your replies. i saw i forgot something to mention. I’m only calculating the pile model, and not a complete structure(Jonathan i understand you note about the placement, but for this early design phase/structure that’s going to be build on these piles it okay to have the total load equally spread on all piles).
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
Dynamo fileLoop +1 opzet 0_01.dyn (5.1 KB)

Well you can add the while loop, however the interaction and re-iteration of the RSA will be the difficult part…

Do you know the capacity of the pile, that could help you with a single line of math determine the number of piles needed :wink:

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 = 1
Paalbel = Belasting/1
Unity = Paalbel/Toelaatbaar

Paalbelasting = []
aantal= []


while Unity>1:
#for i in range(len(Aantalpalen)):
	Paalbel = Belasting/i
	Unity = Paalbel/Toelaatbaar
	aantal.append(Unity)
	Paalbelasting.append(Paalbel)
	i=i+1


#Assign your output to the OUT variable.
OUT = Unity, aantal, Paalbelasting

I feel like this is the way to go at the schematic stage.

1 Like

Hi @1234eddie,

I would suggest one of the following options;

  1. Choose a sensible pile arrangement, determine the load in each pile and then use Robot’s design module to design and size your pile, instead of the verification module you are using.

  2. As mentioned already, work out the capacity of a single pile (check bearing pressure, stability, member strength etc) and simply divide your demand by the capacity to determine how many piles you require for a given pile size.

Below is a python script that could also be considered to achieve what you are looking for.
I don’t have experience iterating through a loop that forces robot to run calculations and design checks and return results in this loop.

Hope this helps,
Alex

@JacobSmall @Jonathan.Olesen @alex.mcfadyen many many thanks for all your thoughts and help.
I got my script solved.

Jonathan, i don’t know the capacity of the pile, because the pile load is an interaction between the number of piles and the total load. within the load i’m considering horizontal force, vertical force and a moment due to excentricity, which all influences the stability of the pile.

Alex, 1. i get your point, but i’m not allowed to change the pile dimensions.
2. the bearing capacity is checked in an other part of the module i’m building. but as mentioned in the answer to Jonathan i have to deal with the moments and horizontal force.

And 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.
Robot forum
gr Edward
this is the script now Calc +1 script 0_03.dyn (9.3 KB)

1 Like