For example, import customKernel mdb = Mdb() mdb.customData.myString = 'The width is ' mdb.customData.myNumber = 58 mdb.saveAs('custom-test.cae') mdb.close() If you start a new session and open the model database, custom-test.cae, you can refer to the variables that you saved. For example, >>> import customKernel mdb = openMdb('custom-test.cae') >>> print mdb.customData.myString, mdb.customData.myNumber The width is 58 You can store almost any type of Python object under mdb.customData; for example, strings, numbers, and Python classes. However, there are some restrictions; for example, you cannot store file objects. These restrictions are due to the fact that the Abaqus/CAE infrastructure uses Python’s pickle module to store the customData object in the model database. The pickle module allows the Python programmer to write a data structure to a file and then recreate that data structure when reading from the file. For details on the restrictions imposed by the pickle module, see the official Python website (http://www.python.org). If your code creates a custom class and stores an instance of the class in the model database, the custom module that defined that custom class must be available for Python to unpickle the data when the database is subsequently opened. Consequently, if a user saves custom data to a model database and then passes that model database to another user, the other user must also have access to the custom modules that produced the custom data. Otherwise, they will not be able to load the custom data into their Abaqus/CAE session. Abaqus/CAE does not keep track of changes made to the customData object. As a result, when the user quits a session, Abaqus/CAE will not prompt them to save their changes if they changed only objects under customData. |