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

[DesignModeler] Script to Update/Refresh CAD Import

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 3 Post By jotter

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 7, 2017, 15:13
Default Script to Update/Refresh CAD Import
  #1
New Member
 
John
Join Date: Dec 2012
Posts: 8
Rep Power: 13
jotter is on a distinguished road
Hello,

I have a simple question regarding scripting in DesignModeler. I have looked through these forums and the ANSYS help guide (which is no where near listing the full functionality of DesignModeler) and I have not been able to answer my question.

I have a DesignModeler file which imports multiple geometries (.step files) and performs a few Boolean operations before naming each face and exporting to the mesher. I need to run this 1000s of times in an automated environment so I will need to use some scripting. I thought the simplest approach would be to keep all of the operations in the DesignModeler project, and simply update the step files and refresh the project. If i manually refresh the file path with a new step file everything works. However, changing (even deleting ) the step files and refreshing the project from workbench does not update the geometry as I would have hoped. There must be a local copy of the geometries made somewhere.


So my question is simple, how do you script the change of a path of a DesignModeler Import, or refresh the import so that DesignModeler reloads the file at the same path in an automated/scripted fashion?

I came across the following topic on this forum which partly answers my question:

DesignModeler Scripting: How to get Full Command Access

But this describes how to make a new CAD import, rather than update an existing one. This could work but would require that I script many other commands to create my final geometry, which is not an option.


One a side note, is there functionality in DesignModeler to record commands from the GUI like there is in ICEM? Otherwise it seems like an impossible task to guess what the syntax and command names are for each of the GUI functions.

Many thanks for your help in advance

John
jotter is offline   Reply With Quote

Old   August 7, 2017, 19:11
Default
  #2
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
sadly you cant record in DM like in ICEM.
so basically you have to hard code the whole thing.

to update the DM you have to do exact same operation as first import really.
I tired doing update import with different path but it dint work.

Its been long but I can have a look again.

Cheers
KAPI
Kapi is offline   Reply With Quote

Old   August 8, 2017, 04:00
Default
  #3
New Member
 
John
Join Date: Dec 2012
Posts: 8
Rep Power: 13
jotter is on a distinguished road
Thanks for you reply KAPI,

When you attempted this before what did you try?

So I am happy with importing new files like this:

Code:
// import file
var imp1=ag.b.Import("I:\\1.step");  // IAnsImport
imp1.Name="CAD_geom";
imp1.Operation=ag.c.Frozen;
imp1.PutBasePlane(ag.b.GetXYPlane());
But what I need is something like this:

Code:
var imp1 = ag.b.GetImportByName('CAD_geom') // a function to recall an existing import
Does anyone know if such a function exists?
jotter is offline   Reply With Quote

Old   August 8, 2017, 05:50
Default
  #4
New Member
 
John
Join Date: Dec 2012
Posts: 8
Rep Power: 13
jotter is on a distinguished road
OK, so I have managed to answer my own question. Hopefully it will be of use use to someone else.

Code:
var selected_import;

selected_import = ag.gui.TreeviewFeature('TEST', 0); // 'TEST' is the name given to the import 
selected_import.Name = 'TEST'   
selected_import.SourceName  = 'I:\\updated_file.step'             
selected_import.Refresh  = 1;
jotter is offline   Reply With Quote

Old   September 22, 2020, 17:49
Default
  #5
New Member
 
STF#00's Avatar
 
Stéphane MONTESINO
Join Date: Sep 2020
Location: Europe
Posts: 2
Rep Power: 0
STF#00 is on a distinguished road
Hi Jotter,
I tried this script to update a Catia file import but I got an error message concerning the file format.
Do you know if there is any option to specify?

Thanks in advance.

Quote:
Originally Posted by jotter View Post
OK, so I have managed to answer my own question. Hopefully it will be of use use to someone else.

Code:
var selected_import;

selected_import = ag.gui.TreeviewFeature('TEST', 0); // 'TEST' is the name given to the import 
selected_import.Name = 'TEST'   
selected_import.SourceName  = 'I:\\updated_file.step'             
selected_import.Refresh  = 1;
STF#00 is offline   Reply With Quote

Old   September 22, 2020, 18:53
Default
  #6
New Member
 
STF#00's Avatar
 
Stéphane MONTESINO
Join Date: Sep 2020
Location: Europe
Posts: 2
Rep Power: 0
STF#00 is on a distinguished road
Quote:
Originally Posted by STF#00 View Post
Hi Jotter,
I tried this script to update a Catia file import but I got an error message concerning the file format.
Do you know if there is any option to specify?

Thanks in advance.
At the end, I also found the answer by myself...

I did 2 mistakes in my code:
I copy paste the file path (using shift + right click)
and I had in my code:
Code:
selected_import.SourceName  = '"D:\Workbench\Cube_New.CATPart"'
  • the double quote had to be removed.
  • The backslash \ need to be replaced by a slash /.

The code that worked for me is:
Code:
selected_import.SourceName  = 'D:/Workbench/Cube_New.CATPart'
Compared to your solution, I used / when you use \\.

Jotter, thanks a lot for your code.
I also hope that my mistake can help those who try to script within Ansys.

Last edited by STF#00; September 22, 2020 at 18:54. Reason: emphasize code
STF#00 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
In Workbench Mechanical, create a script to import external loads grahamrigs ANSYS 0 April 20, 2017 18:05
Can OpenFOAM currently import CAD geometry? Davitt OpenFOAM Pre-Processing 2 November 2, 2015 07:46
[OpenFOAM] Annoying issue of automatic "Rescale to Data Range " with paraFoam/paraview 3.12 keepfit ParaView 60 September 18, 2013 03:23
Errors running allwmake in OpenFOAM141dev with WM_COMPILE_OPTION%3ddebug unoder OpenFOAM Installation 11 January 30, 2008 20:30
I-DEAS CAD data import with boundary conditions Yunus FLUENT 2 March 14, 2001 14:45


All times are GMT -4. The time now is 04:38.