Delete all support labels by API

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.
saved labels
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 “”, line 28, in
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.
Dyname file Delete info 3.dyn (2.4 KB)
for robot file with saved labels see this link

Qeustion solved on the autodesk robot structural analysis forum.
Had to change the range definition.