CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   ANSYS Meshing & Geometry (https://www.cfd-online.com/Forums/ansys-meshing/)
-   -   [ANSYS Meshing] Named Selection Script (https://www.cfd-online.com/Forums/ansys-meshing/238296-named-selection-script.html)

Skadi September 4, 2021 14:19

Named Selection Script
 
Hi Everybody
I'm new to Ansys Scripting.
I'm working on Mechanical Model environment. I've created named selection using worksheet as following code.
Code:

# Name Selection Body
sel = Model.AddNamedSelection()
sel.ScopingMethod=GeometryDefineByType.Worksheet
sel.Name = "Oil"
OilC = sel.GenerationCriteria
OilC.Add(None)
OilC[0].EntityType=SelectionType.GeoBody
OilC[0].Criterion=SelectionCriterionType.Name
OilC[0].Operator=SelectionOperatorType.Equal
OilC[0].Value="FVe"
OilC.Add(None)
OilC[1].EntityType=SelectionType.GeoBody
OilC[1].Criterion=SelectionCriterionType.Name
OilC[1].Operator=SelectionOperatorType.Equal
OilC[1].Value="Core"
OilC.Add(None)
OilC[2].EntityType=SelectionType.GeoBody
OilC[2].Criterion=SelectionCriterionType.Name
OilC[2].Operator=SelectionOperatorType.Equal
OilC[2].Value="Box"
sel.Generate()

Now I want to use the created group in mesh sizing But I don't know how.

Code:

msh = Model.Mesh
m_1 = msh.AddSizing()
m_1.Location  =  "select Name selection Parts Code"

There is an option for selecting geometry by named selection

https://i.ibb.co/Fq8xNmh/NS.png

thanks in advance for your Help and time.

Skadi September 12, 2021 15:08

Named Selection Script
 
I finally found the code thanks to this website

for whom are interested in scripting

Code:

msh = Model.Mesh
Named_selections = DataModel.GetObjectsByName("NAME") #get name selection by its name
m_6 = msh.AddSizing()
m_6.Location = Named_selections[0] #choose The location
m_6.ElementSize = Quantity(str(18)+"[mm]")



All times are GMT -4. The time now is 23:56.