(API) Getting properties for large collection of nodes/bars etc

(API) Getting properties for large collection of nodes/bars etc

Anonymous
Not applicable
705 Views
3 Replies
Message 1 of 4

(API) Getting properties for large collection of nodes/bars etc

Anonymous
Not applicable

Hi,

 

I just wondered what the quickest method is for reading the properties (e.g. nodal co-ordinates) of a large number of elements via the API.  Previously I've simply created a RobotCollection and then looped through reading each item one by one, but this tends to be very slow for large numbers of elements.  Is there a faster way of querying object properties - nodal co-ordinates, bar properties etc (something similar to the query mechanism for obtaining analysis results)?

 

Thanks,

 

Alan Carter

 

0 Likes
Accepted solutions (1)
706 Views
3 Replies
Replies (3)
Message 2 of 4

Rafal.Gaweda
Autodesk Support
Autodesk Support
Accepted solution

Hi @Anonymous

 

It should be possible by results query or by dumping table(s) to csv

Take a look at this forum thread.

 

Macro for damping any table here.

 

 

In case of resultsquery I think, I am not sure, but something like that should be used:

 

        queryParams.SetParam(RobotOM.IRobotResultParamType.I_RPT_NODE, 1)

        queryParams.SetParam(RobotOM.IRobotResultParamType.I_RPT_RESULT_POINT_COORDINATES, 1)

 

 

 then

 

Dim arrxyz As Double() = row.GetParam(RobotOM.IRobotResultParamType.I_RPT_RESULT_POINT_COORDINATES)



Rafal Gaweda
Message 3 of 4

Anonymous
Not applicable

Thanks Rafal, that's perfect - I'll try the query method.

Alan.

 

0 Likes
Message 4 of 4

Anonymous
Not applicable

Hi Rafal, I've tried you solution and I don't know why is no working, I think I'm doing correctly, can you check it out?

 

public static List<KeyValuePair<int, Punto>> Puntos(List<int> IDs_Robot)
{
    // I generate the returning object of the method.
    List<KeyValuePair<int, Punto>> elemento_retorno = new List<KeyValuePair<int, Punto>>();

    // I generate all selections requiered.
    RobotSelection seleccion_nodos = Datos.Estructura.Selections.Create(IRobotObjectType.I_OT_NODE);
    seleccion_nodos.Clear();
    foreach (int id in IDs_Robot) seleccion_nodos.AddOne(id);

    // I generate the query.
    RobotResultQueryParams tabla = Datos.Aplicacion.CmpntFactory.Create(IRobotComponentType.I_CT_RESULT_QUERY_PARAMS);
    RobotResultRowSet iterador = new RobotResultRowSet();
    tabla.Selection.Set(IRobotObjectType.I_OT_NODE, seleccion_nodos);
    tabla.SetParam(IRobotResultParamType.I_RPT_NODE, 1);
    tabla.SetParam(IRobotResultParamType.I_RPT_RESULT_POINT_COORDINATES, 1); 
    tabla.ResultIds.SetSize(1);
    tabla.ResultIds.Set(1, Convert.ToInt32(IRobotFeResultType.I_FRT_DETAILED_NXX));
    Datos.Estructura.Results.Query(tabla, iterador);
    bool hay_tabla = iterador.MoveFirst();

    while (hay_tabla == true)
    {
        // I get all values of the row.
        int nodo = iterador.CurrentRow.GetParam(IRobotResultParamType.I_RPT_NODE);
        double[] coords = iterador.CurrentRow.GetParam(IRobotResultParamType.I_RPT_RESULT_POINT_COORDINATES) as double[];
        string hola = iterador.CurrentRow.GetParam(IRobotResultParamType.I_RPT_RESULT_POINT_COORDINATES).ToString();
        Punto punto = new Punto(coords);

        // I add a new entry.
        elemento_retorno.Add(new KeyValuePair<int, Punto>(1, punto));
        hay_tabla = iterador.MoveNext();
    }

    // I return the requiered object
    return elemento_retorno;
}

PD: Datos.Estructura represents a RobotStructure object and Datos.Aplicacion represents a RobotApplication object

0 Likes