CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS

Ansys Workbench-Meshing scripting

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 2, 2018, 12:24
Default Ansys Workbench-Meshing scripting
  #1
New Member
 
Nathan
Join Date: Oct 2018
Posts: 2
Rep Power: 0
njpatter is on a distinguished road
Hi everyone,

First, thanks for all of the great answers to previous questions that people have provided in the forum, they have been helpful in navigating the scripting/automation process.

I am trying to automate an entire project:
1. Geometry creation in SpaceClaim
2. Sizing and mesh generation in Meshing
3. Fluent setup, simulation, and post-processing

I have a working solution for #1 and am figuring out the command list options for #3. I also have a working solution for Meshing (#2), well two of them actually, but am unable to figure out how to call either from a Workbench journal file.

The one I'd prefer to use at this point is a working jscript macro for Meshing and I would like to call from a workbench journal.

Simple version of Meshing Macro (works if called by running Macro in Meshing):
Code:
Main();

function Main()
{ 
	var Mesh_Mod = DS.Tree.FirstActiveBranch.MeshControlGroup;
	DS.Script.SelectItems(""+Mesh_Mod.ID);

	//Insert the face sizing for the object
	DS.Script.doInsertMeshSize(1)
	ListView.ActivateItem("Scoping Method");
	ListView.ItemValue = "Named Selection" ;
	ListView.ActivateItem("Named Selection");
	ListView.ItemValue = "ObjSurface" ;
	ListView.ActivateItem("Type");
	ListView.ItemValue = "Element Size";
	ListView.ActivateItem("Element Size");
	ListView.ItemValue = "0.01";
	ListView.ActivateItem("Behavior");
	ListView.ItemValue = "Hard";
}
When I try to run it from a Workbench journal file using:
Code:
meshComponent1 = system1.GetComponent(Name="Mesh")
meshComponent1.Refresh()
meshing1 = system1.GetContainer(ComponentName="Mesh")
meshing1.Edit()
meshScript = open('C:\...blahblahpath...\Meshing_ScriptTest.js', 'r')
meshing1.SendCommand(Command=meshScript.read()) #this is line 20
meshing1.Exit()
meshComponent1.Refresh()
It launches the Meshing program and then throws the following error:
Quote:
CommandFailedException: Unalge to update setup using new parameter values. In file '...myfilepath...', line 20
Does anyone have any suggestions where my code/approach may be wrong?
njpatter is offline   Reply With Quote

Old   October 2, 2018, 13:34
Default
  #2
New Member
 
Nathan
Join Date: Oct 2018
Posts: 2
Rep Power: 0
njpatter is on a distinguished road
I figured it out and thought I'd leave it here in case anyone else has the same problem.

Instead of the open and SendCommand lines from above, I used this:
Quote:
meshing1.SendCommand(Command="WB.AppletList.Applet ("DSApplet").App.Script.doToolsRunMacro("C:/folder/structure/withForward/slashes/Meshing_ScriptTest.js")")
and exiting I did a meshComponent1.Update() instead of refresh.
njpatter is offline   Reply With Quote

Old   March 22, 2023, 09:47
Default
  #3
Senior Member
 
Join Date: Feb 2020
Posts: 114
Rep Power: 6
lbj007 is on a distinguished road
Hi, I would like to ask a question about scdm scripting. I want to filter out all the faces such as in the z = 5 plane, but I do not know how to implement this process.
lbj007 is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ansys workbench meshing sanjaykummar2810 CFD Freelancers 6 August 15, 2018 01:47
Ansys workbench scripting sunilpatil CFX 7 January 31, 2018 07:57
[ANSYS Meshing] Migrating from GAMBIT to ANSYS Meshing David-CFD ANSYS Meshing & Geometry 1 April 1, 2011 06:22
Meshing In Ansys Workbench For Fluent (Refinement) FAU_OceanEng FLUENT 0 May 31, 2010 18:12


All times are GMT -4. The time now is 00:14.