Surface manipulation by name on command line

Is there a way to name the last surface created? Right now I have to know the number for the surface I just created on the command line:

surface 28 name "jjj"

Also, is there a way to move the surface by name?

move surface "jjj" x 1
ERROR: Syntax error.
No entities specified.
Type 'help move' for correct syntax.

There are a few ways to get the id of the last surface (or other geometric entity) created. The first is using the APREPRO functionality in Cubit - and use the Id() function:

The other is similar, but using the Python API and the get_last_id() method:
https://coreform.com/cubit_help/cubithelp.htm#t=appendix%2Fpython%2Fnamespace_cubit_interface.htm

  • Example:
    surf_id = cubit.get_last_id("surface")
    cubit.cmd("remove surface {}".format(surf_id))
    
1 Like

Thanks, it looks like it works.

>>> import cubit
>>> cubit.init("cubit")
usb support disabled
[2021-03-30 09:52:26.529] [info] RLM session initialized
QObject::startTimer: Timers can only be used with threads started with QThread
QObject::startTimer: Timers can only be used with threads started with QThread
QObject::startTimer: Timers can only be used with threads started with QThread
QObject::startTimer: Timers can only be used with threads started with QThread
WARNING: Could not open file: t
WARNING: Could not open file: i
WARNING: Could not open file: b
WARNING: Could not open file: u


                   CCCCC    UU   UU   BBBBBB    IIII   TTTTTT
                  CC   CC   UU   UU   BB   BB    II      TT
                  CC        UU   UU   BB   BB    II      TT
                  CC        UU   UU   BBBBBB     II      TT
                  CC        UU   UU   BB   BB    II      TT
                  CC   CC   UU   UU   BB   BB    II      TT
                   CCCCC     UUUUU    BBBBBB    IIII     TT  tm

                            MESH GENERATION TOOLKIT        
                                      FOR                   
                   PRE-PROCESSING OF FINITE ELEMENT ANALYSES

                 User community mailing list: cubit@sandia.gov   
         Report bugs and enhancement requests to cubit-help@sandia.gov


                         Cubit Version 2020.2 64-Bit Build e72463d7cb
                               VTK Version 8.2.0
                              ACIS Version 28.0.2.0
                            Exodus API Version 8.03
                            MeshGems Version 2.11-1
                     Copyright 2001-2008 Sandia Corporation
              Revised Tue Nov 10 11:45:34 2020 -0700
                        Running 03/30/2021 09:52:24 AM

                 CUBIT includes MeshGems by Distene S.A.S.
                  CUBIT includes ACIS software by Spatial Inc.
                  CUBIT includes LP Solve by Michel Berkelaar.
                       CUBIT includes VTK by Kitware Inc.
           CUBIT includes Exodus II, based on netCDF by UCAR/Unidata.
            CUBIT includes VERDICT, by Sandia National Laboratories.
          CUBIT includes MESQUITE, by Argonne National Laboratory and
                         Sandia National Laboratories.

Machine type is Darwin 18.7.0
Machine name is Juan-MBP-2
Working Directory: /Users/test/


Commands will be journaled to '/Users/test/cubit06.jou'
WARNING: Could not open requested journal file.

>>> cubit.cmd('create surface rectangle width 0.095 height 0.035 xplane')
Journaled Command: create surface rectangle width 0.095 height 0.035 xplane

True
>>> 
>>> surf_id = cubit.get_last_id("surface")
>>> surf_id
1

Great! Glad to see you have it working!

One comment, when you initialize Coreform Cubit using cubit.init() you can pass in a list of arguments, which you can find here: https://coreform.com/cubit_help/cubithelp.htm#t=environment_control%2Fsession_control%2Fexecution_command_syntax.htm

Not all arguments are available in Cubit-Python (e.g. it’s always --nographics) but here’s what I often like to run, particularly when I want to minimize output to screen.

cubit.init(["cubit", "-nobanner", "-noecho", "-nojournal","-information", "off", "-warning", "off"])