Command to select hex elements with negative scaled jacobian quality


I have read the help about select statements but unfortunatly I cannot figure out how it works for my purpose.

Here is my problem and probably there is an easy way to do this :wink:

I have an existing hexahedral mesh from an INP file.
When I import this mesh and check the quality, there are some hex elements with a negative scaled jacobian quality. I can visualize these with this command easily:
quality element all scaled jacobian high 0 draw mesh

Now I would like to get all Element IDs of these by a command - actually, it would be perfect if I can have a list of IDs in a python script so I can then modify the bad elements later.

thank you for your help on my previous topics, I really appreciate your effort!

Best regards,

Hi @Willi,

In Python there is a method get_quality_value() that can return the quality value for a given element. You could simply loop through all elements in your mesh and store the value in a list or NumPy array.

Here’s a link to the documentation of this method.

Here’s an example of querying the Scaled Jacobian of hex element #1:

cubit.get_quality_value("hex",1,"scaled jacobian")

Let me know if that’s helpful!

Best regards,


Hi Greg,

thank you for your quick and helpful support!
This works basically, but I need to have my element IDs as in the INP file, therefore I would do a sequence of the following:

loop through all element IDs
   cubit.cmd("select element [elementID]");
   hexID = cubit.get_selected_id(0);
   quality = cubit.get_quality_value("hex",hexID,"scaled jacobian");
   check quality and save it ...
loop end

Is there an “easier” way to do that?
I tried it with
quality = cubit.get_quality_value("element",elementID,"scaled jacobian")
but it didn’t work, return value is 0.0

Best regards,

Hi Willi,

# Get all the (Cubit) Hex Ids in a volume
hexID = cubit.get_volume_hexes(1)

# Initialize list to store element information
abaID = []
quality = []
for i in range(0,len(hexID)):
   # If you need the Abaqus ID, I think this should work
   abaID.append(cubit.get_global_element_id("hex", hexID[i]))
   # Query the current hex element's quality
   quality.append(cubit.get_quality_value("hex", hexID[i], "scaled jacobian"))

Does that work for you?

Hi Greg,

works perfectly, thank you very much! :slight_smile:

Best regards,