Message 1 of 17
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Everyone,
How do we code for starting the application? Apologies if this is a very simple question.
Solved! Go to Solution.
Hi Everyone,
How do we code for starting the application? Apologies if this is a very simple question.
Solved! Go to Solution.
Hi @HadiMoosavi
You can access the link below, which has examples and basic steps for beginners
Link: https://forums.autodesk.com/t5/robot-structural-analysis-forum/api-tutorial/td-p/3939601
Have a nice day
@chjpcoi , Hello again,
I looked at those locations. But I didn't find an example that launches Robot.
I found an article in Robot API tutorial (see below). But it does not seem to be the right code for launching a new instance of Robot. Could you please advise on this? By the way, I use C#.
hi @HadiMoosavi
To use API
using RobotOM;
// To use API with Robot and a project open
IRobotApplication RobApp = new RobotApplication();
bool Visible = RobApp.Visible == -1,
IsActive = RobApp.Project.IsActive == -1,
Ready = Visible && IsActive;
if (Ready){
// do something
}
RobApp = null;
// To open Robot and create a new project
RobotApplication RobApp = new RobotApplication();
RobApp.Visible = -1;
RobApp.Project.New(IRobotProjectType.I_PT_FRAME_3D);
Best regards
Thank you very much, Stephane.
What do Visible and Active properties are used for?
There is little information in the SDK.
@Stephane.kapetanovic
I have another question if you would help.
Manually, I can open two instances of Robot.
Is it possible to open two instances using API?
hi @HadiMoosavi
I'm not sure I understand precisely, could you detail the reasons for such a request?
If you plan to use two successive function calls (cascade) on same thread, yes it is possible.
At the same time or very close on same server (multithread), it is not safe.
Working on two robot instances at the same time by API is not possible.
Best regards
I am glad you asked. Here it goes.
I am trying to call RSA from Revit Dynamo in a Generative Design(GD) graph. GD which is some kind of evolutionary algorithm, runs six parallel instances of the graph which means six RSA instances. But based on your answer, it seems it is not possible. Do you have any recommendations?
Does your program itself handle synchronization across the six instances? If so, you could protect access to Robot with a lock. If not, it isn’t safe. It also depends on which parts are implemented. Your project is interesting, but what you’re trying to achieve is complex and not really within the scope of this forum, which is focused on the use of Robot software. I’m not saying there are no solutions, but you should carefully review the requirements of such an asynchronous architecture.
Best regards
It does manage the sync between instances. Although, I did not understand the part about protecting with a lock.
Could you expand on this?
I was referring to a program you developed yourself and over which you have full control, not a third-party application you’re trying to integrate. In your case, it’s not safe.
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/statements/lock
Hi, Why my program always ask to run Robot analysis before starting my program that have robot API ?
Is there a solution to this problem, thank you
hi @WALIDGIO
that’s just how Robot works. There’s no real storage outside the open project, so if the app and project aren’t both running, a bunch of API calls just won’t work.
It’s kind of a built-in safeguard. Most people just add a check at the start of their script to catch that.
Sometimes it shows a message, sometimes it’s silent. You can also delay the check and handle it later in the flow if that makes more sense for your tool.
Some devs even build their own data formats or logic around Robot, so they can split things like, generate stuff first and deal with export later. That way, you are not stuck if Robot is used otherwise or not running permanently.
Excel works great for simple sequential workflows. If the data is more demanding, exporting to formats like plain text, CSV, JSON, XML, or even a database can give you more speed and flexibility.
Best regards
Thanks for the explanation, that helped clarify things.
Quick question: I’d like my app to start even if Robot isn’t running. Then, later (e.g., on an "Import" button), I want to check if Robot and a project are available and proceed.
I want my C# app to:
Start without requiring Robot
Allow users to launch Robot later
Recheck connection on "Import" without restarting the app
The problem is:
If I launch my app when Robot isn’t running, even setting robotApp = null, or trying robotApp = new RobotApplication() when lunching Robot later doesn’t work. the app still acts like Robot is unavailable unless I restart the app.
Is there a clean way to reset or reinitialize the Robot connection once Robot is launched after the app has started?
Any tip or small example would be really appreciated!
Best,
Walid
hi @WALIDGIO
Start without requiring Robot -> yes but you can't use functions creating objects from servers
Allow users to launch Robot later -> add a "send to robot" button
Recheck connection on "Import" without restarting the app -> 1 2 3 asks to create your own objects and classes
Is there a clean way to reset or reinitialize the Robot connection once Robot is launched after the app has started? ReleaseComObject
Best Regards