Material parameterization

Post Reply
giulio.zanellato
Posts: 13
Joined: Thu Oct 10, 2024 12:22 pm

Material parameterization

Post by giulio.zanellato » Wed Jan 08, 2025 9:48 am

Hi, I'm creating a stko model of a reinforced concrete frame in which the infill is modeled through 2 pairs of struts. The central part of the struts is made up of a fiber section composed of 120 fibers and therefore 60 different fiber materials. To optimize the fiber material insertion procedure I wanted to write a script that allows me to automatically parameterize the parameters of the fiber materials of the strut by directly taking the values ​​from an excel sheet with the data inside.
The problem is that after running the script it gives me this error: no module named 'openpyxl' as reported in the following screens.
How can I solve it? Is the script correct to be able to parameterize the fiber material?
Attachments
F-02.12.24_PO_IP_InfilledFrame.zip
(106.23 MiB) Downloaded 111 times
Error openpyxl.jpg
Error openpyxl.jpg (78.46 KiB) Viewed 1923 times
Screen.jpg
Screen.jpg (233.71 KiB) Viewed 1923 times

STKO Team
Posts: 3066
Joined: Tue Oct 29, 2019 8:45 am

Re: Material parameterization

Post by STKO Team » Thu Jan 09, 2025 11:38 am

It's because STKO uses its own embedded python interpreter, and openpyxl is not in C:\Program Files\STKO\python_packages

You have 3 options:
  • copy the openpyxl folder from your python lib directory to the python_packages (but you will have to do it everytime you install a new STKO version)
  • Do this before importing

    Code: Select all

    import sys
    sys.path.append('C:/Python310/Lib/site-packages')
    import openpyxl
    (but it's dangerous, because now STKO will see all the libs in your python, and some of them may conflict with those used by STKO).
  • Mix the 2 previous approaches, copy openpyxl out of Lib/site-packages and out of STKO install folder (say for example in C:\MyCustomPackages, now use sys.path.append('C:\MyCustomPackages')

giulio.zanellato
Posts: 13
Joined: Thu Oct 10, 2024 12:22 pm

Re: Material parameterization

Post by giulio.zanellato » Fri Jan 10, 2025 5:09 pm

ok thank you very much I solved it. Now I'm running the script and I get these debugs that I put. How can I fix it so that the materials are created? I tried more functions but unfortunately I'm not solving any of them.

Terminal
Inizio esecuzione script...
Documento STKO caricato.
Percorso file Excel: D:\Giulio\F\02.12.24_PO_IP_InfilledFrame\LibreriaSezione_fibreTamponamenti.xlsx
File Excel trovato.
Caricamento del file Excel...
Caricamento del file Excel completato.
Sto leggendo il foglio: F (Minotto 2020)
Leggendo riga 6...
Creando materiale Hysteretic con ID 101...
Errore nella creazione del materiale ID 101: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 7...
Creando materiale Hysteretic con ID 102...
Errore nella creazione del materiale ID 102: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 8...
Creando materiale Hysteretic con ID 103...
Errore nella creazione del materiale ID 103: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 9...
Creando materiale Hysteretic con ID 104...
Errore nella creazione del materiale ID 104: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 10...
Creando materiale Hysteretic con ID 105...
Errore nella creazione del materiale ID 105: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 11...
Creando materiale Hysteretic con ID 106...
Errore nella creazione del materiale ID 106: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 12...
Creando materiale Hysteretic con ID 107...
Errore nella creazione del materiale ID 107: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 13...
Creando materiale Hysteretic con ID 108...
Errore nella creazione del materiale ID 108: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 14...
Creando materiale Hysteretic con ID 109...
Errore nella creazione del materiale ID 109: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 15...
Creando materiale Hysteretic con ID 110...
Errore nella creazione del materiale ID 110: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 16...
Creando materiale Hysteretic con ID 111...
Errore nella creazione del materiale ID 111: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 17...
Creando materiale Hysteretic con ID 112...
Errore nella creazione del materiale ID 112: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 18...
Creando materiale Hysteretic con ID 113...
Errore nella creazione del materiale ID 113: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 19...
Creando materiale Hysteretic con ID 114...
Errore nella creazione del materiale ID 114: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 20...
Creando materiale Hysteretic con ID 115...
Errore nella creazione del materiale ID 115: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 21...
Creando materiale Hysteretic con ID 116...
Errore nella creazione del materiale ID 116: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 22...
Creando materiale Hysteretic con ID 117...
Errore nella creazione del materiale ID 117: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 23...
Creando materiale Hysteretic con ID 118...
Errore nella creazione del materiale ID 118: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 24...
Creando materiale Hysteretic con ID 119...
Errore nella creazione del materiale ID 119: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 25...
Creando materiale Hysteretic con ID 120...
Errore nella creazione del materiale ID 120: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 26...
Creando materiale Hysteretic con ID 121...
Errore nella creazione del materiale ID 121: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 27...
Creando materiale Hysteretic con ID 122...
Errore nella creazione del materiale ID 122: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 28...
Creando materiale Hysteretic con ID 123...
Errore nella creazione del materiale ID 123: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 29...
Creando materiale Hysteretic con ID 124...
Errore nella creazione del materiale ID 124: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 30...
Creando materiale Hysteretic con ID 125...
Errore nella creazione del materiale ID 125: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 31...
Creando materiale Hysteretic con ID 126...
Errore nella creazione del materiale ID 126: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 32...
Creando materiale Hysteretic con ID 127...
Errore nella creazione del materiale ID 127: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 33...
Creando materiale Hysteretic con ID 128...
Errore nella creazione del materiale ID 128: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 34...
Creando materiale Hysteretic con ID 129...
Errore nella creazione del materiale ID 129: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 35...
Creando materiale Hysteretic con ID 130...
Errore nella creazione del materiale ID 130: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 36...
Creando materiale Hysteretic con ID 131...
Errore nella creazione del materiale ID 131: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 37...
Creando materiale Hysteretic con ID 132...
Errore nella creazione del materiale ID 132: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 38...
Creando materiale Hysteretic con ID 133...
Errore nella creazione del materiale ID 133: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 39...
Creando materiale Hysteretic con ID 134...
Errore nella creazione del materiale ID 134: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 40...
Creando materiale Hysteretic con ID 135...
Errore nella creazione del materiale ID 135: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 41...
Creando materiale Hysteretic con ID 136...
Errore nella creazione del materiale ID 136: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 42...
Creando materiale Hysteretic con ID 137...
Errore nella creazione del materiale ID 137: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 43...
Creando materiale Hysteretic con ID 138...
Errore nella creazione del materiale ID 138: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 44...
Creando materiale Hysteretic con ID 139...
Errore nella creazione del materiale ID 139: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 45...
Creando materiale Hysteretic con ID 140...
Errore nella creazione del materiale ID 140: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 46...
Creando materiale Hysteretic con ID 141...
Errore nella creazione del materiale ID 141: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 47...
Creando materiale Hysteretic con ID 142...
Errore nella creazione del materiale ID 142: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 48...
Creando materiale Hysteretic con ID 143...
Errore nella creazione del materiale ID 143: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 49...
Creando materiale Hysteretic con ID 144...
Errore nella creazione del materiale ID 144: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 50...
Creando materiale Hysteretic con ID 145...
Errore nella creazione del materiale ID 145: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 51...
Creando materiale Hysteretic con ID 146...
Errore nella creazione del materiale ID 146: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 52...
Creando materiale Hysteretic con ID 147...
Errore nella creazione del materiale ID 147: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 53...
Creando materiale Hysteretic con ID 148...
Errore nella creazione del materiale ID 148: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 54...
Creando materiale Hysteretic con ID 149...
Errore nella creazione del materiale ID 149: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 55...
Creando materiale Hysteretic con ID 150...
Errore nella creazione del materiale ID 150: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 56...
Creando materiale Hysteretic con ID 151...
Errore nella creazione del materiale ID 151: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 57...
Creando materiale Hysteretic con ID 152...
Errore nella creazione del materiale ID 152: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 58...
Creando materiale Hysteretic con ID 153...
Errore nella creazione del materiale ID 153: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 59...
Creando materiale Hysteretic con ID 154...
Errore nella creazione del materiale ID 154: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 60...
Creando materiale Hysteretic con ID 155...
Errore nella creazione del materiale ID 155: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 61...
Creando materiale Hysteretic con ID 156...
Errore nella creazione del materiale ID 156: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 62...
Creando materiale Hysteretic con ID 157...
Errore nella creazione del materiale ID 157: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 63...
Creando materiale Hysteretic con ID 158...
Errore nella creazione del materiale ID 158: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 64...
Creando materiale Hysteretic con ID 159...
Errore nella creazione del materiale ID 159: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 65...
Creando materiale Hysteretic con ID 160...
Errore nella creazione del materiale ID 160: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 66...
Creando materiale Hysteretic con ID 161...
Errore nella creazione del materiale ID 161: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 67...
Creando materiale Hysteretic con ID 162...
Errore nella creazione del materiale ID 162: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 68...
Creando materiale Hysteretic con ID 163...
Errore nella creazione del materiale ID 163: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 69...
Creando materiale Hysteretic con ID 164...
Errore nella creazione del materiale ID 164: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 70...
Creando materiale Hysteretic con ID 165...
Errore nella creazione del materiale ID 165: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 71...
Creando materiale Hysteretic con ID 166...
Errore nella creazione del materiale ID 166: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 72...
Creando materiale Hysteretic con ID 167...
Errore nella creazione del materiale ID 167: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 73...
Creando materiale Hysteretic con ID 168...
Errore nella creazione del materiale ID 168: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 74...
Creando materiale Hysteretic con ID 169...
Errore nella creazione del materiale ID 169: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 75...
Creando materiale Hysteretic con ID 170...
Errore nella creazione del materiale ID 170: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 76...
Creando materiale Hysteretic con ID 171...
Errore nella creazione del materiale ID 171: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 77...
Creando materiale Hysteretic con ID 172...
Errore nella creazione del materiale ID 172: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 78...
Creando materiale Hysteretic con ID 173...
Errore nella creazione del materiale ID 173: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 79...
Creando materiale Hysteretic con ID 174...
Errore nella creazione del materiale ID 174: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 80...
Creando materiale Hysteretic con ID 175...
Errore nella creazione del materiale ID 175: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 81...
Creando materiale Hysteretic con ID 176...
Errore nella creazione del materiale ID 176: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 82...
Creando materiale Hysteretic con ID 177...
Errore nella creazione del materiale ID 177: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 83...
Creando materiale Hysteretic con ID 178...
Errore nella creazione del materiale ID 178: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 84...
Creando materiale Hysteretic con ID 179...
Errore nella creazione del materiale ID 179: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 85...
Creando materiale Hysteretic con ID 180...
Errore nella creazione del materiale ID 180: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 86...
Creando materiale Hysteretic con ID 181...
Errore nella creazione del materiale ID 181: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 87...
Creando materiale Hysteretic con ID 182...
Errore nella creazione del materiale ID 182: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 88...
Creando materiale Hysteretic con ID 183...
Errore nella creazione del materiale ID 183: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 89...
Creando materiale Hysteretic con ID 184...
Errore nella creazione del materiale ID 184: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 90...
Creando materiale Hysteretic con ID 185...
Errore nella creazione del materiale ID 185: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 91...
Creando materiale Hysteretic con ID 186...
Errore nella creazione del materiale ID 186: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 92...
Creando materiale Hysteretic con ID 187...
Errore nella creazione del materiale ID 187: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 93...
Creando materiale Hysteretic con ID 188...
Errore nella creazione del materiale ID 188: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 94...
Creando materiale Hysteretic con ID 189...
Errore nella creazione del materiale ID 189: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 95...
Creando materiale Hysteretic con ID 190...
Errore nella creazione del materiale ID 190: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 96...
Creando materiale Hysteretic con ID 191...
Errore nella creazione del materiale ID 191: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 97...
Creando materiale Hysteretic con ID 192...
Errore nella creazione del materiale ID 192: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 98...
Creando materiale Hysteretic con ID 193...
Errore nella creazione del materiale ID 193: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 99...
Creando materiale Hysteretic con ID 194...
Errore nella creazione del materiale ID 194: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 100...
Creando materiale Hysteretic con ID 195...
Errore nella creazione del materiale ID 195: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 101...
Creando materiale Hysteretic con ID 196...
Errore nella creazione del materiale ID 196: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 102...
Creando materiale Hysteretic con ID 197...
Errore nella creazione del materiale ID 197: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 103...
Creando materiale Hysteretic con ID 198...
Errore nella creazione del materiale ID 198: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 104...
Creando materiale Hysteretic con ID 199...
Errore nella creazione del materiale ID 199: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 105...
Creando materiale Hysteretic con ID 200...
Errore nella creazione del materiale ID 200: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 106...
Creando materiale Hysteretic con ID 201...
Errore nella creazione del materiale ID 201: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 107...
Creando materiale Hysteretic con ID 202...
Errore nella creazione del materiale ID 202: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 108...
Creando materiale Hysteretic con ID 203...
Errore nella creazione del materiale ID 203: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 109...
Creando materiale Hysteretic con ID 204...
Errore nella creazione del materiale ID 204: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 110...
Creando materiale Hysteretic con ID 205...
Errore nella creazione del materiale ID 205: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 111...
Creando materiale Hysteretic con ID 206...
Errore nella creazione del materiale ID 206: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 112...
Creando materiale Hysteretic con ID 207...
Errore nella creazione del materiale ID 207: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 113...
Creando materiale Hysteretic con ID 208...
Errore nella creazione del materiale ID 208: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 114...
Creando materiale Hysteretic con ID 209...
Errore nella creazione del materiale ID 209: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 115...
Creando materiale Hysteretic con ID 210...
Errore nella creazione del materiale ID 210: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 116...
Creando materiale Hysteretic con ID 211...
Errore nella creazione del materiale ID 211: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 117...
Creando materiale Hysteretic con ID 212...
Errore nella creazione del materiale ID 212: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 118...
Creando materiale Hysteretic con ID 213...
Errore nella creazione del materiale ID 213: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 119...
Creando materiale Hysteretic con ID 214...
Errore nella creazione del materiale ID 214: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 120...
Creando materiale Hysteretic con ID 215...
Errore nella creazione del materiale ID 215: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 121...
Creando materiale Hysteretic con ID 216...
Errore nella creazione del materiale ID 216: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 122...
Creando materiale Hysteretic con ID 217...
Errore nella creazione del materiale ID 217: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 123...
Creando materiale Hysteretic con ID 218...
Errore nella creazione del materiale ID 218: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 124...
Creando materiale Hysteretic con ID 219...
Errore nella creazione del materiale ID 219: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Leggendo riga 125...
Creando materiale Hysteretic con ID 220...
Errore nella creazione del materiale ID 220: 'MpcCaeDocument' object has no attribute 'createPhysicalProperty'
Script completato.

I attach the script below
Last edited by giulio.zanellato on Sat Jan 11, 2025 11:04 am, edited 1 time in total.

giulio.zanellato
Posts: 13
Joined: Thu Oct 10, 2024 12:22 pm

Re: Material parameterization

Post by giulio.zanellato » Fri Jan 10, 2025 5:19 pm

SCript -API-6

from PyMpc import *
import os
from openpyxl import load_workbook

App.clearTerminal()
doc = App.caeDocument()

def run():
print("Inizio esecuzione script...")

# Verifica se il documento STKO è caricato
if doc is None:
print("Errore: Nessun documento attivo in STKO.")
return
print("Documento STKO caricato.")

# Percorso del file Excel
excel_file_path = os.path.join(os.getcwd(), "LibreriaSezione_fibreTamponamenti.xlsx")
print(f"Percorso file Excel: {excel_file_path}")

# Controllo del file Excel
if not os.path.exists(excel_file_path):
print(f"Errore: Il file {excel_file_path} non esiste.")
return
print("File Excel trovato.")

# Caricamento del file Excel
print("Caricamento del file Excel...")
workbook = load_workbook(filename=excel_file_path, data_only=True)
print("Caricamento del file Excel completato.")

# Selezione del foglio
sheet_name = "F (Minotto 2020)"
if sheet_name not in workbook.sheetnames:
print(f"Errore: Il foglio {sheet_name} non esiste nel file Excel.")
return
worksheet = workbook[sheet_name]
print(f"Sto leggendo il foglio: {sheet_name}")

# Definizione delle colonne per i dati
start_row = 6
end_row = 125
col_z = "G"
col_a = "H"
cols_params = ["K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U"]

# Loop sulle righe dell'Excel per creare e configurare nuovi materiali
for row in range(start_row, end_row + 1):
print(f"Leggendo riga {row}...")
zi = worksheet[f"{col_z}{row}"].value
Ai = worksheet[f"{col_a}{row}"].value
params = [worksheet[f"{col}{row}"].value for col in cols_params]

if None in [zi, Ai] + params:
print(f"Riga {row}: Dati incompleti, salto questa riga.")
continue

# Estrazione dei parametri del materiale
s1, e1, s2, e2, s3, e3, pinchX, pinchY, damage1, damage2, beta = params
material_id = 101 + (row - start_row)

try:
print(f"Creando materiale Hysteretic con ID {material_id}...")

# Creazione di un nuovo materiale Hysteretic
material = doc.createPhysicalProperty("uniaxialMaterial", "Hysteretic")
material.XObject.getAttribute('tag').integer = material_id
material.XObject.getAttribute('s1').real = s1
material.XObject.getAttribute('e1').real = e1
material.XObject.getAttribute('s2').real = s2
material.XObject.getAttribute('e2').real = e2
material.XObject.getAttribute('s3').real = s3
material.XObject.getAttribute('e3').real = e3
material.XObject.getAttribute('pinchX').real = pinchX
material.XObject.getAttribute('pinchY').real = pinchY
material.XObject.getAttribute('damage1').real = damage1
material.XObject.getAttribute('damage2').real = damage2
material.XObject.getAttribute('beta').real = beta

# Salva il materiale nel documento STKO
doc.addPhysicalProperty(material)
print(f"Materiale creato e salvato: ID={material_id}")

except Exception as e:
print(f"Errore nella creazione del materiale ID {material_id}: {e}")

print("Script completato.")

# Main execution
if __name__ == "__main__":
run()

STKO Team
Posts: 3066
Joined: Tue Oct 29, 2019 8:45 am

Re: Material parameterization

Post by STKO Team » Thu Jan 30, 2025 3:21 pm

The function createPhysicalProperty does not exist.
This is how you can create physical properties

Code: Select all

doc = App.caeDocument()

# create the XOBjectMetaData (i.e. the type of XObject)
meta = doc.metaDataPhysicalProperty('materials.uniaxial.Elastic')

# now you can create many instances of this type
for young_modulus in (1000.0, 2000.0, 3000.0):
	# create the instance
	xobj = MpcXObject.createInstanceOf(meta)
	# edit its attributes
	xobj.getAttribute('E').quantityScalar.value = young_modulus
	# create a new property
	prop = MpcProperty()
	prop.id = doc.physicalProperties.getlastkey(0)+1
	prop.name = 'Elastic Material ({})'.format(young_modulus)
	# set the XObject in the property
	prop.XObject = xobj
	prop.commitXObjectChanges()
	# add it to the document
	doc.addPhysicalProperty(prop)
# done
doc.commitChanges()
doc.dirty = True
Here you can find the API reference:
https://asdeasoft.github.io/STKO-Python ... index.html

Post Reply