How can I create a selection of adjacent edges using Scripting?

Ayush Kumar
Ayush Kumar Member, Moderator, Employee Posts: 389
First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer

How can I create a selection of adjacent edges using Scripting?

Comments

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 389
    First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer

    You need to define an initial selection using the Geometrical ID, for example let us start with an edge ID 180 and then collect all the adjacent selections and create a named selection:

    # create a new empty selection
    tempSel = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
    # provide list of Ids of entities to select
    tempSel.Ids = [180]
    
    
    ExtAPI.SelectionManager.ClearSelection()
    ExtAPI.SelectionManager.AddSelection(tempSel)
    
    
    ExtAPI.Application.ScriptByName("jscript").ExecuteCommand("DS.Script.doGraphicsAdjacentSelect();")
    cs = ExtAPI.SelectionManager.CurrentSelection
    
    
    ns = Model.AddNamedSelection()
    ns.Location = cs
    ns.Name = "Loop_1"