CubitInterface::Surface::ordered_loops() in python interface

Hi, I’m using the python interface to generate and modify mesh.

What I’m wondering is how to access curves that are contained in a certain surface?

I read about the method ‘ordered_loops()’ and it says it returns vector of vector of Curve which is a standard C++ container type.
But when I used this in python scripts, the returned variable is not iterable and I cannot access this using the list operator like value[0].
I want to modify intervals points of the curves that compose a certain surface in order to manipulate mesh granularity.

How can I do this?

Cubit version is latest (2022. 06)

Thank you.

Welcome to the forum @kkm3182!

One way to get all the curves in a surface is to use the parse_cubit_list() method. This method returns a tuple of entity ids that correspond to the results of the cubit command list <entity_type> <logical>.

For example, if you would run a Cubit command:

list curve in surface 198

the corresponding Python command would be:

cubit.parse_cubit_list( "curve", "in surface 198" )

I’ll often use this in a loop, for example, maybe I want to iterate over all surfaces in a volume and for each surface grab its curves and do operations:

V = cubit.get_entities( "volume" ) ## Gets *all* volume ids
for vid in V: 
    ## For each volume, get all children surfaces
    S = cubit.parse_cubit_list( "surface", f"in volume {vid}" )
    for sid in S:
        ## For each surface in the volume, get all children curves
        C = cubit.parse_cubit_list( "curve", f"in surface {sid}" )
        do_something_with_curves( C )  ## do something

Hi @kkm3182 ,

There appears to be a bug in how ordered_loops() returns data to python. You are right in that it should return an iterable. In this case it should return a tuple of tuples of Curve objects. I will enter this into our bug tracking system.

In the meantime, @grvernon’s response is the method that I normally use anyway.

Thanks,
Karl

Thanks for you guys @gvernon @karl .
I’ll try the way that @gvernon wrote here.