API Robot Python - Panel

API Robot Python - Panel

polylouis
Enthusiast Enthusiast
2,723 Views
10 Replies
Message 1 of 11

API Robot Python - Panel

polylouis
Enthusiast
Enthusiast

Hello everyone,

 

I tried to do add new label for thicknness panel :

 

label = labels.Create(IRobotLabelType.I_LT_PANEL_THICKNESS,"25mm")
thData=IRobotThicknessData
thData = label.Data
thData.MaterialName = "S235"
thData.ThicknessType = IRobotThicknessType.I_TT_HOMOGENEOUS
homo = IRobotThicknessHomoData
homo = thData.Data
homo.Thickconst = "0,025"
labels.Store(label)

same think on my python script but I have the following error : 

 

I have the following error : 

thData = label.Data
AttributeError: '__ComObject' object has no attribute 'Data'

 

Do you have a solution to fix this problem ?

 

Thank you in advance,

Louis

0 Likes
Accepted solutions (2)
2,724 Views
10 Replies
Replies (10)
Message 2 of 11

Stephane.kapetanovic
Mentor
Mentor

hi @polylouis 

how did you define the type label, provide previous lines.

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 3 of 11

polylouis
Enthusiast
Enthusiast

Hi,

 

Here is the definition : 

 
import clr
ref = clr.AddReference(
    "C:\Program Files\Autodesk\Autodesk Robot Structural Analysis Professional 2021\System\Exe\Interop.RobotOM.dll")
from RobotOM import *
from System import *
from System import Environment
 
app = RobotApplicationClass()
project = app.Project
project.New(IRobotProjectType.I_PT_SHELL)
labels = structure.Labels
 
Regards,
Louis
0 Likes
Message 4 of 11

Stephane.kapetanovic
Mentor
Mentor
Accepted solution

hi @polylouis 

 

As explained, your problem is probably due to not converting the label variable to a RobotLabel type, reason why you cannot access to datas.

label = RobotLabel(labels.Create(IRobotLabelType.I_LT_PANEL_THICKNESS,"25mm"))

Don't do implicit casting with robot API in python try setting explicitly your variable.

Read this thread :

https://forums.autodesk.com/t5/robot-structural-analysis-forum/python-api/m-p/8804010

 

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
Message 5 of 11

polylouis
Enthusiast
Enthusiast

Hi Stephane,

 

Thnak you for your reply !

 

I have another error: 

 
label = IRobotLabel(labels.Create(IRobotLabelType.I_LT_PANEL_THICKNESS,"E120"))
thData=IRobotThicknessData
thData = label.Data
thData.MaterialName = "C30/37"
thData.ThicknessType = IRobotThicknessType.I_TT_HOMOGENEOUS
homo = IRobotThicknessHomoData
homo = thData.Data
homo.Thickconst = "120"
labels.Store(label)
 
File "testrobot.py", line 82, in <module>
homo = thData.Data
AttributeError: '__ComObject' object has no attribute 'Data'
 
Thank a lot for your support,
Louis
0 Likes
Message 6 of 11

Stephane.kapetanovic
Mentor
Mentor
Accepted solution

hi @polylouis 

same issue, label.data and thData.Data returns dynamics vars so cast is necessary. 

thData = IRobotThicknessData(label.Data)
[...]
homo = IRobotThicknessHomoData(thData.Data)

To understand, try to find topics on boxing/unboxing ___.data returns on multiple types and all are specific that is equal to using same object but recept it in different container declining himself into parts also.

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
Message 7 of 11

polylouis
Enthusiast
Enthusiast

Thanks a lot for your help. It works ! 

 

I would like talk about other subject. On my panel I have a to add several node forces (for example 4) 

 

I did like following example : 

case_number = cases.FreeNumber
dl= cases.CreateSimple(case_number, "n1", IRobotCaseNature.I_CN_EXPLOATATION, IRobotCaseAnalizeType.I_CAT_STATIC_LINEAR)
dl_record = dl.Records.Create(IRobotLoadRecordType.I_LRT_NODE_FORCE)
dl_record = IRobotLoadRecord(dl_record)
dl_record.Objects.AddOne(node1)  # select nodes
dl_record.SetValue(IRobotNodeForceRecordValues.I_NFRV_FZ,XXX)
dl_record.SetValue(IRobotNodeForceRecordValues.I_NFRV_FX,XXX)
 
 
The only solution I find is to do that for each nodes (ie x4) and combine in a "load combinaison" after 
 
Do you have any ideas to be more efficient about that ?
 
Thank you in advance,
Louis 
0 Likes
Message 8 of 11

Stephane.kapetanovic
Mentor
Mentor

hi @polylouis 

first close the topic and accept one or several solutions as accepted.

Second create a new thread with new questions in this category.

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 9 of 11

polylouis
Enthusiast
Enthusiast

Hello everyone !

 

Alike the creation of label for thickness label I would like to do the same for Reinforcement data.

I have a problem about "Minimum Reinforcement" label :

label_slab = IRobotLabel(labels.Create(IRobotLabelType.I_LT_PANEL_REINFORCEMENT, "REINF_massif2"))
rnfData=IRConcrReinforceData(label_slab.Data)
rnfData.Cover_Bot=XXXX
rnfData.Cover_Up=YYYY
rnfData.SetMainDirection(IRConcrReinforceDirection.I_CRD_ALONG_X,1,1,1)
rnfData.MinimumReinf=IRConcrMinimumReinforcementType.I_CMRT_NONE
All is good (no error given) but the last line is not taken into account..
 
Do you have any ideas to fix this problem ?
 
Thank you in advance,
Louis 
0 Likes
Message 10 of 11

Stephane.kapetanovic
Mentor
Mentor

hi @polylouis 

IRConcrReinforceData interface has no property IRConcrReinforceData

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 11 of 11

Stephane.kapetanovic
Mentor
Mentor

IRConcrReinforceData interface has no property MinimumReinf. Sorry 

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