Robot Structural Analysis Forum
Welcome to Autodesk’s Robot Structural Analysis Forums. Share your knowledge, ask questions, and explore popular Robot Structural Analysis topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Reply
Message 1 of 5
bechir_hammadi
398 Views, 4 Replies

API c#

Hello,

 

Some one can help me please with documents to c# API for RSA.

4 REPLIES 4
Message 2 of 5

hi @bechir_hammadi 

you have several files and example delivered with the SDK (need to be installed) located in the installation subdirectory ...\SDK.

Look also to this topic 

Best Regards

 

Tags (1)
Message 3 of 5

I have the SDK installed and API references for robot are active in visual studio 

But still have problem, I guess related to syntaxe, that is why I need a document (pdf) where i can found syntaxe of C# for RSA.

using System;
using System.Runtime.InteropServices;
using RobotOM;

namespace RSAExample
{
class Program
{
static void Main(string[] args)
{
IRobotApplication rsaApp = null;

try
{
// Création de l'instance de l'interface IRobotApplication
rsaApp = (IRobotApplication)Activator.CreateInstance(Type.GetTypeFromProgID("Robot.Application"));

// Vérifier si RSA est en cours d'exécution
if (rsaApp != null)
{
rsaApp.Interactive = 1; // Démarrer en mode interactif

// Spécifier le chemin du projet existant
string fullProjectPath = @"C:\Users\bechir.hammadi\Desktop\NDC\NomDuFichier01.rtd";

// Ouvrir le projet existant
rsaApp.Project.Open(fullProjectPath);

IRobotStructure structure = rsaApp.Project.Structure;

IRobotNodeServer nodeServer = structure.Nodes;
nodeServer.Create(1, 0, 0, 0);
nodeServer.Create(2, 0, 0, 3);

IRobotBarServer barServer = structure.Bars;
barServer.Create(1, 1, 2);

rsaApp.Project.Preferences.SetCurrentDatabase(IRobotDatabaseType.I_DT_SECTIONS, "SIMPL");
IRobotLabel Section = rsaApp.Project.Structure.Labels.Create(IRobotLabelType.I_LT_BAR_SECTION, "HEA 120");
IRobotBarSectionData SData = Section.Data;
SData.LoadFromDBase("HEA 120");
rsaApp.Project.Structure.Labels.Store(Section);

RobotBar Bar1 = (RobotBar)rsaApp.Project.Structure.Bars.Get(1);
Bar1.SetLabel(IRobotLabelType.I_LT_BAR_SECTION, "HEA 120");


// Enregistrer les modifications apportées au projet
rsaApp.Project.Save();


Console.WriteLine("Modifications enregistrées avec succès.");
}
else
{
Console.WriteLine("Robot Structural Analysis n'est pas en cours d'exécution.");
}
}
catch (Exception ex)
{
Console.WriteLine("Une erreur s'est produite : " + ex.Message);
}
finally
{
// Libérer les ressources
if (rsaApp != null)
{
Marshal.FinalReleaseComObject(rsaApp);
}
}
}
}
}

For exemple the script is good and executed but than I cant find the file, may be there is an other method to save it 

Message 4 of 5

Hi @bechir_hammadi 

refer to the “Getting Started Guide Robot API.pdf” in the SDK directory on page 31 for the code in C#

instead of FinalReleaseComObject:

while (Marshal.ReleaseComObject(rsaApp) != 0); rsaApp = null;

Best Regards

 

 

Tags (2)
Message 5 of 5

Thank you very much, that hekofull 🙂 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report