|
[Sponsors] |
February 25, 2014, 06:44 |
Designmodeler java scripting
|
#1 |
New Member
Join Date: Feb 2014
Posts: 2
Rep Power: 0 |
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 |
|
February 25, 2014, 09:06 |
|
#2 |
Senior Member
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20 |
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();"") 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. |
|
February 25, 2014, 10:06 |
|
#3 | |
New Member
Join Date: Feb 2014
Posts: 2
Rep Power: 0 |
Quote:
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 |
||
February 26, 2014, 05:29 |
|
#4 |
Senior Member
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20 |
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. |
|
November 4, 2014, 12:17 |
|
#5 |
New Member
Luke
Join Date: Nov 2012
Location: italy
Posts: 24
Rep Power: 14 |
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?? |
|
November 12, 2014, 20:53 |
|
#6 | ||
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
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:
Quote:
Hope this solves your problem! Cheers Kapi |
|||
November 18, 2014, 05:06 |
|
#7 |
New Member
Luke
Join Date: Nov 2012
Location: italy
Posts: 24
Rep Power: 14 |
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! |
|
April 20, 2015, 03:13 |
|
#8 |
New Member
narjisse
Join Date: Apr 2015
Posts: 5
Rep Power: 11 |
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! |
|
April 20, 2015, 03:24 |
|
#9 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
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 |
|
April 21, 2015, 03:25 |
|
#10 |
New Member
narjisse
Join Date: Apr 2015
Posts: 5
Rep Power: 11 |
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, |
|
April 21, 2015, 20:34 |
|
#11 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
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() 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" Cheers KAPI |
|
September 11, 2019, 19:17 |
|
#12 | |
New Member
Vishal Chauhan
Join Date: Jan 2012
Posts: 14
Rep Power: 14 |
Hi Kapi,
your suggestions really helped me a lot for my work. As of now, I have implemented what you have suggested to create 3D curve from scratch (using its coordinates) using script. But, now what I am trying to do is to open existing .wbpj file then open Design modeler and then edit coordinates of existing 3D curve (everything using script). I have tried to do some tricks like trial and error but till now no success. Would you please give some suggestions on this? Thanks a lot. Quote:
|
||
September 13, 2019, 09:25 |
|
#13 |
Member
Dimitrios S. P.
Join Date: Jan 2018
Posts: 63
Rep Power: 8 |
Good day everyone,
is there a good guide for the design modeler scripting? I need one that describes functions that do not exist in Ansys HELP. I have tried to reverse enginnering some .dll files of design modeler, but the effrot was unsuccessful. |
|
October 16, 2019, 17:19 |
|
#14 | |
New Member
Justin
Join Date: Jan 2015
Posts: 28
Rep Power: 11 |
Quote:
You saved me much frustration! I manually setup DM that has an external CAD file import along with 2 3D curves (by file). During my iterative process, the initial CAD and curve files get overwritten and I then I simply need to refresh them to reload the new file contents. Here is what I ended up with that worked: Code:
var NodeName = "Import1"; // Name of the import feature var NodeName2 = "Curve1"; //Name of 3d curve feature var NodeName3 = "Curve2"; //Name of 3d curve feature // Loop through the existing features and select the required ones var count = ag.fm.FeatureCount; var num1 = 0; var Yes = agc.Yes; for (var i = 0; i < count; i++) { var current = ag.fm.Feature(i); var Name = current.Name; if (Name.toLowerCase() == NodeName.toLowerCase()) { // found the match current.Refresh = Yes; // Refresh the Geometry num1 += 1; } else if (Name.toLowerCase() == NodeName2.toLowerCase()) { current.CurveRefresh = Yes; num1 += 1; } else if (Name.toLowerCase() == NodeName3.toLowerCase()) { current.CurveRefresh = Yes; num1 += 1; } else if (num1 == 3) { break; } } agb.regen(); Code:
current.Refresh = Yes; Code:
current.CurveRefresh = Yes; |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro scripting in netbeans, importing star libraries | laurensvd | STAR-CCM+ | 3 | October 31, 2020 23:06 |
[DesignModeler] DesignModeler Scripting: How to get Full Command Access | ANT | ANSYS Meshing & Geometry | 53 | February 16, 2020 16:13 |
record actions via scripting | Marabelle | ANSYS | 0 | July 31, 2013 12:57 |
Macro to access java files in sub-directory | abraum | STAR-CCM+ | 3 | July 11, 2012 03:46 |
Getting OpenFOAM to coexist with an existing JAVA VM | nik777 | OpenFOAM Installation | 5 | February 22, 2007 08:21 |