2022.4+26187-e1209cf7 Apr 14, 2022

11.2 Importing Cubit into Python

Python users are able to import Cubit into Python and make calls into Cubit via CubitInterface and the other Python classes described in this section. Below is a simple Python script. The key parts are ensuring the Cubit libraries are on the path and ensuring the cubit.init() call is made first.

import sys

 

# add Cubit libraries to your path

sys.path.append(’/opt/cubit/bin’)

 

import cubit

 

#start cubit - this step is key

#cubit.init does not require any arguments.

#If you do want to provide arguments, you must

#provide 2 or more, where the first must

#be "cubit", and user args start as the 2nd argument.

#If only one argument is used, it will be ignored.

cubit.init([’cubit’,’-nojournal’])

 

height = 1.2

blockHexRadius = 0.1732628

 

#hexagon

baseBlock = cubit.prism(height, 6, blockHexRadius, blockHexRadius)

 

#etc . . .