How do I detect read-only characteristics of a named selection generation criteria?

tlewis3348
tlewis3348 Member Posts: 20
10 Comments Name Dropper Photogenic
**

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.

Best Answer

  • Mike.Thompson
    Mike.Thompson Member, Employee Posts: 366
    25 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    Answer ✓

    Why do you need the read only items? Many of the read only items are logically pretty obvious. For example defining by range requires a min/max while by value requires a value.

    You are correct each line will have a value for all columns, but they are simply not used when not logically required. So a Min value definition does nothing when converting from a face to edge because it doesn’t make sense (but won’t hurt you)

    You can always record the line creation and see the APIs as well.

Answers

  • tlewis3348
    tlewis3348 Member Posts: 20
    10 Comments Name Dropper Photogenic
    **

    Edit:

    I just realized that characteristics that are "read-only" in the UI are not necessarily read-only on the scripting side. Does this mean I should just ignore whether the characteristic is read-only or not?

  • tlewis3348
    tlewis3348 Member Posts: 20
    10 Comments Name Dropper Photogenic
    **

    Mike,

    Thanks for the response. I think knowing that having the value set on the scripting side even if it is read-only on the UI side answers my question. Ultimately, I'm trying to loop through all the criteria and get the definition for each so I can later create new criteria in a matching named selection later. I was concerned that I should only be applying the properties in the new named selection when the property was writable, but since I can write to the property with the script whether the property gets used or not should simplify things.