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   September 5, 2016, 05:06
Default
  #21
New Member
 
Aung Ko Latt
Join Date: Jul 2016
Location: Germany
Posts: 12
Rep Power: 10
Allen Latt is on a distinguished road
Thank you so much ,Kapi !
I will think about it.


Quote:
Originally Posted by Kapi View Post
as suggested by PSYMN

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
Allen Latt is offline   Reply With Quote

Old   September 5, 2016, 05:08
Default
  #22
New Member
 
Aung Ko Latt
Join Date: Jul 2016
Location: Germany
Posts: 12
Rep Power: 10
Allen Latt is on a distinguished road
Thanks Elketonis
I didn't know about it.
I will try for this.

Quote:
Originally Posted by elketonis View Post
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.
Allen Latt is offline   Reply With Quote

Old   September 5, 2016, 10:51
Default
  #23
New Member
 
Join Date: Sep 2016
Posts: 3
Rep Power: 10
elketonis is on a distinguished road
Thanks for the reply Kapi!

So, when I import a geometry file and UpdateFromCAD, I have one part with three bodies. What I need is three bodies as separate parts. I can import the three files separately (but I am not sure how to do this) or I can import the geometry file and then form a new part from each body, so that I end up with three parts and three bodies.

Do you know how to select body 1 and form a new part and select body 2 and form a new part in JScript? That should give me what I'm after.

Quote:
Originally Posted by Kapi View Post
you will not be able to "explode" in DM
bring in each geometry separately if u wish!

care to explain more what u want?


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?
elketonis is offline   Reply With Quote

Old   September 5, 2016, 20:51
Default
  #24
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
you may try this code for exploding part after Regen.
All i could find was this code!
Code:
agTreeExplodePart();
Hope it works for you!
Kapi is offline   Reply With Quote

Old   September 6, 2016, 09:27
Default Selecting the part before exploding
  #25
New Member
 
Join Date: Sep 2016
Posts: 3
Rep Power: 10
elketonis is on a distinguished road
Kapi,

When I try to run a script in DesignModeler with the command
Code:
agTreeExplodePart();
I get an error "object expected."

If I have the following geometry structure:
Part1
_Body1
_Body2
_Body3
How do I select the part that is to be exploded? I tried the select all bodies code
Code:
ag.gui.PickFilter(5, true);
ag.gui.SelectAll();
agTreeExplodePart();
and received the same error.

Also, I cannot use the following code
Code:
geometry1.SendCommand(Command="""ag.m.NewSession (1);
var imp1 = ag.b.Import("D:/....prt");
imp1.Name="Name";
imp1.Operation=ag.c.Frozen;
ag.b.Regen();""")
since I have a .prt file, and it needs to use the NX interface to generate the geometry. When the above script is run, it imports three empty bodies into the model. So my only option is to import one geometry file via WB script, updatefromCAD, and explode the part tree.
elketonis is offline   Reply With Quote

Old   September 6, 2016, 20:07
Default
  #26
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
give object as Part1
may be try this then!

Code:
agTreeExplodePart(Part1);
I havent used this code so I am not 100% sure about it.
Kapi is offline   Reply With Quote

Old   August 25, 2018, 20:03
Default
  #27
New Member
 
Luiz Pancini
Join Date: Jan 2015
Posts: 3
Rep Power: 11
Luiz Pancini is on a distinguished road
Quote:
Originally Posted by ICS View Post
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?
I couldn't find how to read a JScript from the journal, your information has saved me, thanks!
Luiz Pancini 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 20:30.