The code below loops through the generation criteria for a named selection and saves the criteria selections to a list.
chars = [
"Active",
"Action",
"EntityType",
"Criterion",
"Operator",
"Units",
"Value",
"LowerBound",
"UpperBound",
"CoordinateSystem"
]
gen_crits = []
for gen_crit in ns.GenerationCriteria:
gen_crits.append([])
for char in chars:
gen_crits[-1].append((char, getattr(gen_crit, char)))
However, I'm running into issues when the characteristic is disabled or read-only. Here is the criteria I've been using for testing:

Here is the content of the gen_crits
variable:
[
[
('Active', True),
('Action', Add),
('EntityType', GeoBody),
('Criterion', NamedSelection),
('Operator', Equal),
('Value', Ansys.ACT.Automation.Mechanical.NamedSelection),
('LowerBound', None),
('UpperBound', None),
('CoordinateSystem', Ansys.ACT.Automation.Mechanical.CoordinateSystem)
],
[
('Active', True),
('Action', Add),
('EntityType', GeoBody),
('Criterion', NamedSelection),
('Operator', Equal),
('Value', Ansys.ACT.Automation.Mechanical.NamedSelection),
('LowerBound', None),
('UpperBound', None),
('CoordinateSystem', Ansys.ACT.Automation.Mechanical.CoordinateSystem)
],
[
('Active', True),
('Action', Convert),
('EntityType', GeoEdge),
('Criterion', AnyVertex),
('Operator', Unknown),
('Value', None),
('LowerBound', 1.7E+308),
('UpperBound', 1.7E+308),
('CoordinateSystem', Ansys.ACT.Automation.Mechanical.CoordinateSystem)
],
[
('Active', False),
('Action', Filter),
('EntityType', GeoEdge),
('Criterion', Type),
('Operator', Equal),
('Value', 1),
('LowerBound', 1.7E+308),
('UpperBound', 1.7E+308),
('CoordinateSystem', Ansys.ACT.Automation.Mechanical.CoordinateSystem)
],
[
('Active', True),
('Action', Filter),
('EntityType', GeoEdge),
('Criterion', LocationX),
('Operator', RangeInclude),
('Value', '0.01452565193 [m]'),
('LowerBound', '0.014 [m]'),
('UpperBound', '0.015 [m]'),
('CoordinateSystem', Ansys.ACT.Automation.Mechanical.CoordinateSystem)
]
]
As you can see, the returned value for each characteristic that shows up as "N/A" in the UI seems to be unpredictable. For example, the value returned for LowerBound
is sometimes "None", but other times, it is essentially infinite. What I would honestly like to do is detect when the characteristic is disabled / read-only and not save it to the list. As far as I can tell, there is not a ReadOnly
property for any given characteristic. I could write a function that tries to modify the characteristic before resetting it to the original value and return a boolean value corresponding to whether or not the value was successfully changed. However, I'm wondering if there might be a better option.