Apply loads to load cases, RSA 2024

Apply loads to load cases, RSA 2024

stefanyC6JZ7
Enthusiast Enthusiast
3,950 Views
22 Replies
Message 1 of 23

Apply loads to load cases, RSA 2024

stefanyC6JZ7
Enthusiast
Enthusiast

Hello everyone, 

 

I am trying to use RSA 2024 with the extention Dynamo to run the following script. My objective is to get the bars loaded with the input values as the first figure on the left shows. However the python script gives me an error. 

The error is "PythonEvaluator.Evaluate operation failed/ IndentationError : ('Expected an indented block',('<string>',37,5,'    Uniform = []\n'))". occurs when running the script. 

 

stefanyC6JZ7_0-1691418860351.png

stefanyC6JZ7_1-1691419018752.png

 

The Python script is also attached.

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 = IRobotLoadRecordLinear3D(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

 

Could you help me to solve this issue?

Thank you beforehand for your help. 

 

Best regards, 

Stefany Salguero 

 

0 Likes
3,951 Views
22 Replies
Replies (22)
Message 2 of 23

1234eddie
Advocate
Advocate

Hi all,

 

Identation error is gone. But now we get the com object error.

 

This is the result we get when we run the script with RSA2022 and dynamo 2.11

1234eddie_0-1691429185592.png

input and script view

1234eddie_1-1691429268372.png

List input part 2

1234eddie_2-1691429324724.png

 

 

code

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

 

With the code above we get at line 40 the _COM object error. when using RSA2024. Could someone explain us why this is happening, both languages/settings are CPython3

 

Hope some of you may help us out? @cool.stuff @vise92 @Stephane.kapetanovic @JacquesGaudin 

0 Likes
Message 3 of 23

Stephane.kapetanovic
Mentor
Mentor

hi @1234eddie, @stefanyC6JZ7 

I can't see what's in the ILRT variable and if it can match with IRobotLoadRecord.

Stephanekapetanovic_0-1691431471620.png

Best Regards

 

 

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to click the Accept Solution button and leave a < like !
EESignature
0 Likes
Message 4 of 23

1234eddie
Advocate
Advocate

@Stephane.kapetanovic 

 

It's the number 5 of the 'list 2'. 

See image

1234eddie_0-1691434036546.png

 

0 Likes
Message 5 of 23

Stephane.kapetanovic
Mentor
Mentor

hi @1234eddie 

try the loop like this and inspect the num and LoadRecord values

LoadRecord = IRobotLoadRecord
for j in range(len(objects)):
    Uniform = []
    num = rec.New(ILRT)
    Uniform.append(num)
    LoadRecord = rec.Get(num) 
    LoadRecord.SetValue(0,LoadPX)
    # ...

Best Regards

 

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to click the Accept Solution button and leave a < like !
EESignature
0 Likes
Message 6 of 23

stefanyC6JZ7
Enthusiast
Enthusiast

Hi @Stephane.kapetanovic 

Thank you for your answer.

We have followed your code, however the ComObject error is still happening. Please see figure bellow 

error view.JPG 

Also the files are attached. Could you check them please?

 

Best regards, 

Stefany 

 

0 Likes
Message 7 of 23

JacquesGaudin
Advocate
Advocate

You don't need the list `Uniform` anymore. I would try this:

 

    # Uniform = []
    # Uniform.append(rec.New(ILRT)) 
    LoadRecord = IRobotLoadRecord(rec.Create(ILRT)) 
    LoadRecord.SetValue(0,LoadPX)
    LoadRecord.SetValue(1,LoadPY)
    LoadRecord.SetValue(2,LoadPZ[j])

 

0 Likes
Message 8 of 23

stefanyC6JZ7
Enthusiast
Enthusiast

Hi @JacquesGaudin, 

Thank you for your reply. We changed the code, there was an error with line 8, so, first, we changed  line 8 for 9 and it worked. Then, from line 38 to line 40, they are neglected, and I got a new error: "Attribute Error:' IRobotLoadRecord' has no attribute 'Create' line 41." Please see figure below.

Error_2.JPG

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 = []
    #NUM = rec.New(ILRT)
    #Uniform.append(NUM)
    LoadRecord = IRobotLoadRecord(rec.Create(ILRT))
    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

Could you please check it?

 

Best regards, 

Stefany 

0 Likes
Message 9 of 23

JacquesGaudin
Advocate
Advocate

Strange the `Create` method used to be there.

 

JacquesGaudin_0-1691487990218.png

What do you get if you insert the following command:

 

print(dir(rec))
0 Likes
Message 10 of 23

stefanyC6JZ7
Enthusiast
Enthusiast

@JacquesGaudin We changed the code as you suggested, however we get the error: " TypeError: object does not implement  IRobotLoadRecord, line 41" 

stefanyC6JZ7_0-1691489416716.png

Could you check it please?

 

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 = []
    #NUM = rec.New(ILRT)
    #Uniform.append(NUM)
    LoadRecord = IRobotLoadRecord(rec.New(ILRT))
    #LoadRecord = 
    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 = print(dir(LoadRecord))
0 Likes
Message 11 of 23

JacquesGaudin
Advocate
Advocate
That's why I use `Create` rather than `New`.

`Create` returns the load record object whereas `New` returns the index.

Did you try to ``print(dir(rec))``? It would be good to see the result of this command to check whether `Create` is still a method of IRobotLoadRecordMngr.
0 Likes
Message 12 of 23

stefanyC6JZ7
Enthusiast
Enthusiast

@JacquesGaudin 

thanks for your reply,

 

we had to change the call a little bit. is this the list you mean?

 

stefanyC6JZ7_0-1691490656173.png

stefanyC6JZ7_1-1691490689237.png

 

 

0 Likes
Message 13 of 23

JacquesGaudin
Advocate
Advocate

Shocking! 😉

 

It seems that `Create` was removed from IRobotLoadRecordMngr!

 

@gwizdzm Do you know anything about this?

0 Likes
Message 14 of 23

1234eddie
Advocate
Advocate

@JacquesGaudin 

Many thanks for your involvement already.

 

@okapawal @Rafal.Gaweda it seems like @gwizdzm is quite inactive, do you know any other members that coöperate with the structural analysis package?

 

Many thanks in advance

0 Likes
Message 15 of 23

1234eddie
Advocate
Advocate

Hi @JacquesGaudin 

 

We did some trial and error on our script. and figured out that the '.new' function does work. see the images below

step 1-with.JPG

 

step 2-with.JPG

 

creation of the load type does work. te green box line 13 is on our inputs list which does contain 4 list, in the red box is the answer and it says that it ended with 4. that's correct in my opinion. in line 44 'yellow arrow' the .new function is used and indeed in the second image you can see that there is 4 times a uniform load created. Below is the code we used.

 

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 = []
CreatedLoadstype = []
case = structure.Cases.Get(LoadCaseID)
simplecase = IRobotSimpleCase(case)
rec = IRobotLoadRecordMngr(simplecase.Records)
#rec2 = IRobotLoadRecordLinear3D(simplecase.Records)
count = rec.Count

for i in range(count+1)[::-1]:
    #rec = simplecase.Records.Delete(i)
    rec.Delete(i)

#CreatedLoads.append(dir(rec))
#OUT = print(dir(rec))

for j in range(len(objects)):
    #for k in range(len(objects[j])):
    Uniform = []
    NUM = rec.New(ILRT)
    Uniform.append(NUM)
    CreatedLoadstype.append(dir(NUM))
    LoadRecord = IRobotLoadRecord(rec.Get(Uniform[0]))
    CreatedLoads.append(dir(LoadRecord))
    #LoadRecord = IRobotLoadRecordType(rec.New(ILRT))
    #LoadRecord = IRobotLoadRecord2.(NUM)
    #LoadRecord = IRobotLoadRecordType(NUM)
    #LoadRecord.SetValue('I_URV_PX',LoadPX))
    #LoadRecord.GetValue(1,LoadPY)
    #LoadRecord.GetValue(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 = CreatedLoads
OUT = LoadRecord,CreatedLoads,Uniform,NUM,objects,LoadCaseID,ILRT,LoadPX,LoadPY,LoadPZ

 

 

With all this, we know need to figure out in which part/ where is "setvalue" now related?? Because the output of 'LoadRecord' is still a _com object.

 

Many thanks in advance

0 Likes
Message 16 of 23

JacquesGaudin
Advocate
Advocate

@1234eddie Good to know the creation of the load record works. The `New` method is fine, it was just my preference to get the LoadRecord object returned rather than its index but the functionality is pretty much the same.

 

I'm not sure why `LoadRecord` doesn't have a `SetValue` method after casting to `IRobotLoadRecord`. Would you be able to share the exact error message?

 

Also I don't have Robot 2024 on my machine, just 2023. I would be curious to see what the API document says about IRobotLoadRecord and IRobotLoadRecordMngr. The document is usually in C:\Program files\Autodesk\Robot Structural Analysis Professional 2024\SDK. 

0 Likes
Message 17 of 23

1234eddie
Advocate
Advocate

@JacquesGaudin 

 

this is the error message, don't know if this is exactly what you are looking for?

error line 52.JPG

 

or could it be that we call "IRobotLoadRecord" with it's settings wrong?

 

1234eddie_0-1691572603539.png1234eddie_1-1691572639209.png

 

Many thanks in advance, we really appreciate it.

0 Likes
Message 18 of 23

JacquesGaudin
Advocate
Advocate

Thanks, that 's helpful.

The type cast to IRobotLoadRecord works but the `SetValue` method is missing on the object. It seems to be a similar problem with the `Create` method of `IRobotLoadRecordMngr`.

There's not much we can do to retrieve these methods if they're not exposed in the API, I think Autodesk has to fix it on their side.

 

@okapawal @Rafal.Gaweda 

0 Likes
Message 19 of 23

1234eddie
Advocate
Advocate

@JacquesGaudin 

many thanks for your answer.

topic is also active on the dynamo forum

 

To the autodesk teammembers can you have a look in to this?

@okapawal @Rafal.Gaweda @Krzysztof_Wasik @Artur.Kosakowski @Pawel.Pulak 

 

Many thanks in advance

0 Likes
Message 20 of 23

1234eddie
Advocate
Advocate

Hi all,

 

@JacquesGaudin 

For your info, This topic is still going on the DYnamo forum.

 

If there is more i will let you know

 

Gr Edward