since a few months RSA 2024 is out. in our company we do have quite a few scripts that we rewrote from ironpython2 tot Cpython3 due to the switch from ‘dynamo studio’ to integrated dynamo.
Now we run in RSA 2022 with Dynamo 2.11. Works perfectly fine.
In RSA 2024 its the new 2.17 Dynamo.
and when we now start checking our scripts we have a problem with the load assignment.
This is what we get with 2022
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
from System import Environment
user = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
sys.path.append(user+r"\Dynamo\Dynamo Core\2.11\packages\Structural Analysis for Dynamo\bin\RSA\Interop.RobotOM.dll")
clr.AddReference('interop.RobotOM')
#clr.AddReference(user+r"\Dynamo\Dynamo Core\2.11\packages\Structural Analysis for Dynamo\bin\RSA\Interop.RobotOM.dll")
from RobotOM import *
from System import Object
objects = IN[0]
LoadCaseID = IN[1]
ILRT = IN[2]
LoadPX = IN[3]
LoadPY = IN[4]
LoadPZ = IN[5]
application = RobotApplicationClass()
project = application.Project
structure = project.Structure
labels = structure.Labels
loads = structure.Cases
CreatedLoads = []
case = structure.Cases.Get(LoadCaseID)
simplecase = IRobotSimpleCase(case)
rec = IRobotLoadRecordMngr(simplecase.Records)
count = rec.Count
for i in range(count+1)[::-1]:
rec.Delete(i)
for j in range(len(objects)):
#for k in range(len(objects[j])):
Uniform = []
Uniform.append(rec.New(ILRT))
LoadRecord = IRobotLoadRecord(rec.Get(Uniform[0]))
LoadRecord.SetValue(0,LoadPX)
LoadRecord.SetValue(1,LoadPY)
LoadRecord.SetValue(2,LoadPZ[j])
LoadRecord.Objects.FromText(' '.join(str(objects[j]) for el in objects))
#CreatedLoads.append(LoadRecord.UniqueId)
#LoadRecord.Objects.FromText(str(objects[j][k]))
application.Visible = True
application.Interactive = True
application.Project.ViewMngr.Refresh()
OUT = objects
And this is what we get with RSA2024 (same script no changes).
Hi @1234eddie
I wrote it in the quick start guide, and I suppose things didn’t change (I don’t use RSA anymore): you cannot use CPython with RSA! install the Ironpython package and run your python scripts with it.
Sol is on vacation and I don’t have Robot installed at the moment. I may have a project starting soon which would require it, so if that kicks off I will jump in if I can.
Hi. We haven’t changed API in that area. So, I checked “Loads” API in c# project (is easier to debugging) and there everything works fine. The problem is elsewhere, but I don’t know where. We will look at that.
Hi @1234eddie@c.poupin@jacob.small
I apologize for the late reply but we had vacation time. After few tests we know that problem occurs when CPython3 is used. If you install package with the older version of Python in the new Dynamo (and you adapt a litle your code) evrything will works fine. Evrything works with other lenguages (C++, C#) too. Test was made with two version of Dynamo and two vwerion of RSA and we see that only Python version is important.
This is not a problem with “LoadRecord”. We found a few RSA methods witch work inproperlly too and returns invalid object for CPython3, or object is invalid interpreted on CPython3 side.
In this moment we try to investigete behaviour of different Python version outside of Dynamo enviroment.
We have three potential sources of bug:
somthing in the Dynamo enviroment when CPython3 is used,
CPython3 (and other new versions of Pythons?) interpreter ,
different implementation of a few API method in RSA witch are invalid treated in new Python version.
That’s all we know now. I will let you know if we find anything.
Hi @sanzoghenzo
You write in the article Quickstart Guide for Dynamo in RSA 2023 that COM API doesn’t work in CPython3. Is this your experience with RSA API or you found that information about COM API somewhere? I see similar information here: Troubles with switching from IronPython2 to CPython3 but without explanation. I still can’t find the reason, we were sure that it should work (but we are not Python specialist). Especially that it works for many RSA COM objects.
Robot COM API are old, and Autodesk needs to provide a better, .NET API for things to work well with dynamo and python3
pythonnet, the Cpython3 engine used in dynamo, doesn’t support com api and probably never will
Dynamo developers made a huge mistake in pushing cpython as the default interpreter, especially for RSA, since everybody thinks it can be used flawlessly when it obviously it isn’t the case.
That being said, there’s a workaround to handle com objects described here but it’s tedious to use that class to wrap every single COM object.
Do yourself a favour and stick with IronPython 2 until Autodesk developers fix this nightmare…
The TLDR of this is that this simply isn’t something that Autodesk can fix. Python 2 (and therefore Iron Python 2) had to be removed from Dynamo for security reasons, as it is no longer supported and therefore unsecure. Python is owned by a separate entity. Autodesk could implement a different flavor which interacts with the .net environment (just like Iron Python 2 and Iron Python 3), it isn’t our area of expertise. Microsoft (who owns the .net environment, Component Object Model or COM, and the Common Language Runtime or CLR) was the driving force behind Iron Python for a half decade before abandoning the project. I can’t confirm it, but I suspect much of the reliability of Iron Python 2 is likely due to their involvement.
The good news in all of this is that while neither Dynamo nor Autodesk can fix Python implementation issues, we can provide options.
Iron Python 2 should you want to risk it, CPython 3, and Iron Python 3 are all available as engines for you to deploy in your work. Flexibility is good in general as we can ‘get stuff done’ and work to develop in a secure environment.
One last note on this, I suspect a lot will change with the conversion from .net 4.8 to a more modern .net implementation (6, 7 or 8) with the 2025 product line. While some existing code will break, I’m hopeful that more things will be fixed int he long term by that modernization effort.
PythonNet 2.5.x has bugs with the .Net environment and the arrival of .Net 6 may not help things if PythonNet 2.5.x is maintained (instead of PythonNet 3.x)
However, PythonNet 3.x has significant changes (break)
@gwizdzm
Many thanks for your reply.
so if there is a solution with the Cpython3 let me know.
Because it’s now holding us back on upgrading to newer RSA versions.
Hi @1234eddie
For clarification: new version of RSA should work with old Dynamo too.
You can install Dynamo Sandbox (Dynamo Core Runtime), next install package “Structural Analysis for Dynamo” and after that everything should work with last started RSA. It is because when RSA starts COM is register for that version.
So, probably (I’m 99% sure) that if you:
run version 2023,
run Dynamo from RSA “Add-ins” from 2023
close RSA 2003 (without closing Dynamo)
run RSA 2024
open script inside Dynamo
run the script
Dynamo will use RSA 2024…
Additionally you can manually attach Dynamo Sandbox or Dynamo4RSA (Dynamo4RSA from previous version of RSA) to new the RSA as Add-In using Add-In manager. After that it will be accessible from menu in new version of RSA. API changes in RSA were minor, we add something. If you have script for 2023 it should work for 2024 (maybe not in the opposite way).