[EC8 & Python code]

[EC8 & Python code]

xroguiez
Enthusiast Enthusiast
2,595 Views
25 Replies
Message 1 of 26

[EC8 & Python code]

xroguiez
Enthusiast
Enthusiast

Hello
I am trying to transform VBA code into Python from the example provided here: https://forums.autodesk.com/t5/robot-structural-analysis-forum/api-seismic-case-definition/m-p/33578...
But I can't access the GetAnalysisParams() methods :

 

caseEdX = structure.Cases.CreateSimple(6, "Ed+X",
RobotOM.IRobotCaseNature.I_CN_SEISMIC ,
RobotOM.IRobotCaseAnalizeType.I_CAT_DYNAMIC_SEISMIC)

num_EdX1 = caseEdX.GetSeismicCode #is empty
#doesn't work num_EdX1 = caseEdX.Records.New(RobotOM.IRobotSeismicAnalysis_EC8_General_Params) #a validate
EC8params = caseEdX.GetAnalysisParams #is empty too

Can someone help me?
Thanks for any help

Xavier

0 Likes
2,596 Views
25 Replies
Replies (25)
Message 2 of 26

Stephane.kapetanovic
Mentor
Mentor

Hi @xroguiez 

You must declare your variable types

Best regards 

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
0 Likes
Message 3 of 26

xroguiez
Enthusiast
Enthusiast

Hello

I agree with you but how to do it (in Python) ? I couldn't do it

Thanks

Xavier

0 Likes
Message 4 of 26

Stephane.kapetanovic
Mentor
Mentor

> To declare a variable

Variable = Type_of_Variable (Class / Interface)

Example:

thData = IRobotThicknessData

 

> To Cast

Variable_0 = Type_of_Variable(Variable_1)

 

b = 125.3
print(int(b))
Output
125

Example:

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

 

therefore, you must declare the types of variables when necessary and check the output types of the functions according to the variables types to perform the casts

 

Best Regards

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
Message 5 of 26

Stephane.kapetanovic
Mentor
Mentor

See also

https://forums.autodesk.com/t5/robot-structural-analysis-forum/generate-ec8-general-seismic-case-thr...

Stéphane Kapetanovic

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

xroguiez
Enthusiast
Enthusiast

Hi

Thank you for all your advice.

 

I took the example in the link on the first 4 lines

VBA Source :

 

Dim ECParams As RobotSeismicAnalysis_EC8_General_Params

Set EQLoad = Robapp.Project.Structure.Cases.CreateSimple(200, "EarthQuake+X", I_CN_SEISMIC, I_CAT_DYNAMIC_SEISMIC)
Set ECParams = EQLoad.GetAnalysisParams
ECParams.Ag = Foglio2.Range("F9")

 

 

And then a partial version of Python transcription that works perfectly:

 

ECParams = RobotOM.RobotSeismicAnalysis_EC8_General_Params
ModalParams = RobotOM.RobotModalAnalysisParams
#I'm using different namespaces, but it's the same syntax
EQLoad = structure.Cases.CreateSimple(6, "Ed+X", 
                                    RobotOM.IRobotCaseNature.I_CN_SEISMIC ,
                                    RobotOM.IRobotCaseAnalizeType.I_CAT_DYNAMIC_SEISMIC)

 

 The console proof, :

 

>>> dir(ECParams)
['Ag', 'B', 'BehaviorFactor', 'Direction', 'DirectionType', 'ExcitationDir', 'Filter', 'ResidualMode', 'S', 'Spectrum', 'Tb', 'Tc', 'Td', '__doc__', '__repr__']
dir(EQLoad)
['AnalizeType', 'CreateObjRef', 'Equals', 'GetAnalysisParams', 'GetHashCode', 'GetLifetimeService', 'GetSeismicCode', 'GetType', 'InitializeLifetimeService', 'IsAuxiliary', 'MainMode', 'MemberwiseClone', 'ModesCount', 'Name', 'Nature', 'NatureName', 'Number', 'Records', 'ReferenceEquals', 'SetAnalysisParams', 'SetNatureExt', 'TimeStepCount', 'ToString', 'Type', 'UniqueId', 'UserId', '__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'label']

 

 But the next point is completely blocking, i don't understand how to cast :, in this attempt, the intial variable is erasing

 

#### here is my main cast problem...
ECParams = EQLoad.GetAnalysisParams
>>> ECParams = EQLoad.GetAnalysisParams
>>> dir(ECParams)
['Equals', 'GetHashCode', 'GetType', 'MemberwiseClone', 'ReferenceEquals', 'ToString', '__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']

 

Another clumsy attempt :

 

>>> EQLoad.SetAnalysisParams(ECParams)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Le cast spécifié n'est pas valide.
>>> EQLoad.SetAnalysisParams(ECParams())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Cannot create instances of RobotSeismicAnalysis_EC8_General_Params because it is abstract
>>> ECParams.Ag = 1.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: static property 'Ag' of 'IRobotSeismicAnalysis_EC8_General_Params' can only be assigned to through a type, not an instance

 

 

To be honest, i don't know in this how to cast it ? Could you help me ?

Thanks for all

Xavier

0 Likes
Message 7 of 26

Stephane.kapetanovic
Mentor
Mentor

How did you define EQLoad ?  EQLoad = RobotSimpleCase ?

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
0 Likes
Message 8 of 26

xroguiez
Enthusiast
Enthusiast

Hi again

 

Anothers attempts of casting :

>>> ECParams = RobotOM.IRobotSeismicAnalysis_EC_8_General_Params(caseEdX.GetAnalysis())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: attribute 'IRobotSeismicAnalysis_EC_8_General_Params' of 'namespace#' object is read-only
>>> ECParams = RobotOM.RobotSeismicAnalysis_EC_8_General_Params(caseEdX.GetAnalysis)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: attribute 'RobotSeismicAnalysis_EC_8_General_Params' of 'namespace#' object is read-only

The thing i don't really understand is the main difference between the two path... for the modal load, it's works :

caseMod = loads.CreateSimple(5, "Modale", 
                                RobotOM.IRobotCaseNature.I_CN_EXPLOATATION ,
                                RobotOM.IRobotCaseAnalizeType.I_CAT_DYNAMIC_MODAL)
num_Mod1 = caseMod.Records.New(RobotOM.IRobotLoadRecordType.I_LRT_SPECTRUM_VALUE) #a valider
#loadRec = caseMod.Records.Get(num_Mod) #pas utile ici on l'applique au projet
modParams = caseMod.GetAnalysisParams()
modParams.Mode = RobotOM.IRobotModalAnalysisMode.I_MAM_MODAL
modParams.ModesCount = 50
modParams.Damping = 5e-2
...
caseMod.SetAnalysisParams(modParams)

These commands worked in Robot for the modal analysis and not for the seismic analysis

 

Xavier

0 Likes
Message 9 of 26

xroguiez
Enthusiast
Enthusiast

Hello

Like this ?

EQLoad = structure.Cases.CreateSimple(6, "Ed+X", 
                                    RobotOM.IRobotCaseNature.I_CN_SEISMIC ,
                         RobotOM.IRobotCaseAnalizeType.I_CAT_DYNAMIC_SEISMIC)

Is it right ?

Xavier

0 Likes
Message 10 of 26

xroguiez
Enthusiast
Enthusiast

Hi

I've used the following shortcuts

robApp.Project.New(RobotOM.IRobotProjectType.I_PT_SHELL)

project = robApp.Project
## IRobotStructure

structure = project.Structure  #IRobotStructure
0 Likes
Message 11 of 26

Stephane.kapetanovic
Mentor
Mentor

Before answer to other post

Code fail ↓

 

 

ECParams = EQLoad.GetAnalysisParams

 

 

3 possible reasons :

- EcParams not defined as IRobotSeismicAnalysis_EC_8_General_Params type

- EqLoad not defined as a RobotSimpleCase type

 

 

EQLoad = RobotSimpleCase
EQLoad = structure.Cases.CreateSimple(6, "Ed+X", 
                         RobotOM.IRobotCaseNature.I_CN_SEISMIC ,
                         RobotOM.IRobotCaseAnalizeType.I_CAT_DYNAMIC_SEISMIC)

 

 

- Try also

ECParams = EQLoad.GetAnalysisParams()

try to set preferences by SetActiveCode function as explain by cris.bac

 

there is also a remarks by Rafal Gaweda in your link

aaa = RCase.GetSeismicCode ' this is check only line, for EC codes there is no name returned here

'RobotSeismicAnalysis_EC_8_Params refers to ENV 1998-1-1:1994 DAN francaise, which is currently unused - if you are interested I can tell you how to enable this unused code

 

Best regards

 

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
0 Likes
Message 12 of 26

xroguiez
Enthusiast
Enthusiast

Hello

Thanks again for your help

 

If I understand correctly for the first point, it works for me ?

 

>>> ECParams = RobotOM.RobotSeismicAnalysis_EC8_General_Params

 

- EcParams not defined as IRobotSeismicAnalysis_EC_8_General_Params type, it seems to be right ?

 

>>> dir(ECParams)
['Ag', 'B', 'BehaviorFactor', 'Direction', 'DirectionType', 'ExcitationDir', 'Filter', 'ResidualMode', 'S', 'Spectrum', 'Tb', 'Tc', 'Td', '__doc__', '__repr__']

 

- EqLoad not defined as a RobotSimpleCase type, same conclusion ?

 

>>> EQLoad = RobotOM.RobotSimpleCase
>>> dir(EQLoad)
['AnalizeType', 'CreateObjRef', 'Equals', 'GetAnalysisParams', 'GetHashCode', 'GetLifetimeService', 'GetSeismicCode', 'GetType', 'InitializeLifetimeService', 'IsAuxiliary', 'MainMode', 'MemberwiseClone', 'ModesCount', 'Name', 'Nature', 'NatureName', 'Number', 'Records', 'ReferenceEquals', 'SetAnalysisParams', 'SetNatureExt', 'TimeStepCount', 'ToString', 'Type', 'UniqueId', 'UserId', '__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'label']
>>> EQLoad = structure.Cases.CreateSimple(inumC, "Ed+X",
... RobotOM.IRobotCaseNature.I_CN_SEISMIC ,
... RobotOM.IRobotCaseAnalizeType.I_CAT_DYNAMIC_SEISMIC)
>>> dir(EQLoad)
['AnalizeType', 'CreateObjRef', 'Equals', 'GetAnalysisParams', 'GetHashCode', 'GetLifetimeService', 'GetSeismicCode', 'GetType', 'InitializeLifetimeService', 'IsAuxiliary', 'MainMode', 'MemberwiseClone', 'ModesCount', 'Name', 'Nature', 'NatureName', 'Number', 'Records', 'ReferenceEquals', 'SetAnalysisParams', 'SetNatureExt', 'TimeStepCount', 'ToString', 'Type', 'UniqueId', 'UserId', '__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'label']

 

-Try Also

Attempt 1 :the structure of ECParams has been deleted

 

>>> ECParams = EQLoad.GetAnalysisParams
>>> dir(ECParams)
['Equals', 'GetHashCode', 'GetType', 'MemberwiseClone', 'ReferenceEquals', 'ToString', '__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']

 

Attempt 2 :the structure of ECParams has also been deleted

 

>>> ECParams = RobotOM.RobotSeismicAnalysis_EC8_General_Params
>>> ECParams = EQLoad.GetAnalysisParams()
>>> dir(ECParams)
['Equals', 'GetHashCode', 'GetType', 'MemberwiseClone', 'ReferenceEquals', 'ToString', '__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']

 

Attempt 3 : the structure of ECParams has also been deleted

 

>>> ECParams = RobotOM.RobotSeismicAnalysis_EC8_General_Params
>>> aaa = EQLoad.GetSeismicCode
>>> ECParams = EQLoad.GetAnalysisParams()
>>> dir(ECParams)
['Equals', 'GetHashCode', 'GetType', 'MemberwiseClone', 'ReferenceEquals', 'ToString', '__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']

 

 

Thanks for all

Xavier

0 Likes
Message 13 of 26

Stephane.kapetanovic
Mentor
Mentor

Is that works ? 

could you write the correct integral sequence ?

Attempt 1, 2, 3 not working ? 

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
0 Likes
Message 14 of 26

xroguiez
Enthusiast
Enthusiast

Hello

Sorry it doesn't works.

But what do you mean with the integral sequence ? I've posted all the code and the console return

Xavier

0 Likes
Message 15 of 26

Stephane.kapetanovic
Mentor
Mentor

yes all code in one thread please to resume because it's hard to follow for @JacquesGaudin, @cool.stuff, @1234eddie, @Rafal.Gaweda, @napooil.

.

Is this conclusion still true? with Python ? 

https://forums.autodesk.com/t5/robot-structural-analysis-forum/api-seismic-case-definition/m-p/33578...

 

 

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
Message 16 of 26

xroguiez
Enthusiast
Enthusiast

Hello

 

Sorry for this stream of unstructured information. I put everything in a single script ECM.txt (extension is not accepted). Is it ok ?

 

I'm running the script in IronPython2.7.12 and with Robot 2023. Do you have a solution to set the seismic parameters ?

 

Thanks for all

Xavier

 

 

 

0 Likes
Message 17 of 26

JacquesGaudin
Advocate
Advocate

With the line below, you can make sure that you are using the right default:

 

Robapp.Project.Preferences.SetActiveCode(I_CT_SEISMIC_LOADS, "EN 1998-1:2004/A1:2013-General")

 

The type of seismic params depends on this setting. If you put this line before defining the seismic load case, you should get the correct type of params.

 

Note: In Python, you need the brackets to call a function. Without brackets, you are referring to the function / method object.

 

Message 18 of 26

Stephane.kapetanovic
Mentor
Mentor

To obtain codes numbers and names

Preferences = RobotOM.RobotProjectPreferences
Preferences = robApp.Project.Preferences
#Preferences.SetActiveCodeNumber(RobotOM.IRobotCodeType.I_CT_SEISMIC_LOADS, 000)
#Preferences.SetActiveCode(RobotOM.IRobotCodeType.I_CT_SEISMIC_LOADS, "XXX")
CodeNumber = Preferences.GetActiveCodeNumber(RobotOM.IRobotCodeType.I_CT_SEISMIC_LOADS)
      Code = Preferences.GetActiveCode(RobotOM.IRobotCodeType.I_CT_SEISMIC_LOADS)

Table (to be continued) to match seismic codes and Params

# Nbr ! Code                                          ! Params
# ----+-----------------------------------------------+-----------------------------
# 136 : "EN 1998-1:2004/A1:2013"                      ! RobotSeismicAnalysis_EC8_Params
# 137 : "EuroCode 8 2003 (General)"                   ! RobotSeismicAnalysis_EC8_General_Params
# 137 : "EN 1998-1:2004/A1:2013-General"              ! RobotSeismicAnalysis_EC8_General_Params
# 148 : "NF EN 1998-1/NA:2007 19.juil.2011"           ! ???
# 162 : "NF EN 1998-1/NA:2013 DÉCEMBRE 2013"          ! ???
# 163 : "NF EN 1998-1/Nice PPR/NA:2007 19 juil. 2011" ! ???
# TBC :                                               ! 

 

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
Message 19 of 26

xroguiez
Enthusiast
Enthusiast

Hi

 

Here are the 2 codes I got

 

>>> preferences = robApp.Project.Preferences
>>> CodeNumber = preferences.GetActiveCodeNumber(RobotOM.IRobotCodeType.I_CT_SEISMIC_LOADS)
>>> Code = preferences.GetActiveCode(RobotOM.IRobotCodeType.I_CT_SEISMIC_LOADS)
>>> print(CodeNumber, Code)
(162, u'NF EN 1998-1/NA:2013 D\xc9CEMBRE 2013')

 

I was not able to access the objects by trying the 2 methods

>>> EC8 = RobotOM.RobotSeismicAnalysis_EC8_General_Params
>>> EC8.BehaviorFactor = 1.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: static property 'BehaviorFactor' of 'IRobotSeismicAnalysis_EC8_General_Params' can only be assigned to through a type, not an instance
>>> EC8 = RobotOM.RobotSeismicAnalysis_EC8_Params
>>> EC8.BehaviorFactor = 1.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: static property 'BehaviorFactor' of 'IRobotSeismicAnalysis_EC8_Params' can only be assigned to through a type, not an instance

Thanks for any help

Xavier

 

0 Likes
Message 20 of 26

Stephane.kapetanovic
Mentor
Mentor

as indicated in the correspondence table, code 162 does not seem to have a functional interface among the three available

 

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
0 Likes