How to generate mesh on selected body with and without looping?

Member, Employee Posts: 201
100 Likes 100 Comments Second Anniversary Ansys Employee
✭✭✭✭
edited August 2023 in Structures

How to generate mesh on selected body with and without looping?

Tagged:

Best Answer

  • Member, Employee Posts: 201
    100 Likes 100 Comments Second Anniversary Ansys Employee
    ✭✭✭✭
    edited August 2023 Answer ✓

    While looping one can use the following code :

    1. currentIds = ExtAPI.SelectionManager.CurrentSelection.Ids
    2. for id in currentIds :
    3. geoBody = ExtAPI.DataModel.GeoData.GeoEntityById(id)
    4. treeBody = ExtAPI.DataModel.Project.Model.Geometry.GetBody(geoBody)
    5. treeBody.GenerateMesh()

    and without looping (after activating all tree objects) :

    1. cmd="""DS.Script.doModelPreviewMesh();"""
    2. ds=ExtAPI.Application.ScriptByName("jscript").ExecuteCommand(cmd)

Answers

  • Member, Employee, GitHub-issue-creator Posts: 353
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    edited October 2024

    At 24.2:

    1. import context_menu
    2. ExtAPI.DataModel.Tree.Activate(list_of_tree_objects_to_mesh)
    3. context_menu.DoModelPreviewMesh(ExtAPI)
    4.  

Welcome!

It looks like you're new here. Sign in or register to get started.