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/)
-   -   [Workbench] Automating worksheet of named selections in Ansys Workbench (https://www.cfd-online.com/Forums/ansys-meshing/183923-automating-worksheet-named-selections-ansys-workbench.html)

Ben_15 February 16, 2017 19:16

Automating worksheet of named selections in Ansys Workbench
 
Hi everyone,


I would like to create an automatic named selection with Jscript code in Ansys Workbench.


My idea was to use a worksheet as scoping method for named selection (with different criteria). However I have some problem with the code.


I don’t know how to write in my code the selection of different criteria (Action, GeometryType, Operator, Value …) and the application of “a filter” (Body, Face, Vertex … for GeometryType / Equal, NotEqual, Less Than … for Operator …) which are in the worksheet.


When I tried something like the code below, I have an error message: Error 800A01C2 - Wrong number of arguments of invalid property assignment.


name = "Selection_1"
NS = DS.Script.addNamedSelection(false,name,DS.Script.i d_NS_Body);
DS.Script.changeActiveObject(NS.ID)
ListView.ActivateItem("Scoping Method");
ListView.ItemValue = "Worksheet";
NS.AddCriteriaData();

Someone have an idea ?



In my opinion, I don’t have the good parameters in “addnamedselection()” but I don’t know how to do.


Thank you for your help.
Ben

LLORIA October 4, 2017 06:00

Hi here is your answer :) :

named_sel=ExtAPI.DataModel.Project.Model.AddNamedS election()
named_sel.SendToSolver=0
named_sel.Location=ExtAPI.SelectionManager.CreateS electionInfo(SelectionTypeEnum.WorksheetSpecific)
named_sel_WS=named_sel.Location
named_sel.Name="Target_Faces_mesh_sizing_sym_entry _holes"

named_sel_WS.AddRow()
named_sel_WS.SetAction(0,NamedSelectionWorksheetAc tion.Add)
named_sel_WS.SetEntityType(0,NamedSelectionWorkshe etEntityType.Face)
named_sel_WS.SetCriterion(0,NamedSelectionWorkshee tCriterion.Location_Y) #NamedSelection Location_X
named_sel_WS.SetOperator(0,NamedSelectionWorksheet Operator.GreaterThan) #Largest Smallest Equal NotEqual LessThan GreaterThan Equal
named_sel_WS.SetValue(0,0.245)

named_sel_WS.AddRow()
named_sel_WS.SetAction(1,NamedSelectionWorksheetAc tion.Filter)
named_sel_WS.SetEntityType(1,NamedSelectionWorkshe etEntityType.Face)
named_sel_WS.SetCriterion(1,NamedSelectionWorkshee tCriterion.Location_Y) #NamedSelection Location_X
named_sel_WS.SetOperator(1,NamedSelectionWorksheet Operator.LessThan) #Largest Smallest Equal NotEqual LessThan GreaterThan Equal
named_sel_WS.SetValue(1,0.278)

named_sel_WS.AddRow()
named_sel_WS.SetAction(2,NamedSelectionWorksheetAc tion.Filter)
named_sel_WS.SetEntityType(2,NamedSelectionWorkshe etEntityType.Face)
named_sel_WS.SetCriterion(2,NamedSelectionWorkshee tCriterion.Size)
named_sel_WS.SetOperator(2,NamedSelectionWorksheet Operator.LessThan)
named_sel_WS.SetValue(2,0.00290)

named_sel_WS.AddRow()
named_sel_WS.SetAction(3,NamedSelectionWorksheetAc tion.Filter)
named_sel_WS.SetEntityType(3,NamedSelectionWorkshe etEntityType.Face)
named_sel_WS.SetCriterion(3,NamedSelectionWorkshee tCriterion.Size)
named_sel_WS.SetOperator(3,NamedSelectionWorksheet Operator.GreaterThan)
named_sel_WS.SetValue(3,0.00280)
named_sel_WS.Generate()

danishrehman March 9, 2019 10:14

Automatic selection script gives the error.... Help Please
 
Hello experts,
I am trying to access the named selection automation script given by LLORIA but when I run it in ANSYS MESH, it mentions the error shown in the picture. I want to create 100s of named selection (faces/volumes) to assign boundary conditions systematically. Thanks for your help in advance.


https://drive.google.com/file/d/171u...ew?usp=sharing

Quote:

Originally Posted by LLORIA (Post 666529)
Hi here is your answer :) :

named_sel=ExtAPI.DataModel.Project.Model.AddNamedS election()
named_sel.SendToSolver=0
named_sel.Location=ExtAPI.SelectionManager.CreateS electionInfo(SelectionTypeEnum.WorksheetSpecific)
named_sel_WS=named_sel.Location
named_sel.Name="Target_Faces_mesh_sizing_sym_entry _holes"

named_sel_WS.AddRow()
named_sel_WS.SetAction(0,NamedSelectionWorksheetAc tion.Add)
named_sel_WS.SetEntityType(0,NamedSelectionWorkshe etEntityType.Face)
named_sel_WS.SetCriterion(0,NamedSelectionWorkshee tCriterion.Location_Y) #NamedSelection Location_X
named_sel_WS.SetOperator(0,NamedSelectionWorksheet Operator.GreaterThan) #Largest Smallest Equal NotEqual LessThan GreaterThan Equal
named_sel_WS.SetValue(0,0.245)

named_sel_WS.AddRow()
named_sel_WS.SetAction(1,NamedSelectionWorksheetAc tion.Filter)
named_sel_WS.SetEntityType(1,NamedSelectionWorkshe etEntityType.Face)
named_sel_WS.SetCriterion(1,NamedSelectionWorkshee tCriterion.Location_Y) #NamedSelection Location_X
named_sel_WS.SetOperator(1,NamedSelectionWorksheet Operator.LessThan) #Largest Smallest Equal NotEqual LessThan GreaterThan Equal
named_sel_WS.SetValue(1,0.278)

named_sel_WS.AddRow()
named_sel_WS.SetAction(2,NamedSelectionWorksheetAc tion.Filter)
named_sel_WS.SetEntityType(2,NamedSelectionWorkshe etEntityType.Face)
named_sel_WS.SetCriterion(2,NamedSelectionWorkshee tCriterion.Size)
named_sel_WS.SetOperator(2,NamedSelectionWorksheet Operator.LessThan)
named_sel_WS.SetValue(2,0.00290)

named_sel_WS.AddRow()
named_sel_WS.SetAction(3,NamedSelectionWorksheetAc tion.Filter)
named_sel_WS.SetEntityType(3,NamedSelectionWorkshe etEntityType.Face)
named_sel_WS.SetCriterion(3,NamedSelectionWorkshee tCriterion.Size)
named_sel_WS.SetOperator(3,NamedSelectionWorksheet Operator.GreaterThan)
named_sel_WS.SetValue(3,0.00280)
named_sel_WS.Generate()


bpulat March 12, 2019 03:31

I am not an expert in ANSYS ACT but the script originally posted by LLORIA looks to be an ACT code.
Therefore, it is not going to work with ANSYS run macro utility which uses JScript.


All times are GMT -4. The time now is 16:21.