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

[DesignModeler] Macro / Script for automatic geometry import

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 13, 2013, 06:10
Default Macro / Script for automatic geometry import
  #1
New Member
 
Join Date: Feb 2013
Posts: 7
Rep Power: 13
wasabi is on a distinguished road
Hello everybody,

First I want to say that I searched in the forum for something similar but I found nothing, so I´m opening this topic.


I´m performing an optimization in which the 3rd-party optimizer runs an external software for geometry generation that generates an .igs file, that, imported into DesignModeler, is the starting point for a parametric model, from where starts a complete CFD workflow.

Here´s my problem:

this .igs file is already present inside the DesignModeler tree, and, even if it is updated at every optimization step (by optimizer-->geometry generation software), it is not automatically updated in DM (think that even if the file is missing the geometry keeps working, I get only a message saying that the original file is missing...).


So I tried to record a script from Workbench in File-->Scripting-->Start recording journal performing these actions:

Opening DM from geometry block --> go to the Import feature in the tree --> RMB "Edit selections" --> Giving the path of .igs file --> Generate --> exit DM --> save file.

But when I run this script workbench only opens DM and closes it, without doing all the import procedure.


Does somebody have any kind of hint for me?

Thanks in advance, best regards.
wasabi is offline   Reply With Quote

Old   June 14, 2013, 11:13
Default
  #2
Senior Member
 
PSYMN's Avatar
 
Simon Pereira
Join Date: Mar 2009
Location: Ann Arbor, MI
Posts: 2,663
Blog Entries: 1
Rep Power: 47
PSYMN has a spectacular aura aboutPSYMN has a spectacular aura about
I don't know what is wrong with DM (why it doesn't try to update), but generally speaking, IGES is a problem.

Each time you generate an IGES file, it generates new surface names without any consistency. It is a difficult starting point for any sort of parametric update.

Just about anything else would be better.
__________________
-----------------------------------------
Please help guide development at ANSYS by filling in these surveys

Public ANSYS ICEM CFD Users Survey

This second one is more general (Gambit, TGrid and ANSYS Meshing users welcome)...

CFD Online Users Survey
PSYMN is offline   Reply With Quote

Old   June 14, 2013, 12:24
Default
  #3
New Member
 
Join Date: Feb 2013
Posts: 7
Rep Power: 13
wasabi is on a distinguished road
First thanks for the answer.

Quote:
Originally Posted by PSYMN View Post
I don't know what is wrong with DM (why it doesn't try to update)
I even tried "manually" to change the imported file, change in WB a parameter (so he was obliged to refresh the DM component) and then I had a look in DM to see if the imported geometry was changed but it was still the old one. To change it, in the "Import" feature properties i found a feature "Refresh"(Yes/No) that if selected as Yes, gives me the chance to click on Generate and so the new geometry is loaded (please see screenshot attached). But this property has to be set manually every time, the simple Refresh of the DM component do not read the geometry file every time, that´s what I´m noticing.

By the way, with some help I set up a Python script to command WB operations and a JavaScript script to make DM loading the file, and right now I´m performing some tests, but I have to wait for the results (finger crossed!).


Concerning the IGES file, thanks for the hint, I will consider a change of format (will STEP be fine?).

Thanks again!
Attached Images
File Type: jpg Screenshot-7.jpg (48.5 KB, 155 views)
wasabi is offline   Reply With Quote

Old   June 14, 2013, 15:13
Default
  #4
Senior Member
 
PSYMN's Avatar
 
Simon Pereira
Join Date: Mar 2009
Location: Ann Arbor, MI
Posts: 2,663
Blog Entries: 1
Rep Power: 47
PSYMN has a spectacular aura aboutPSYMN has a spectacular aura about
Step and IGES are similarly bad... ACIS, Parasolid, dwg and other formats are better because they persistently name their entities the same way between updates.
__________________
-----------------------------------------
Please help guide development at ANSYS by filling in these surveys

Public ANSYS ICEM CFD Users Survey

This second one is more general (Gambit, TGrid and ANSYS Meshing users welcome)...

CFD Online Users Survey
PSYMN is offline   Reply With Quote

Old   June 18, 2013, 08:59
Default
  #5
Member
 
Join Date: Oct 2011
Posts: 36
Rep Power: 15
vigges is on a distinguished road
wasabi,

would you mind sharing the code for both WB and DM operations? I've reached an dead end and maybe you can get me out of there

thanks,
vigges
vigges is offline   Reply With Quote

Old   June 20, 2013, 06:20
Default
  #6
New Member
 
Join Date: Feb 2013
Posts: 7
Rep Power: 13
wasabi is on a distinguished road
Quote:
Originally Posted by vigges View Post
wasabi,

would you mind sharing the code for both WB and DM operations? I've reached an dead end and maybe you can get me out of there

thanks,
vigges
I need firts to check if I can, I developed it in a project of the company I´m working for.
wasabi is offline   Reply With Quote

Old   August 12, 2013, 20:12
Default
  #7
ICS
New Member
 
Join Date: Aug 2013
Posts: 12
Rep Power: 13
ICS is on a distinguished road
I´m also facing problems importing geometries... I already generate parasolids, but it contains many bodies and when I change the geometry all of them become a separate part... I need to automaticaly form a new part with all the bodies in the geometry... how can I do it using script?
ICS is offline   Reply With Quote

Old   August 13, 2013, 04:45
Default
  #8
Senior Member
 
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20
mvoss is on a distinguished road
Regarding the IGES import:
You cannot use the "journaling" for the DM. Wb is Phython, DM is JScript.
BUT: you can send JScript Commands to an DM-Container via the wb-journal.
JScript isn´t supported but there is an overview in the documentation.

I was facing a very similar problem with ICEM and a parametric geometry in an EXTRA dm container on the wb-schematic. I solved the not-upto-date-geometry-error by including the standalone geometry container in the appropriate simulation container (CFX, FLUENT, ANSYS, etc.) . Since the geometry AND the whole downstream action (meshing, solving, post) are stuffed in ONE update call everything worked out. There is smth. strange about different containers on the wb-schematic calling the update for containers downstream in the workflow and also vice versa. Reported it to the support ( they gave the idea mentioned above).

Hope this helps..

Matthias
crevoise likes this.

Last edited by mvoss; August 13, 2013 at 07:52.
mvoss is offline   Reply With Quote

Old   August 13, 2013, 07:57
Default
  #9
ICS
New Member
 
Join Date: Aug 2013
Posts: 12
Rep Power: 13
ICS is on a distinguished road
Thanks for your help!

I understand that I cannot use the "journaling" for the DM. But I can call a JScript from the wokbench journal... so what i'm trying to do is:

WB journal:

system1 = GetSystem(Name="FFF")
geometry1 = system1.GetContainer(ComponentName="Geometry")
geometry1.SetFile(FilePath="C:...........x_t")
geometry1.Edit()
script = open('C:...............js', 'r')
geometry1.SendCommand(Command=script.read())

This code changes the .x_t geometry, opens the DM and runs the JScript file... but how would it be the JScript code to select all bodies in the geometry and form a single part?
Luiz Pancini likes this.
ICS is offline   Reply With Quote

Old   April 1, 2014, 20:05
Default
  #10
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi ICS,

Quote:
Originally Posted by ICS View Post
but how would it be the JScript code to select all bodies in the geometry and form a single part?
there are few functions for all these things, you need to go inside codes to find these functions.
Anyway, what you can do is at the end of your "geometry.js" code, add this

var X = agb.FormNewPartFromAllBodies();
X.name = "Y";

this will create single part from all the bodies.
"Y" is th ename you want for the part which includes all bodies

Hope it helps
Cheers
KAPI
Kapi is offline   Reply With Quote

Old   April 2, 2014, 07:40
Default
  #11
ICS
New Member
 
Join Date: Aug 2013
Posts: 12
Rep Power: 13
ICS is on a distinguished road
Hi Kapi, thanks for your help.

I had already managed a solution, but I forgot to post here... this is how the code became:

system1 = GetSystem(Name="FFF")
geometry1 = system1.GetContainer(ComponentName="Geometry")
geometry1.Edit()
geometry1.SendCommand(Command="""ag.m.NewSession (1);
ag.gui.CreateImport("C:/....x_t");
agb.regen();
ag.gui.PickFilter(5, true);
ag.gui.SelectAll();
ag.m.FormBodyGroup();""")

It opens the DM, create a new session, import the new geometry file, select all bodies and form a new group.

In another thread I discussed a way to update the mesh and export the file: http://www.cfd-online.com/Forums/ans...esh-macro.html
ICS is offline   Reply With Quote

Old   April 9, 2014, 01:27
Default
  #12
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi ICS,
this is alone of the ways to make part from bodies in WBJN file.

Quote:
Originally Posted by ICS View Post
agb.regen();
ag.gui.PickFilter(5, true);
ag.gui.SelectAll();
ag.m.FormBodyGroup();""")
what I posted above is for JS file where all your geometry code goes!
I checked mesh macro link as well, its good, quiet similar to geometry.

Keep up the good work!

Cheers
KAPI
Kapi is offline   Reply With Quote

Old   November 18, 2014, 13:05
Default
  #13
maw
New Member
 
Mark
Join Date: Dec 2011
Posts: 4
Rep Power: 15
maw is on a distinguished road
Do you know a method of choosing only a few bodies as opposed to all?
maw is offline   Reply With Quote

Old   November 24, 2014, 01:07
Default
  #14
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi Maw,

In your JS script you can either do Named selection of bodies and use them how you want or other option is to pick them from top to bottom, something like this

Code:
body1 = ag.fm.Body(ag.fm.BodyCount-1);
and then rename them and use them in your code.

Hope this helps.

Cheers
Kapi
Kapi is offline   Reply With Quote

Old   October 27, 2015, 04:53
Default
  #15
New Member
 
Neal
Join Date: Sep 2013
Posts: 4
Rep Power: 13
nealrm is on a distinguished road
I also need to some how script the creation of a single part from many bodies. However the differences are that i am currently using a parameterized model in workbench that updates by running a journal file with new parameter values (that change the number of bodies by pattern operation).

How can i make a geometry script that will update the existing geometry in workbench and subsequently form the single part of all bodies?
nealrm is offline   Reply With Quote

Old   December 15, 2015, 00:40
Default
  #16
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi Neal,

I think you are after this function

Code:
var Prt1 = agb.FormNewPartFromAllBodies();
Prt1.Name ="Part1";

Cheers
KAPI
Kapi is offline   Reply With Quote

Old   August 29, 2016, 09:04
Talking
  #17
New Member
 
Aung Ko Latt
Join Date: Jul 2016
Location: Germany
Posts: 12
Rep Power: 10
Allen Latt is on a distinguished road
Hello Everyone,

Just like Wasabi, I aslo have the same problem with you.
I am stuck in this place. I tried to find solution but not find out till now.
here is my workflow.

In Design Modeller in my Ansys workbench workflow, I imported one geometry (in .igs file format) and it means that one geometry is already there and there were some additonal editing steps .

In the other hand, I have a main Journal Script to command Workbench operations in WB GUI.

Now I would like to replace that geometry with another geometry (in .igs file format) in Design Modeller.
Is there any JScript command to replace and load another geometry and refresh the old additional editing steps in DesignModeller?

I would like to put that JScript in main Journal Script. How can I link?

I hope someone has an idea about this.

Best Regards,
Aung Ko Latt



Quote:
Originally Posted by wasabi View Post
First thanks for the answer.


I even tried "manually" to change the imported file, change in WB a parameter (so he was obliged to refresh the DM component) and then I had a look in DM to see if the imported geometry was changed but it was still the old one. To change it, in the "Import" feature properties i found a feature "Refresh"(Yes/No) that if selected as Yes, gives me the chance to click on Generate and so the new geometry is loaded (please see screenshot attached). But this property has to be set manually every time, the simple Refresh of the DM component do not read the geometry file every time, that´s what I´m noticing.

By the way, with some help I set up a Python script to command WB operations and a JavaScript script to make DM loading the file, and right now I´m performing some tests, but I have to wait for the results (finger crossed!).


Concerning the IGES file, thanks for the hint, I will consider a change of format (will STEP be fine?).

Thanks again!
Allen Latt is offline   Reply With Quote

Old   August 31, 2016, 22:09
Default
  #18
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
as suggested by PSYMN

Quote:
Step and IGES are similarly bad... ACIS, Parasolid, dwg and other formats are better because they persistently name their entities the same way between updates.
so I suggest u to use other format firstly.
Secondly I am not sure if there is any function to replace your geometry file.
You may have to delete the old file and import the new one.

Kapi
Kapi is offline   Reply With Quote

Old   September 2, 2016, 12:26
Default Explode part/import multiple parts w/ NS
  #19
New Member
 
Join Date: Sep 2016
Posts: 3
Rep Power: 10
elketonis is on a distinguished road
Hi all,

I'm trying to import a .prt geometry file as multiple parts. They are currently being imported as only 1 part with 3 bodies.

I have identified several possible solutions -
1. I need to explode the imported geometry file in DM
2. Import multiple parts with named selections
3. Form a new part for each of the solid bodies

I have not been able to find a command for 1.

Using the import code:
Code:
...
newGeom = "D:/.....prt"
geometry1.SetFile(FilePath=newGeom)
geometry1.Edit()
geometry1.SendCommand(Command="""ag.m.NewSession (1);
ag.gui.CreateImport("D:\....1.prt");
agb.regen();
ag.gui.CreateImport("D:\....2.prt");
agb.regen();
ag.gui.CreateImport("D:\....3.prt");
agb.regen();""")
Creates imports that are not actual solid geometry since it's originally added as a material. Even when I change these manually to add frozen, none of the normal "import geometry" options are available, such as named selections etc.

I'm not sure how to use the
Code:
body1 = ag.fm.Body(ag.fm.BodyCount-1);
that Kapi posted. How do I call body1 to form a new part? Am completely unfamiliar with OOP and JScript.

Any help is appreciated... This is the last step holding me back from automation.
elketonis is offline   Reply With Quote

Old   September 5, 2016, 00:54
Default
  #20
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
you will not be able to "explode" in DM
bring in each geometry separately if u wish!

care to explain more what u want?
Quote:
Creates imports that are not actual solid geometry since it's originally added as a material. Even when I change these manually to add frozen, none of the normal "import geometry" options are available, such as named selections etc.
the code which I posted is used once you have regenerated your geometry as solid body.
Once created you can call the bodies and use functions on them.
What functions do u want to use?
Kapi 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
[ICEM] How to Import a DWG Geometry to ICEM? qzsky ANSYS Meshing & Geometry 6 June 11, 2013 07:43
[DesignModeler] problem with import geometry from catia pavilion ANSYS Meshing & Geometry 1 November 23, 2012 11:45
[ICEM] Problem in geometry creation by script lavoz ANSYS Meshing & Geometry 4 March 12, 2010 11:56
import catia geometry in icem v10 anorky Main CFD Forum 4 December 26, 2009 02:15
creating geometry using "Script files" in ICEMCFD jaber Main CFD Forum 1 November 11, 2007 10:28


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