-
-
August 1, 2024 at 4:53 amDustin LochmüllerSubscriber
Hi,
I am currently using a “User Defined Result” to evaluate the equivalent (von-Mises) stress along a construction geometry (path). I use this Python code to generate the result:
solution = Model.Analyses[0].Solution.AddUserDefinedResult()
solution.ScopingMethod = GeometryDefineByType.Path
solution.Location = DataModel.GetObjectsByName(“PATH_NAME”)[0]
solution.Expression = r'seqv'
solution.GraphControlsXAxis = GraphControlsXAxis.Time
solution.CreateParameter(“Maximum”)The path runs through two bodies, but I want to limit it to one body using the geometry option (see screenshot). This works manually by selecting the body, but unfortunately, I can't find a way to do this via the scripting interface.
Does anyone know how to update the geometry option (something like “solution.Geometry = DataModel.GetObjectsByName(“BODY_NAME”)”)? Thanks in advance.Kindest Regards
Dustin
-
August 1, 2024 at 1:08 pmAniketForum Moderator
try recording the function from mechanical scripting,
You will get something like:
#region Details View Action
selection = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
selection.Ids = [64]
user_defined_result_60.Location = selection-Aniket
-
August 1, 2024 at 1:59 pmDustin LochmüllerSubscriber
Thanks for the prompt answer, I have already tried that. I already set the location parameter with the path (see code excerpt above). If I set the location parameter again with a body, then the scoping method changes to “Named Selection” and the path is no longer used.
-
August 1, 2024 at 2:18 pmErik KostsonAnsys Employee
The below is working – needs to be in this order:
model=ExtAPI.DataModel.Project.Model # refer to Model
analysis = model.Analyses[0]
solution = analysis.Solution
geometry = DataModel.GetObjectsByName(‘Solid.1’)[0]
path = DataModel.GetObjectsByName(‘Path’)[0]
res=solution.AddUserDefinedResult()
gId=geometry.GetGeoBody().Id
SlMn = ExtAPI.SelectionManager
SlMn.ClearSelection()
Sel = SlMn.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
Sel.Ids = [gId]
res.ScopingMethod=GeometryDefineByType.Path
res.Location=Sel
res.Location=pathres.Expression=’UX'
or if we are using a named selection (NS) say called Selection2:
model=ExtAPI.DataModel.Project.Model # refer to Model
analysis = model.Analyses[0]
solution = analysis.Solution
ns=DataModel.GetObjectsByName(‘Selection2’)[0] # change name of NS as needed
path = DataModel.GetObjectsByName(‘Path’)[0] # change name of path as needed
res=solution.AddUserDefinedResult()
res.ScopingMethod=GeometryDefineByType.Path
res.Location=ns
res.Location=pathres.Expression=’UZ'
both are working fine .
Still if for some reason it is not then read here for more info and alternative:
https://discuss.ansys.com/discussion/2491/how-to-set-path-and-geometry-scoping-when-defining-result-object-with-path-as-the-scoping-method-
August 1, 2024 at 5:38 pmDustin LochmüllerSubscriber
Thank you, Erik! It is working now. My mistake was that I always did it the other way around (first defined the path and then the geometry) and that didn’t work.
Do you also have some advice on how to export the result as a table? The script recording is not showing any output when I run it by hand.
If I use "res.ExportToTextFile("PATH_TO_FILE")" it exports the data from the path over distance. I want to change the X-Axis to Time and export those Min, Max, and Average values, but that seems not to work. I did the following but still got the values over distance:
res.GraphControlsXAxis = GraphControlsXAxis.Time
res.ExportToTextFile("PATH_TO_FILE")and then I got this:
but I want to export this:
-
-
August 2, 2024 at 6:40 amErik KostsonAnsys Employee
Hi
Does not seem to be a direct command.
One way to do it is posted here:
https://discuss.ansys.com/discussion/4344/path-results-vs-time-graphic-controlAll the best
Erik
-
August 2, 2024 at 6:54 amDustin LochmüllerSubscriberHello!I greatly appreciate your help! Thank you, this has helped me a lot. I'm doing it now, similar but a bit different. I just create a user-defined result for each time step and add the maximum value to the parameter set.Thank you, it really helped me a lot.Dustin
-
-
August 2, 2024 at 6:55 amErik KostsonAnsys Employee
In the future post any script related questions in the linked (discuss) forums which are dedicated to that.
Closing this as it might help others.
-
August 1, 2024 at 2:17 pmDustin LochmüllerSubscriber
Thank you for your detailed answer. Unfortunately, I am unable to make it work.
In this picture you can see the analysis I am currently using. I generate the path I want to use in static structural. The solid I intend to apply to the geometry parameter is the solid imported from the mechanical model. A named selection contains this body, how can I use the named selection to assign the body to the Geometry parameter?
And another thing I can't find a solution for currently: Is there a way to export the user defined results data in table form using scripting? Like in this picture
Thanks for helping
Dustin
-
- The topic ‘User Defined Result’ is closed to new replies.
- Problem with access to session files
- Ayuda con Error: “Unable to access the source: EngineeringData”
- At least one body has been found to have only 1 element in at least 2 directions
- Error when opening saved Workbench project
- Geometric stiffness matrix for solid elements
- How to select the interface delamination surface of a laminate?
- How to apply Compression-only Support?
- Timestep range set for animation export
- Image to file in Mechanical is bugged and does not show text
- SMART crack under fatigue conditions, different crack sizes can’t growth
-
1191
-
513
-
488
-
225
-
209
© 2024 Copyright ANSYS, Inc. All rights reserved.