General Mechanical

General Mechanical

Topics related to Mechanical Enterprise, Motion, Additive Print and more.

Create Mesh Element Named Selection in ACT

TAGGED: ,

    • Anezka.Michalkova
      Subscriber

      I am trying to create an ACT which defines load. The user would choose geometry with scoping. The ACT would then make named selection from the chosen geometry (which would be face or multiple faces for example). Then using worksheet, other named selection would be created, selecting all elements which belong to the first name selection. The element named selection would be then used for applying the load with APDL commands (sfe). I have this code

      scoping = load.Properties ["Geometry"].Value
      selectedIds = scoping.Ids
      ExtAPI.SelectionManager.ClearSelection()
      mySel = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
      mySel.Ids = selectedIds

      area = ExtAPI.DataModel.Project.Model.AddNamedSelection()
      area.Location = mySel
      area.Name = "load_area"

      elements = ExtAPI.DataModel.Project.Model.AddNamedSelection()
      elements.Name = "elements"
      elements.ScopingMethod = GeometryDefineByType.Worksheet
      criteria = elements.GenerationCriteria
       
      # First row
      criteria.Add(None)
      criterion_1 = criteria[0]
      criterion_1.EntityType = SelectionType.GeoFace
      criterion_1.Criterion = SelectionCriterionType.NamedSelection
      criterion_1.Operator = SelectionOperatorType.Equal
      criterion_1.Value = area
       
      # Second row
      criteria.Add(None)
      criterion_2 = criteria[1]
      criterion_2.Action = SelectionActionType.Convert
      criterion_2.EntityType = SelectionType.MeshElement
      elements.Generate()


      when I run this code in Mechanical, it works just fine but when the code is run inside the ACT, it does not work. It creates the first named selection but then there is an error (ValueError: This property is parameterized and is read-only.) at the line

      elements.ScopingMethod = GeometryDefineByType.Worksheet

      What is the problem and how can I resolve it?

      The same problem was happening also when I tried to create nodal named selection like this:

      area = ExtAPI.DataModel.Project.Model.AddNamedSelection()
      area.Location = mySel
      area.Name = "load_area"

      area.CreateNodalNamedSelection()

      Again, was working fine in Mechanical scripting, does not work when run in ACT.
    • mjmiddle
      Ansys Employee

       

      If the ACT object is run as part of the solution being generated, such as a load object under the analysis branch, then the Outline object structure is fixed. It is not allowed to change it at that stage because as the APDL input file is written (generally in the order of Outline objects seen from top-to-bottom) certain Outline objects depend on others such as loads/supports written in certain coordinate systems defined higher. Changing some Outline objects at solution time could invalidate other Outline objects.

      With control=”scoping” in the XML, why not just have the user selection a named selection instead of geometry selection? Vertex, edge, face selections create nodal components in APDL while body and element selections cause element components in APDL. So instead of converting to an element named selection, you could enforce body/element selections when “geometry” type is selected for control=”scoping”:

      Or document your extension that the user needs to select named selection from the dropdown and select a body or element named selection.

      Or use control=”select” to make a manual dropdown and populate the list with only those named selections for which your code has checked are body or element named selections.

      Or instead of a "load" use an "object" as a load:

      And use an "ongenerate" callback. This will cause the load to have a yellow lightning bolt until the user right clicks to “Generate” from a popup menu. This may still be a problem since the ongenerate is done automatically when the solution is initiated if the user had not right clicked to generate it first. The Outline is locked during solution as decribed above, so it may cause an error at that time.

      So another suggestion would be to use an "action" callback under an "object":

      This also creates a selection in a right click popup menu. This function could create the named selections and set a global variable used by an "isvalid" callback you would define to check that variable value for whether your Outline object is in a valid state.

      If your load sends APDL commands, such as with a "getsolvecommands" callback or

      ,then another idea would be to handle the conversion to attached elements in APDL from a nodal component or nodal selection. Use NSEL to select the node IDs from the user selection, then ESLN to select attached elements. You can then just use that selection or use CM to create an element component from that.

    • Anezka.Michalkova
      Subscriber

       

      Thank you so much. Can I ask about documentation regarding ACT? There is XML reference guide in help and also XML online reference guide for Mechanical but in neither of them could I find that something like

       exists. Are there any other materials from which I can learn about these commands?

       

    • mjmiddle
      Ansys Employee

      I think this is discussed in the Introductory ACT Training in Mechanical course in the Ansys Learning Hub (ALH):

      https://www.ansys.com/services/ansys-learning-hub

      You should also fnd some usages of it in the ACT Templates:

      https://catalog.ansys.com/Developers.cshtml

      Also see the "Extension Examples" on that page that are discussed in the ACT Developer's Guide:

      https://ansyshelp.ansys.com/account/secured?returnurl=/Views/Secured/corp/v232/en/act_dev/act_dev_exampleExtensions.html

      You could probably find it in ACT extensions in the Ansys Store also. Any that are free and contain the source code are good instructionals.

       

Viewing 3 reply threads
  • The topic ‘Create Mesh Element Named Selection in ACT’ is closed to new replies.