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.
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
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.