How can you dynamically determine if an object "works" with an Analysis/environment type?

In Ansys Mechanical scripting, is it possible to determine what objects types are "valid" in a specified analysis/environment type?
Through the Analysis object API, you can add any load/support, but that doesn't necessarily mean it's valid. For example, you can add a pressure object to a Modal analysis, but you won't be able to set the geometry location.
This mapping exists somewhere as the UI elements for a selected analysis change depending on the type.
For example, I've added a Pressure to a Modal through scripting, but this isn't possible through the UI.
Is it possible to check what is "valid" (according to the UI) in scripting?
Best Answer
-
Hi
The only way I have found is through the InternalObject State property, so it can not be guaranteed to work always (internal object).Tried it also on a modal and static system and it gives 2 and 1 as a print out probably meaning that 1 is ok/defined and 2 is not fully defined.
All the best
Erik
- model=ExtAPI.DataModel.Project.Model # refer to Model
- analysis = model.Analyses[0] # change this
- solution = analysis.Solution
- forc=analysis.AddForce()
- NS = ExtAPI.DataModel.GetObjectsByName('myfc')[0] # named sel.
- forc.Location= NS
- forc.Magnitude.Output.SetDiscreteValue(0, Quantity(1, "N"))
- print(forc.InternalObject.State) # 1 for defined and 2 for undefined seems like
0
Answers
-
Hello,
Is this internal state the same as the ObjectState property?
This is how we are checking it now.
- data_model_object.ObjectState == Ansys.Mechanical.DataModel.Enums.ObjectState.FullyDefined
Regardless, our use case requires checking if the object makes sense in that analysis/environment before we create the object. We have actually started poking around in the Python found in v242\aisol\DesignSpace\DSPages looking for where the controllers for these UI handlers may be and where they are getting this mapping.
Would this be the correct direction?
Thank you,
Adam0 -
In addition, we also encounter a similar problem.
For the different DefineBy options for objects, there are different options in the dropdown.
For example, for a Pressure object:
And for a Force object:
The Force object does not have NormalTo. However, you can set the DefineBy to any of the enums values present in LoadDefineBy.
For example:
- force_obj.DefineBy = LoadDefineBy.NormalToOrTangential
The assignment will stick, and the object will report as fully defined.
How can we check for what the valid options are? (As reported by the UI.)
0