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. Note that cubit.init() does not require any arguments. But 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.

import sys # Add Cubit libraries to your path sys.path.append(’/opt/cubit/bin’) import cubit # Start cubit - this step is key cubit.init([’cubit’,’-nojournal’]) # Use Cubit height = 1.2 blockHexRadius = 0.1732628 baseBlock = cubit.prism(height, 6, blockHexRadius, blockHexRadius) #etc . . .