# Rapid-Code Import from .txt-file to Robotstudio

**URL:** <https://tech-community.robotics.abb.com/t/rapid-code-import-from-txt-file-to-robotstudio/11482>\
**Category:** RobotStudio\
**Created:** [June 19, 2024, 1:25pm UTC](https://tech-community.robotics.abb.com/t/rapid-code-import-from-txt-file-to-robotstudio/11482 "2024-06-19T13:25:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bochiller](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@bochiller](https://tech-community.robotics.abb.com/u/bochiller)\
**Post date:** [June 19, 2024, 1:25pm UTC](https://tech-community.robotics.abb.com/t/rapid-code-import-from-txt-file-to-robotstudio/11482/1 "2024-06-19T13:25:55Z")

</div>

Hello 🙂  
i am generating Rapid Code with a Python-Script, which is connected to Chatgpt. The code ist then saved as a .txt file on my PC. Now i want to automatically import the code to Robotstudio, but I cant find a way to do so.

My Idea was, that I either send the code via an api to Robotstudio or I tell Robotstudio where the txt.-file is and it gets importet. But I cant find a way to implement something like this.

Thanks  
Levin

---

<div class="post-metadata">

**Author:** ![lemster68](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/lemster68/32/1945_2.png) [@lemster68](https://tech-community.robotics.abb.com/u/lemster68)\
**Post date:** [June 19, 2024, 4:19pm UTC](https://tech-community.robotics.abb.com/t/rapid-code-import-from-txt-file-to-robotstudio/11482/2 "2024-06-19T16:19:36Z")

</div>

Don’t save it as .txt, save it as .mod. All rapid modules are text files basically. Use the Load command in rapid to then load your .mod file.

---

<div class="post-metadata">

**Author:** ![bochiller](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@bochiller](https://tech-community.robotics.abb.com/u/bochiller)\
**Post date:** [June 21, 2024, 10:47am UTC](https://tech-community.robotics.abb.com/t/rapid-code-import-from-txt-file-to-robotstudio/11482/3 "2024-06-21T10:47:02Z")

</div>

Thanks for the answer!  
I tried searching for the command-syntax but couldnt find any.  
Could you explain to me how the load command should look?

---

<div class="post-metadata">

**Author:** ![lemster68](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/lemster68/32/1945_2.png) [@lemster68](https://tech-community.robotics.abb.com/u/lemster68)\
**Post date:** [June 21, 2024, 12:06pm UTC](https://tech-community.robotics.abb.com/t/rapid-code-import-from-txt-file-to-robotstudio/11482/4 "2024-06-21T12:06:40Z")

</div>

You are welcome.  
A search on this site should yield quite a few threads concerning Load/UnLoad.

---

<div class="post-metadata">

**Author:** ![bochiller](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@bochiller](https://tech-community.robotics.abb.com/u/bochiller)\
**Post date:** [June 21, 2024, 1:16pm UTC](https://tech-community.robotics.abb.com/t/rapid-code-import-from-txt-file-to-robotstudio/11482/5 "2024-06-21T13:16:17Z")

</div>

I have found some discussions, but I still can’t really make progress. My current code looks like this:

var string diskhome := “c:/asdf/”;  
Load\Dynamic,diskhome\File:=“Code.Mod”;

I get the error message that the file cannot be found…"

---

<div class="post-metadata">

**Author:** ![lemster68](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/lemster68/32/1945_2.png) [@lemster68](https://tech-community.robotics.abb.com/u/lemster68)\
**Post date:** [June 21, 2024, 1:32pm UTC](https://tech-community.robotics.abb.com/t/rapid-code-import-from-txt-file-to-robotstudio/11482/6 "2024-06-21T13:32:10Z")

</div>

The path to the virtual controller’s home is very different from that. If that is where the file is located, try to specify that and drop the variable assignment to diskhome and use the path in your load instruction.  
Or, maybe copy it into the virtual controller’s home directory first.

---

<div class="post-metadata">

**Author:** ![bochiller](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@bochiller](https://tech-community.robotics.abb.com/u/bochiller)\
**Post date:** [June 21, 2024, 2:44pm UTC](https://tech-community.robotics.abb.com/t/rapid-code-import-from-txt-file-to-robotstudio/11482/7 "2024-06-21T14:44:53Z")

</div>

I must admit that I don’t really understand what you mean, this is the first time I’m using RobotStudio. So if you could perhaps explain it again, I would be very grateful.

Otherwise, I had another idea: As far as I understand, the RAPID code is saved as a .modx file under C:\Users\droste\Documents\RobotStudio\Projects\Project4\Controller Data\IRB4600\_20\_250\RAPID\TASK1\PROGMOD\Module1.modx. My idea was to edit this file directly with Python, but when I change this file, the code remains the same.

---

<div class="post-metadata">

**Author:** ![lemster68](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/lemster68/32/1945_2.png) [@lemster68](https://tech-community.robotics.abb.com/u/lemster68)\
**Post date:** [June 21, 2024, 4:04pm UTC](https://tech-community.robotics.abb.com/t/rapid-code-import-from-txt-file-to-robotstudio/11482/8 "2024-06-21T16:04:50Z")

</div>

In the case of the demo project I have opened in RS, this is the path to the home directory in full:

C:\Users\*_YourUserName_\*\Documents\RobotStudio\Projects\Demo Exhaust Pipe\Virtual Controllers\IRB1600ID\_AW\HOME

You can save or copy the module to the home of the virtual controller you are working with. Then, just use Load “HOME:”\File:=“MyMod.mod”;
