Hi all,
I'm currently working on a script that will remove all avaible supports that are defined in a project.(because it will be part of a bigger script that will run several times and everytime the supports will change.)
here is the list of the supports which are stored.
this is the error i get when running the script.(but labels are deleted, not always. sometimes 1 remains)
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File "<string>", line 28, in <module>
EnvironmentError: System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
at Microsoft.Scripting.ComInterop.ComRuntimeHelpers.CheckThrowException(Int32 hresult, ExcepInfo& excepInfo, UInt32 argErr, String message)
at CallSite.Target(Closure , CallSite , Object , Object )
at lambda_method(Closure , Object[] , StrongBox`1[] , InterpretedFrame )
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)
at DSIronPython.IronPythonEvaluator.EvaluateIronPythonScript(String code, IList bindingNames, IList bindingValues)
this is the script which i use to delete the labels.
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
#The inputs to this node will be stored as a list in the IN variables.
start = IN[0]
application = RobotApplicationClass()
project = application.Project
structure = project.Structure
labels = structure.Labels
loads = structure.Cases
LabServ = IRobotLabelServer
LabServ = project.Structure.Labels
RNA = IRobotNamesArray
RNA = LabServ.GetAvailableNames(IRobotLabelType.I_LT_SUPPORT)
count = RNA.Count
for i in range(count+1)[::-1]:
LabServ.Delete(IRobotLabelType.I_LT_SUPPORT, RNA.Get(i))
OUT = "gedaan", count
Does anyone of you know where/what i'm doiing wrong to get this working without any errors?
Thanks in advance
Gr Edward.
PS: files are attached(robot with stored labels, and dynamo file). i'm working with dynamo studio.
Solved! Go to Solution.
Solved by Stephane.kapetanovic. Go to Solution.
Solved by 1234eddie. Go to Solution.
Solved by Rafal.Gaweda. Go to Solution.
Hi @1234eddie
Simple VBA script works fine
Public robapp As RobotApplication
Private Sub CommandButton1_Click()
Dim robapp As RobotApplication
Set robapp = New RobotApplication
RNA = IRobotNamesArray
Set RNA = robapp.Project.Structure.Labels.GetAvailableNames(IRobotLabelType.I_LT_SUPPORT)
Count = RNA.Count
For i = 1 To Count
robapp.Project.Structure.Labels.Delete IRobotLabelType.I_LT_SUPPORT, RNA.Get(i)
Next i
End Sub
@Rafal.Gaweda thanks.
i had to change the range definition.
this is the corrected script to use with dynamo.
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
#The inputs to this node will be stored as a list in the IN variables.
start = IN[0]
application = RobotApplicationClass()
project = application.Project
structure = project.Structure
labels = structure.Labels
loads = structure.Cases
RNA = IRobotNamesArray
RNA = project.Structure.Labels.GetAvailableNames(IRobotLabelType.I_LT_SUPPORT)
count = RNA.Count
for i in range(1, count+1):
project.Structure.Labels.Delete(IRobotLabelType.I_LT_SUPPORT, RNA.Get(i))
OUT = "gedaan", count
Gr Edward
i solved this last week, but i will try to go one step further in deleting.
Because with the function now it will only delete the support labels. but i want also to delete the non-linear model(force displacement).
I tried to search in the api documentation to get it solved but no luck yet.
this code is what i tried:
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
#The inputs to this node will be stored as a list in the IN variables.
start = IN[0]
application = RobotApplicationClass()
project = application.Project
structure = project.Structure
labels = structure.Labels
loads = structure.Cases
RNA = IRobotNamesArray
RNA = project.Structure.Labels.GetAvailableNames(IRobotLabelType.I_LT_SUPPORT)
count = RNA.Count
for i in range(1, count+1):
project.Structure.Labels.Delete(IRobotLabelType.I_LT_SUPPORT, RNA.Get(i))
RNL = IRobotNonlinearLinkServer
RNL = structure.Nodes.NonlinearLinks.Get("all")
countB = RNL.Count
OUT = "gedaan", count, countB
but i don't get numbers or names from the models.
Do you know or have a example how to call these labels?
Thanks in advance
Gr Edward
Hi all,
@chjpcoi @JacquesGaudin @cool.stuff @lukasz_koc1 does anyone of you have an option or thoughts about the question of deleting the nonlinear model labels?
Thanks in advance.
Gr edward
The following should delete labels where at least one of the support direction has an associated non-linear model.
rb = RobotApplicationClass()
structure = rb.Project.Structure
labels = structure.Labels
support_names = labels.GetAvailableNames(IRobotLabelType.I_LT_SUPPORT)
for i in range(1, support_names.Count + 1):
name = support_names.Get(i)
label = labels.Get(IRobotLabelType.I_LT_SUPPORT, name)
if any((label.Data.NonLinearModel.IsDefined(i) for i in range(5))):
labels.Delete(IRobotLabelType.I_LT_SUPPORT, name)
Thanks @JacquesGaudin
your script works. but it's still deleting only the support labels.
this is the script i use to create the 'Non linear model definition with force-displacement'
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
#The inputs to this node will be stored as a list in the IN variables.
#Define input
nodeSupportName = IN[0]
Model_name = IN[1]
K1= IN[2]
D1 = IN[3]
K2 = IN[4]
nodeSupportData = IN[5]
application = RobotApplicationClass()
project = application.Project
structure = project.Structure
labels = structure.Labels
ProjectPrefs = project.Preferences
#NodeSupport
KNLL = IRobotNonlinearLinkServer
KNLL = IRobotNonlinearLink
KnnLP= IRobotNonlinearLinkParamsBLinear
for i in range(len(nodeSupportName)):
KNLL= structure.Nodes.NonlinearLinks.Create(Model_name[i])
KNLL.ModelType= IRobotNonlinearLinkModelType.I_NLMT_FORCE_DISPLACEMENT
KNLL.SetCurveType(IRobotNonlinearLinkCurveType.I_NLCT_B_LINEAR)
KnnLP = KNLL.GetParams(IRobotNonlinearLinkSemiAxisType.I_NLSAT_ANY)
KnnLP.D1 = D1[i]
KnnLP.K1 = K1[i]
KnnLP.K2 = K2[i]
KNLL.SetParams(KnnLP)
node = labels.Create(IRobotLabelType.I_LT_NODE_SUPPORT, nodeSupportName[i])
relData=node.Data
relData.NonlinearModel.Set(IRobotDegreeOfFreedom.I_DOF_UX, KNLL.Name)
relData.NonlinearModel.Set(IRobotDegreeOfFreedom.I_DOF_UY, KNLL.Name)
node.Data.UZ = nodeSupportData[0]
node.Data.RX = nodeSupportData[1]
node.Data.RY = nodeSupportData[2]
node.Data.RZ = nodeSupportData[3]
labels.Store(node)
application.Visible = True
application.Interactive = True
application.Project.ViewMngr.Refresh()
OUT = node.Name
So what i try to delete is also the nonlinear models.
or @Rafal.Gaweda do you maybe know how to delete them?
thanks in advance. i really appreciate everybody's answers.
Gr Edward
The following should delete the NonLinearModel too. Not sure if Delete throws an exception when no NL model is defined so I put it in a try except statement to err on the side of caution.
rb = RobotApplicationClass()
structure = rb.Project.Structure
labels = structure.Labels
support_names = labels.GetAvailableNames(IRobotLabelType.I_LT_SUPPORT)
for i in range(1, support_names.Count + 1):
name = support_names.Get(i)
label = labels.Get(IRobotLabelType.I_LT_SUPPORT, name)
if any((label.Data.NonLinearModel.IsDefined(i) for i in range(5))):
for i in range(5):
try:
label.Data.NonLinearModel.Delete(i)
except:
pass
labels.Delete(IRobotLabelType.I_LT_SUPPORT, name)
Hi @JacquesGaudin @Rafal.Gaweda @gwizdzm
It has been a while since last message, got a little bit busy on different projects. But the mentioned problem that the non-linear models are not deleted is still a problem.
I tried the script from youre message @JacquesGaudin , which deletes the labels in the support manager and gives at the and the next error due to the existance of some normal supports. see picture
this is the result in Robot
the part in the blue box is what i also want to delete(see explanation below why).
this is the script i used
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
#The inputs to this node will be stored as a list in the IN variables.
start = IN[0]
application = RobotApplicationClass()
project = application.Project
structure = project.Structure
labels = structure.Labels
loads = structure.Cases
#RNA = IRobotNamesArray
support_names = project.Structure.Labels.GetAvailableNames(IRobotLabelType.I_LT_SUPPORT)
count = support_names.Count
for i in range(1, count+1):
name = support_names.Get(i)
label = labels.Get(IRobotLabelType.I_LT_SUPPORT,name)
if any((label.Data.NonLinearModel.IsDefined(i) for i in range(5))):
for i in range(5):
try:
label.Data.NonLinearModel.Delete(i)
#label.Data.NonLinearModel.Remove(i)
# label.Data.NonLinearLink.Remove(i)
except:
pass
project.Structure.Labels.Delete(IRobotLabelType.I_LT_SUPPORT, name)
OUT = "gedaan", count
Explanation:
- i made a script to calculate different section(VB: HEA360, IPE400, etc) as foundation pole in a specific CPT sounding. the script runs over a preset(by myself) depth trajectory, and when the deflection and some other criteria are met it switches over to the next section with a maximum of 10 sections.(I say it's a smart brute force search)
- but within one section i have 5 verification steps(changes in spring stiffness and water levels) from the geotechnical eurocode 9997-1 which i should check.
- example. i want to know from 10 section in a specific CPT what the lenght will be. top of section at normal ground level(0.00NAP) expected depth traject -5.00NAP to -9.00NAP the horizontal springs are added every 25cm so for a full model to -9.00NAP i have (9/0.25=)36 non-linear supports for 1 verification step x5= 180 for a complete analysis of one section x10= 1800 non-linear supports when running the last section of all.
so robot is really slowing down when having to deal with this amount of non-linear models and definitions(also increasing the file sizes) that's why i want to find a way to delete them.
So i hope one of you can help me with this.
Thanks in advance
Gr Edward.
files are attached.
Typically, here is a code to remove items from non linear link server list (RobotNonlinearLinkServer).
RNLS = Robapp.Project.Structure.Nodes.NonlinearLinks
for idx in range(1, RNLS.Count + 1):
RNLS.Remove(idx)
you can also read the subject below:
In the case of your files, I advise you to first delete all the assignments (Supports, Curves, etc.). (too many models)
This code will not remove non-linearity models in the case where nodes have supports affected by these models
To do this, they must first be released.
As you seem to have code to assign them, I haven't written anything about them. If necessary,...
many thanks for your answer, i did't expect to find the function under the 'Nodes server' instead of the 'Label server'.
Your script works perfect, i only had to change the loop direction, because robot is renumbering the list every time there gets an item removed.
So here are my full functions. Removing all supportlabels and removing all Non-linear models.
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
#The inputs to this node will be stored as a list in the IN variables.
start = IN[0]
application = RobotApplicationClass()
project = application.Project
structure = project.Structure
labels = structure.Labels
loads = structure.Cases
"Delete all supports, including assigned supports"
RNA = project.Structure.Labels.GetAvailableNames(IRobotLabelType.I_LT_SUPPORT)
count_sup = RNA.Count
for i in range(1, count_sup+1):
project.Structure.Labels.Delete(IRobotLabelType.I_LT_SUPPORT, RNA.Get(i))
"Delete all Non-linear models, including assigned ones"
RNLS = project.Structure.Nodes.NonLinearLinks
count_nonlin = RNLS.Count
for j in range(count_nonlin+1)[::-1]:
RNLS.Remove(j)
OUT = "gedaan", count_nonlin, count_sup
Thanks for youre other thoughts.
What i'm(script) doing when the script moves on to the next section it's deleting it's complete model, than i will use above presented script, and start building the model again.
Only the end-models where one of the criteria is met will be saved.
Everybody thanks for reading and thinking along.
Gr Edward
file is attached