API c#

API c#

bechir_hammadi
Explorer Explorer
846 Views
4 Replies
Message 1 of 5

API c#

bechir_hammadi
Explorer
Explorer

Hello,

 

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

0 Likes
Accepted solutions (1)
847 Views
4 Replies
Replies (4)
Message 2 of 5

Stephane.kapetanovic
Mentor
Mentor

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

 

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
0 Likes
Message 3 of 5

bechir_hammadi
Explorer
Explorer

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 

0 Likes
Message 4 of 5

Stephane.kapetanovic
Mentor
Mentor
Accepted solution

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

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
0 Likes
Message 5 of 5

bechir_hammadi
Explorer
Explorer

Thank you very much, that hekofull 🙂