Converting a Abaqus python Macro to Simple python script

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Converting a Abaqus python Macro to Simple python script

mamun1834
Hi there,
 

 I have  the following abaqus macro which I am using to extract the pressure value for the node.
 With this macro, I have to open every time abaqus cae and run the script but this method is inefficient.
 Can I convert it to  some python script and run from say Linux console. It would significantly reduce my work stress.
 

 Here is the script, if somebody can help me with this:
 

 # -*- coding: mbcs -*-
 # Do not delete the following import lines
 from abaqus import *
 from abaqusConstants import *
 import __main__
 

 def pressure():
     import section
     import regionToolset
     import displayGroupMdbToolset as dgm
     import part
     import material
     import assembly
     import step
     import interaction
     import load
     import mesh
     import optimization
     import job
     import sketch
     import visualization
     import xyPlot
     import displayGroupOdbToolset as dgo
     import connectorBehavior
     session.mdbData.summary()
     o1 = session.openOdb(
         name='blablabla_location/sphereincube2_main.odb')
     session.viewports['Viewport: 1'].setValues(displayedObject=o1)
     odb = session.odbs['blablabla_location/sphereincube2_main.odb']
     session.fieldReportOptions.setValues(printTotal=OFF, printMinMax=OFF)
     session.writeFieldReport(fileName='pressure.rpt', append=OFF,
         sortItem='Node Label', odb=odb, step=0, frame=15, outputPosition=NODAL,
         variable=(('S', INTEGRATION_POINT, ((INVARIANT, 'Pressure'), )), ))
 

 Any suggestion would be appreciated.
 

 BR,
 Mamun
 

 

Reply | Threaded
Open this post in threaded view
|

Re: Converting a Abaqus python Macro to Simple python script

Guo, Yongjin (Y)
Mamun,

Copy your marco script as a python file. Use the following import statement (remove the sentence "import __main__"):
from abaqus import *
from abaqusConstants import *
from viewerModules import *

also write the following sentences at the end of your file:

if __name__ == "__main__":
    pressure()

Save and run the script using console:
Abaqus cae nogui=pythonFileName

You may need other statements to give the ODB file name and/or change other things.
Note: most of the import statements in the function pressure are not necessary when "from viewerModules import *" is used

Best regards,
Yongjin

------------------------------------------------------
Yongjin Guo
Materials Engineering Center
Corporate R&D, Dow Chemical

Reply | Threaded
Open this post in threaded view
|

Re: Converting a Abaqus python Macro to Simple python script

mitenp
In reply to this post by mamun1834
Hi,


If you mean run the script from the command line without opening the GUI then the syntax is as follows


        abaqus cae -noGUI <script-file>

        eg  abaqus cae -noGUI  /rds/fluid-mesh-gen/HEX-mesh/HEX-meshGen-full.py


note in the script you can invoke subscripts using the execfile command


       execfile('/rds/fluid-mesh-gen/HEX-mesh/HEX-mesh-1-genWires-compress.py')


Hope that helps. For more info see


Abaqus Scripting User's Guide  2.2 : How does the Abaqus Scripting Interface interact with Abaqus/CAE?

Miten


________________________________
From: [hidden email] <[hidden email]> on behalf of [hidden email] [Abaqus] <[hidden email]>
Sent: 26 February 2019 22:12:22
To: [hidden email]
Subject: [Abaqus] Converting a Abaqus python Macro to Simple python script



Hi there,


I have  the following abaqus macro which I am using to extract the pressure value for the node.

With this macro, I have to open every time abaqus cae and run the script but this method is inefficient.

Can I convert it to  some python script and run from say Linux console. It would significantly reduce my work stress.


Here is the script, if somebody can help me with this:


# -*- coding: mbcs -*-

# Do not delete the following import lines

from abaqus import *

from abaqusConstants import *

import __main__


def pressure():

    import section

    import regionToolset

    import displayGroupMdbToolset as dgm

    import part

    import material

    import assembly

    import step

    import interaction

    import load

    import mesh

    import optimization

    import job

    import sketch

    import visualization

    import xyPlot

    import displayGroupOdbToolset as dgo

    import connectorBehavior

    session.mdbData.summary()

    o1 = session.openOdb(

        name='blablabla_location/sphereincube2_main.odb')

    session.viewports['Viewport: 1'].setValues(displayedObject=o1)

    odb = session.odbs['blablabla_location/sphereincube2_main.odb']

    session.fieldReportOptions.setValues(printTotal=OFF, printMinMax=OFF)

    session.writeFieldReport(fileName='pressure.rpt', append=OFF,

        sortItem='Node Label', odb=odb, step=0, frame=15, outputPosition=NODAL,

        variable=(('S', INTEGRATION_POINT, ((INVARIANT, 'Pressure'), )), ))


Any suggestion would be appreciated.


BR,

Mamun