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

[DesignModeler] Designmodeler java scripting

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   February 25, 2014, 06:44
Default Designmodeler java scripting
  #1
New Member
 
Join Date: Feb 2014
Posts: 2
Rep Power: 0
Herbert2014 is on a distinguished road
Hello,
i´m new in the cad-world and haven´t got a lot of experiences with java.

I load two txt-Files as 3D-Curves into the Designmodeler, which are the profile for a blade. In general it´s a workbenchproject. My problem is, when the txt-Files change, i want the designmodeler to refresh the 3d-curves automatically. It works the best with a java-script, but i´m not able to build the script.

In short, i want a script, which sets the 3D-Curve-Option ´Refresh´ to Yes and after that, generates the new geometry.

It would be very nice, if someone could give me an introduction into the java-code, which would solve the problem.

Best regards
Herbert2014 is offline   Reply With Quote

Old   February 25, 2014, 09:06
Default
  #2
Senior Member
 
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 446
Rep Power: 11
mvoss is on a distinguished road
Are you using the JScript feature (JavaScript eq JScript????)?
Within wb you can reach down to the DM from the journal-feature via
Code:
system = GetSystem(Name="Geom")
geometry = system.GetContainer(ComponentName= "Geomtry")
SendCommand(Command = ""var ps1=new Object();
***
agb.Regen();"")
I would guess that the agb.Regen() is what you need.
You need to find a function for reading in the txt-files in DM OR you find the tree feature in DM by name e.g. OR you start the above script after checking for the updated txt-files.

Hopefully this will get you on the right track.
mvoss is offline   Reply With Quote

Old   February 25, 2014, 10:06
Default
  #3
New Member
 
Join Date: Feb 2014
Posts: 2
Rep Power: 0
Herbert2014 is on a distinguished road
Quote:
Originally Posted by mvoss View Post
Are you using the JScript feature (JavaScript eq JScript????)?
Within wb you can reach down to the DM from the journal-feature via
Code:
system = GetSystem(Name="Geom")
geometry = system.GetContainer(ComponentName= "Geomtry")
SendCommand(Command = ""var ps1=new Object();
***
agb.Regen();"")
I would guess that the agb.Regen() is what you need.
You need to find a function for reading in the txt-files in DM OR you find the tree feature in DM by name e.g. OR you start the above script after checking for the updated txt-files.

Hopefully this will get you on the right track.
First, thx for quick answer.

Yes, i worked with a pythen-script from the journal-feature, which uses a java script to update the 3d curve. Meanwhile i create a java-script which should work, but it doesn´t.

Folowing error is produced

Error: The object doesn´t run with this method.
Code:800a01b6
Script: varname.Refresh=1 (line 12....

I think there could be an error in the definition of the 3d-Curve, which i want to refresh. For example my 3d Curve is named "Curve 2323", do you know with which command in java i got the correct definition of a 3d-curve? what ist the right command to give the information which feature in the designmodeler i want to refresh?

Thanks for the help

Best regard

Herbert
Herbert2014 is offline   Reply With Quote

Old   February 26, 2014, 05:29
Default
  #4
Senior Member
 
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 446
Rep Power: 11
mvoss is on a distinguished road
finding the correct function for DM scripting is difficult. i have no idea about a specific command - but i would guess the agb.regen() refreshes the whole dm tree from top to bottom.
Just to be clear on the code:
you MUST spell it agb.Regen() --> since agb gives you smth. like a root access to the dm features - and as always, it´s not documented. Looking at your error this makes sense.
mvoss is offline   Reply With Quote

Old   November 4, 2014, 12:17
Default
  #5
New Member
 
Luke
Join Date: Nov 2012
Posts: 5
Rep Power: 4
aerospace84 is on a distinguished road
same problem! i've to refresh this 3d curve .txt files....and ansys support i'st answering me! have you solved in some way?
i haven't found yet this command to refresh the txt...
any good news??
aerospace84 is offline   Reply With Quote

Old   November 12, 2014, 20:53
Default
  #6
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 230
Rep Power: 4
Kapi is on a distinguished road
to refresh or update the design you need to read the file once again
and then regenerate which updates the design

code something like this will read your geometry.txt file

Quote:
# encoding: utf-8
SetScriptVersion(Version="15.0")
template1 = GetTemplate(TemplateName="Mesh")
system1 = template1.CreateSystem()
geometry1 = system1.GetContainer(ComponentName="Geometry")
geometry1.Edit()
script = open('C:\Users\........\Geometry.txt', 'r')
geometry1.SendCommand(Command=script.read())
script.close();
Inside Geomerty.txt file you can put a code line which regenerates everytime you change code which is given as

Quote:
agb.Regen()

Hope this solves your problem!


Cheers
Kapi
Kapi is offline   Reply With Quote

Old   November 18, 2014, 05:06
Default
  #7
New Member
 
Luke
Join Date: Nov 2012
Posts: 5
Rep Power: 4
aerospace84 is on a distinguished road
thanks! I'll try this as soon as i can. Working in an industry I haven't so much time to strive following one path so i've managed using ICEM script...
But i'll try this in the spare time (i hope to have it!!) and as soon i get it i'll answer about this successful hint.
Anyway thank you for your answer!! i really appreciate that!
aerospace84 is offline   Reply With Quote

Old   April 20, 2015, 02:13
Default
  #8
New Member
 
narjisse
Join Date: Apr 2015
Posts: 5
Rep Power: 2
minou is on a distinguished road
Hi everybody!
I know nothing about the scripting in ANSYS! (but i can try to learn )
I have the same problem: I want to import 2 texts files to draw 2 3D-curves! and after that continue my geometry (close my gemetry,extrude it, create a new sketch .. ).
For an optimization problem, I want to refresh for every individual the 2 curves only and let the rest.[the 2 texts files are refreshed automatically]
Thank you for your help!
minou is offline   Reply With Quote

Old   April 20, 2015, 02:24
Default
  #9
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 230
Rep Power: 4
Kapi is on a distinguished road
Hi Minou,

Welcome to the forum!

To start with Scripting, I strongly suggest that you go to Ansys>Help section and go through "Scripting guide" to understand the process of scripting!

It will help you to sketch down steps of designing and optimization you want to achieve and then you can tackle these steps one by one!

Cheers
KAPI
Kapi is offline   Reply With Quote

Old   April 21, 2015, 02:25
Default
  #10
New Member
 
narjisse
Join Date: Apr 2015
Posts: 5
Rep Power: 2
minou is on a distinguished road
Hi Kapi,

Thank you for you quick answer! However, I just want to know if I can create a macro to change (i.e., refresh) only one part of my geometry, without changing the whole geometry.
Attached in a PDF document, is a snapshot of the tree of my geometry in ANSYS Design Modeler, which illustrates my problem. I would like to only change (i.e., refresh) “Curve1” and “Curve2” in the attached tree by refreshing them automatically every time the Designmodeler is opened during the optimization without changing the rest of the tree, i.e. without changing “Line2”, “Plane5”, “Plane8”, “Extrude3”. The “2parts,2bodies” in the tree will be changed automatically if “Curve1” and “Curve2” are refreshed.
When “Curve1” is selected in the tree, the “Refresh” field in the “Detailed view” window of ANSYS Design modeler in the attached file shows “No”. I would like to change this to a “yes” using a workbench macro. I have not yet succeeded in doing this automatically for each individual during an optimization process, which requires a workbench Macro.

question.pdf

Thank you,
minou is offline   Reply With Quote

Old   April 21, 2015, 19:34
Default
  #11
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 230
Rep Power: 4
Kapi is on a distinguished road
Hi Minou,

Your Line, Plane and Extrude will not be Refreshed if they are not connected to your curve. When you regenerate only your Curve and 2bodies will be updates/refreshed!

After your curve parameters change, you can call macro file (js file) which picks and regenerates your curve.
Code:
agb.Regen()
or when you create curve give this code, it will put refresh as YES!
Code:
var myCurve = ag.gui.CreateCurve();
myCurve.CoordinateFile = "FilePath";
myCurve.Name = "Curve1";
myCurve.CurveRefresh = 1;//if "1" dosent change refresh to yes then change it to "2"
Hope it helps
Cheers
KAPI
Kapi is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[DesignModeler] DesignModeler Scripting: How to get Full Command Access ANT ANSYS Meshing & Geometry 21 May 26, 2015 18:28
record actions via scripting Marabelle ANSYS 0 July 31, 2013 11:57
Macro scripting in netbeans, importing star libraries laurensvd STAR-CCM+ 2 March 31, 2013 10:02
Macro to access java files in sub-directory abraum STAR-CCM+ 3 July 11, 2012 02:46
Getting OpenFOAM to coexist with an existing JAVA VM nik777 OpenFOAM Installation 5 February 22, 2007 08:21


All times are GMT -4. The time now is 20:24.