|
[Sponsors] |
[DesignModeler] DesignModeler Scripting: How to get Full Command Access |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
July 23, 2012, 12:13 |
DesignModeler Scripting: How to get Full Command Access
|
#1 | |||
New Member
Join Date: Jun 2012
Posts: 17
Rep Power: 14 |
I've spent the past several days trying to understand the DesignModeler Script programming interface in order to automate some very iterative geometry generation, which has been quite the difficult process since the Help documentation (DesignModeler User Guide > Scripting API) provides an extremely limited explanation of only a few basic functions. It limits what you can do to only a few batch commands like generating points, planes, sketches, etc., and is missing some pretty essential functions (e.g. how does one generate a Boolean? How does one select objects? How does one create a Named Selection, and how does one choose what goes in the named selection?).
This API also mentions parameters for which the creation/selection commands are undocumented (e.g. explanation of the agb.Sweep(...) command states that it can accept a Named Selection as a Profile or Path parameter, but does not explain how a Named Selection can be specified or generated). Moreover, most tutorials/forum posts on the matter describe only JScript programming for the Workbench/Mechanical environments, which are difficult to follow and simply do not apply to the different API/commands required for DesignModeler. I noticed that the help documentation instructs users to use the "agc." prefix for "Script Constants" (e.g. agc.Yes, agc.Frozen, agc.TypeEdge3d, etc.) and the "agb." prefix for "application functions": Quote:
Quote:
In the same folder as agInterop.js exists a file called agConstants.js, in which you can see that the 9 script constants are just a small subset of the many, many more that exist. Searching for "ag." in the ANSYS directory yields the useful file "agEventHandler.js" which is full of useful commands. Below are a few of the categories of these commands: ag.gb.* --> Graphics Handler/Service ("AgmService") commands ag.gui.* --> GUI commands (GUIModeler), a command for every button shown in DesignModeler (for example ag.gui.AddSketch() and ag.gui.CreatePlane() ), and some others ag.m.* --> Modeler, Main, or Menu (?) commands (e.g. ag.m.SuppressBody(), ag.m.DisplayBodyErrors(...), etc.) Since I just found this, I'm still trying to dig around and learn how to use all of this, but I thought I'd post here since I haven't found anything online that describes these extra functions & where they're at least named within .js files in the ANSYS directory. However, below is an example of a useful way to generate first a separate named selection for each edge in a group (with sequential Face IDs, generated e.g. via AddSegment(...) method on a LinePt() instance; total number defined by numLines, which we assume has been assigned already), and then a named selection that contains all of the edges: Code:
for (var i = 1; i<= numLines; i++) { ag.gui.ClearSelect(); //Clears the selection ag.b.AddSelectEdgeID(i); //Picks the edge ID corresponding to i on each iteration of the for-loop ag.gui.CreateSelectionSet(); //Generates the Named Selection from selection (the one line) } ag.gui.ClearSelect(); //Clears the selection for (var i = 1; i <= numLines; i++) { ag.b.AddSelectEdgeID(i); //Adds all of the edges with edge IDs 1 through numLines to selection } ag.gui.CreateSelectionSet(); //Generates the Named Selection from selection (the group of lines) Edit: List of Global Handles (from agMain.js file) // The most noteworthy global handles are: // ag.wb ....................... WorkBench object // ag.silent ................... No popup messages if set to true // ag.guiScript ................ A pointer to <this> scripting engine // ag.fs ....................... Scripting.FileSystemObject // ag.regName .................. Applet's (registry) name // ag.regNameDS ................ DesignSpace Applet's (registry) name // ag.installDir ............... InstallDir path // ag.pagesDir ................. Pages directory // ag.stringTable .............. Localized stringtable // ag.imageList* ............... The imagelist(s) // ag.runnigScriptPath ......... See agRunScript(.) // ag.m ........................ AGP's Modeler object // ag.fm ....................... AGP's FeatureMgr object // ag.b ........................ AGP's BatchMgr object // ag.WB2....................... True if launched from WB2 // ag.gui ...................... AGP's GUIModeler object // ag.gb ....................... AGP's GfxService object // ag.fromDS ................... true iff started from DS // ag.cursorWaitCounter......... counter, 0 when not waiting // ag.printPreviewTabClicked.... true when user clicks Print Preview tab // ag.printPreviewActive........ true when Print Preview Window is active Searching within files in the ANSYS install directory with selections from this (like "ag.gui." or "ag.m.") will probably get you some useful results. Edit 2: This file (agMain.js) also includes: Quote:
Last edited by ANT; July 23, 2012 at 14:24. |
||||
May 28, 2014, 10:42 |
some more "revrse engineering"....
|
#2 |
New Member
Alexander
Join Date: May 2014
Posts: 7
Rep Power: 12 |
I've used "ole/com object viewer" from Microsoft Visual Studio SDK (OleView.exe) and inspected Type Libraries from
Ans.Modeler.AppletCOM.dll Ans.Modeler.ObjectsCOM.dll located at "C:\Program Files\ANSYS Inc\v150\aisol\bin\winx64\" Refer to IAnsBatchMgr Interface definition for all ag.b functions available. Same thing with IAnsGUIModeler and its ag.gui JScript analog. There are sooo many other interesting things (not documented yet)! But it's good enough source for those who has programmer experience. And....it works! Some examples: Code:
// ag.wb........................IWB // ag.agApplet................IAGApplet // ag.m ........................IAnsGeomModeler // ag.fm .......................IAnsFeatureMgr // ag.b .........................IAnsBatchMgr // ag.gui .......................IAnsGUIModeler // ag.gb ........................IAnsGfxService //------------------------------------------------------------------------------------ // browse the body list for (var i = 0; i < ag.fm.BodyCount; i++) { var f1=ag.fm.body(i); //это объект IAnsBody ag.gui.DisplayWarning("Body "+i+" has" +"\nName="+f1.Name +"\nVolume="+f1.Volume +"\nfaces="+f1.faces +"\nEdges="+f1.Edges +"\nVertices="+f1.Vertices +"\nSeqNumber="+f1.SeqNumber +"\nPartId="+f1.PartId +"\nLabel="+f1.Label ); } // browse the feature list (operations) for (var i = 0; i < ag.fm.FeatureCount; i++) { var f1=ag.fm.Feature(i); ag.gui.DisplayWarning("Feature "+i+" has "+f1.NumChildren+" childs and" +"\nFeatureID="+ag.fm.FeatureID(f1) +"\nFeatureType="+strFType(f1.FeatureType()) ); for (var ii = 0; ii < f1.NumChildren; ii++) { var ff1=f1.Child(ii); ag.gui.DisplayWarning("Feature "+i+"."+ii+" has" +"\nFeatureID="+ag.fm.FeatureID(ff1) +"\nFeatureType="+strFType(ff1.FeatureType()) ); } } //------------------------------------------------------------------------------------ // useful function to understand the FeatureType() function strFType(ft) { var sName="undefined"; switch(ft) { case 2001: sName="ANS_FEATURE_PLANE ";break; case 2002: sName="ANS_FEATURE_SKETCH ";break; case 2003: sName="ANS_FEATURE_EXTRUDE ";break; case 2004: sName="ANS_FEATURE_REVOLVE ";break; case 2005: sName="ANS_FEATURE_BLEND ";break; case 2006: sName="ANS_FEATURE_FBLEND ";break; case 2007: sName="ANS_FEATURE_VBLEND ";break; case 2008: sName="ANS_FEATURE_CHAMFER ";break; case 2009: sName="ANS_FEATURE_SWEEP ";break; case 2010: sName="ANS_FEATURE_SKIN ";break; case 2011: sName="ANS_FEATURE_WIRE ";break; case 2012: sName="ANS_FEATURE_UNFREEZE ";break; case 2013: sName="ANS_FEATURE_FREEZE ";break; case 2014: sName="ANS_FEATURE_PART ";break; case 2015: sName="ANS_FEATURE_IMPORT ";break; case 2016: sName="ANS_FEATURE_ATTACH ";break; case 2017: sName="ANS_FEATURE_DELETE_FACES ";break; case 2018: sName="ANS_FEATURE_ROLLMARK ";break; case 2019: sName="ANS_FEATURE_SHELL ";break; case 2020: sName="ANS_FEATURE_SPOT ";break; case 2021: sName="ANS_FEATURE_SLICE ";break; case 2022: sName="ANS_FEATURE_BODYOP ";break; case 2023: sName="ANS_FEATURE_WIRETOOL ";break; case 2024: sName="ANS_FEATURE_LINEPT ";break; case 2025: sName="ANS_FEATURE_LINESK ";break; case 2026: sName="ANS_FEATURE_LINEED ";break; case 2027: sName="ANS_FEATURE_SELECTION_SET ";break; case 2028: sName="ANS_FEATURE_JOINT ";break; case 2029: sName="ANS_FEATURE_SURFACE_EXT ";break; case 2030: sName="ANS_FEATURE_SKETCH_INSTANCE";break; case 2031: sName="ANS_FEATURE_ENCLOSURE ";break; case 2032: sName="ANS_FEATURE_SURFACE_PATCH ";break; case 2033: sName="ANS_FEATURE_SURF_SK ";break; case 2034: sName="ANS_FEATURE_MIDSURF ";break; case 2035: sName="ANS_FEATURE_FILL ";break; case 2036: sName="ANS_FEATURE_CURVE ";break; case 2037: sName="ANS_FEATURE_PATTERN ";break; case 2038: sName="ANS_FEATURE_WINDING ";break; case 2039: sName="ANS_FEATURE_SAMPLE ";break; case 2040: sName="ANS_FEATURE_IC_MANAGER ";break; case 2041: sName="ANS_FEATURE_IC_POSTMGR ";break; case 2042: sName="ANS_FEATURE_IC_PRE_MANAGER ";break; case 2043: sName="ANS_FEATURE_PRIMITIVE ";break; case 2044: sName="ANS_FEATURE_THIRDPARTY ";break; case 2045: sName="ANS_FEATURE_SYMMETRY ";break; case 2046: sName="ANS_FEATURE_SOLID_EXT ";break; case 2047: sName="ANS_FEATURE_SHELLPRIMITIVE ";break; case 2048: sName="ANS_FEATURE_BOOLEAN ";break; case 2049: sName="ANS_FEATURE_VERTEX_BLEND ";break; case 2050: sName="ANS_FEATURE_UNIVERSE ";break; case 2051: sName="ANS_FEATURE_LATTICE ";break; case 2052: sName="ANS_FEATURE_SKETCH_PROJECT ";break; case 2053: sName="ANS_FEATURE_FLIP ";break; case 2054: sName="ANS_FEATURE_CYCLIC_SYMMETRY";break; case 2055: sName="ANS_FEATURE_MERGE ";break; case 2056: sName="ANS_FEATURE_CONNECT ";break; case 2057: sName="ANS_FEATURE_REPAIR ";break; case 2058: sName="ANS_FEATURE_ATTRIBUTE ";break; case 2059: sName="ANS_FEATURE_FINALIZE ";break; case 2060: sName="ANS_FEATURE_PROJECTION ";break; case 2061: sName="ANS_FEATURE_DELETE_EDGES ";break; case 2062: sName="ANS_FEATURE_ICESIMPLIFY ";break; case 2063: sName="ANS_FEATURE_ICEFAN ";break; case 2064: sName="ANS_FEATURE_ICEOPENING ";break; case 2065: sName="ANS_FEATURE_CONVERSION ";break; case 2066: sName="ANS_FEATURE_SURF_FROM_FACES";break; case 2067: sName="ANS_FEATURE_FACE_SPLIT ";break; case 2068: sName="ANS_FEATURE_ICEGRILLE ";break; case 2069: sName="ANS_FEATURE_SHAFT ";break; case 2070: sName="ANS_FEATURE_FEATURE_GROUP ";break; case 2071: sName="ANS_FEATURE_ICEENCLOSURE ";break; } return sName; } // Also we can use Tree control for browsing // ag.mROOT = "-*ROOT*-"; // ag.bROOT = "-*BODYROOT*-"; // ag.cROOT = "-*SECTIONROOT*-"; // ag.uROOT = "-*UNIVERSEROOT*-"; //--------------------------------------------------------------------------- // ag.tree ................ IWBTreeViewCtrl browseDown(ag.tree.Nodes(ag.mROOT),0); function browseDown(node,level) { var myNode=node; // IWBTreeNode while(myNode != null) { ag.m.DisplayMessage("Node level "+level+ "\nText ="+myNode.Text+ "\nKey = "+myNode.Key,0); if(myNode.Children>0) browseDown(myNode.Child,level+1); myNode = myNode.Next; } } Last edited by BaoBab; June 6, 2014 at 05:42. |
|
June 6, 2014, 04:59 |
|
#3 |
New Member
Yavuz Hes
Join Date: Jun 2014
Posts: 2
Rep Power: 0 |
It's nice to see a recent update on the most visited page after searches like "Design Modeler Scripting API" . Both contributions help a lot. Thank you very much.
|
|
June 6, 2014, 05:35 |
Sample script
|
#4 |
New Member
Alexander
Join Date: May 2014
Posts: 7
Rep Power: 12 |
Here is some practical example on DModeler usage:
Task is: 1) load external CAD body 2) draw the surface under it using its bounds Code:
// start from clear scratch ag.gui.NewFile(); ag.m.ClearAllErrors(); ag.m.NewSession (true); ag.gui.setUnits(ag.c.UnitMillimeter, ag.c.UnitDegree, ag.c.No); // import file var imp1=ag.b.Import("myFile.igs"); // IAnsImport imp1.Name="CAD_geom"; imp1.Operation=ag.c.Frozen; imp1.PutBasePlane(ag.b.GetXYPlane()); ag.b.Regen(); ag.gui.ZoomFit(); // get the actual model bounds var medges=ag.m.ModelEdges(); // IAnsEdges3D var maxX=0, minX=0 , maxY=0, minY=0 , maxZ=0, minZ=0; for(var i=1;i<= medges.Count;i++) { var eg=medges.Item(i); // IAnsEdge3D if(eg.EdgeCoord(0)>maxX) maxX=eg.EdgeCoord(0); if(eg.EdgeCoord(0)<minX) minX=eg.EdgeCoord(0); if(eg.EdgeCoord(1)>maxY) maxY=eg.EdgeCoord(1); if(eg.EdgeCoord(1)<minY) minY=eg.EdgeCoord(1); if(eg.EdgeCoord(2)>maxZ) maxZ=eg.EdgeCoord(2); if(eg.EdgeCoord(2)<minZ) minZ=eg.EdgeCoord(2); } // create scetch object var bX=(maxX+minX)/2.0*1e3; // EdgeCoord() gives "m" but we need 'mm' var bY=(maxY+minY)/2.0*1e3; var lX=Math.abs(maxX-minX)*1e3+4; // add 2 mm to each bound var lY=Math.abs(maxY-minY)*1e3+4; var skPlane = ag.b.GetXYPlane(); // IAnsPlane var Sk1 = skPlane.NewSketch(); // IAnsSketch Sk1.Name = "base_sketch"; Sk1.Line(bX-lX/2.0, bY-lY/2.0, bX+lX/2.0, bY-lY/2.0); Sk1.Line(bX+lX/2.0, bY-lY/2.0, bX+lX/2.0, bY+lY/2.0); Sk1.Line(bX+lX/2.0, bY+lY/2.0, bX-lX/2.0, bY+lY/2.0); Sk1.Line(bX-lX/2.0, bY+lY/2.0, bX-lX/2.0, bY-lY/2.0); // NOTE how to select sketch before CreateSurfSk feature !!! ag.selectedFeature = ag.gui.TreeviewFeature(Sk1.Name, 0); var SSk1=ag.gui.CreateSurfSk(); // IAnsFSurfSk SSk1.Name="ERI_base"; SSk1.Operation=ag.c.Frozen; SSk1.WithPlaneNormal=ag.c.Yes; |
|
July 28, 2014, 09:26 |
Design Modeler listing operations of a selected object
|
#5 |
New Member
Join Date: Jul 2014
Posts: 1
Rep Power: 0 |
Thanks guys for posting these, its valuable for scripting enthuse persons. I have 1 questions in the field of Design Modeler not sure how to get into it. How can we list down all the operations (like Boolean, body operations etc.) performed on a selected object?
|
|
July 30, 2014, 06:11 |
|
#6 | |
New Member
Alexander
Join Date: May 2014
Posts: 7
Rep Power: 12 |
Quote:
In regard to selected objects which were used for the feature creation, I can get the total number (own property in each feature), but not object handles. |
||
August 9, 2014, 03:10 |
|
#7 |
Member
Join Date: Oct 2011
Posts: 36
Rep Power: 15 |
Hello Alexander,
you seem to have some experience with JSript quirks of DesignModeler, maybe you can enlighten me :-) My task is actually pretty simple. I'd like to create a sketch, consisting of three lines (bottom, left, right) and an arc (top). At the intersections of the arc with the left and right line, fillets with a 3mm radius shall be created. What I have so far: Code:
function planeSketch (p) { p.Plane = agb.GetYZPlane(); p.Origin = p.Plane.GetOrigin(); p.XAxis = p.Plane.GetXAxis(); p.YAxis = p.Plane.GetYAxis(); p.Sk = p.Plane.newSketch(); p.Sk.Name = "TEST"; with (p.Sk) { p.Ln1_1 = Line(x1, y1, x2, y2); // bottom p.Ln1_2 = Line(x2, y2, x3, y3); // right p.Ln1_3 = ArcCtrEdge(xCtr, yCtr, x3, y3, x4, y4); // arc p.Ln1_4 = Line(x4, y4, x1, y1); // left p.Ln1_5 = Fillet(p.Ln1_2, selx1, sely1, p.Ln1_3, selx2, sely2, 3., agc.Yes); // right fillet p.Ln1_6 = Fillet(p.Ln1_3, selx1, sely1, p.Ln1_4, selx2, sely2, 3., agc.Yes); // left fillet } } var ps = planeSketch (new Object()); agb.Regen(); Do you have any ideas what's causing this behavior? Best regards, Victor |
|
August 13, 2014, 08:02 |
IAnsSketch::Fillet() fail error
|
#8 |
New Member
Alexander
Join Date: May 2014
Posts: 7
Rep Power: 12 |
Here is the definition of IAnsSketch::Fillet() from Ans.Modeler.ObjectsCOM.dll :
Code:
[id(0x0000006c), helpstring("Creates a round corner between two curves. Locations and switches determine if and how to trim")] HRESULT Fillet( [in] IAnsEdge* edge1, [in] double selPt1_x, [in] double selPt1_y, [in] IAnsEdge* edge2, [in] double selPt2_x, [in] double selPt2_y, [in] double Radius, [in] int trim, [out, retval] IAnsEdge** newFilletId); The following code works good but the second fillet extra edges are not trimmed (do not know why): Code:
// Plane sketch var myPlane=agb.GetXYPlane(); var Sk1 = myPlane.NewSketch(); //Sk1.Name = "Sketch1"; // Points location var x_low=-5.0; var x_high=15.0; var y_low=-1.0; var y_high=19.0; var x_arc=(x_low+x_high)/2; var y_arc=4.0; var r_arc=Math.sqrt((x_high-x_arc)*(x_high-x_arc)+(y_high-y_arc)*(y_high-y_arc)); //Edges var bottomLn = Sk1.Line(x_low, y_low, x_high, y_low); var leftLn = Sk1.Line(x_low, y_low, x_low, y_high); var rightLn = Sk1.Line(x_high, y_low, x_high, y_high); var anArc= Sk1.ArcCtrEdge(x_arc, y_arc, x_high, y_high, x_low, y_high); var filArc1=Sk1.Fillet( leftLn, x_low, y_high-0.5, anArc, x_arc, y_arc+r_arc, 3.0, 4); var filArc2=Sk1.Fillet( rightLn, x_high, y_high-0.5, anArc, x_arc, y_arc+r_arc, 3.0, 4); agb.Regen(); As you can also see the special object wrapper around shape construction (as in "WriteScript:Sketches" command) is optional. |
|
September 2, 2014, 04:48 |
command geometry generation based on Ansys functions
|
#9 |
New Member
Join Date: Apr 2013
Posts: 5
Rep Power: 13 |
Hello Guys,
Really useful info... thanks Is there any way to get this command geometry generation based on Ansys functions automatically from Ansys? I mean I generate my 3D model in Design Modeler GUI, but I want to export it in text command style not in .agdb format, So I can modify the geometry by modifying the command text file. Thanks |
|
September 2, 2014, 05:42 |
|
#10 |
New Member
Join Date: Sep 2012
Posts: 26
Rep Power: 14 |
Hello HA11,
unfortunately you can't let ANSYS generate such a file, you will have to write it on your own. The only thing that works automatically are sketches. Greets Nigirim |
|
September 3, 2014, 05:05 |
JScript-Python-APDL interconnection
|
#11 | |
New Member
Alexander
Join Date: May 2014
Posts: 7
Rep Power: 12 |
Quote:
1) there is a JScript for DM (let say "geom.js") which creates the model geometry and then export geometry into IGES/STEP. 2) there is the IronPython script (let say "update_geom.wbjn") for WB to open/create a project, insert "geometry" template, open it and run geom.js file there. 3) there is APDL-script (let say "import_geom.inp") to import IGES/STEP in ANSYS APDL. 4) there is system BAT-file to run WB in batch mode with update_geom.wbjn as the parameter and then the ANSYS APDL in GUI mode with import_geom.inp as the parameter. Here is the wbjn-code snippet Code:
# encoding: utf-8 SetScriptVersion(Version="12.5") Reset() # this is to log errors in external file import clr clr.AddReference("System.Windows.Forms") import System.Windows.Forms as WinForms logPath="log_file.log" logFile = open(logPath, "w") errNum = 0 try: # in case we need Static Structural further template1 = GetTemplate(TemplateName="Static Structural", Solver="ANSYS") # open geometry geometry1 = system2.GetContainer(ComponentName="Geometry") geometry1.Edit() geometry1.SendCommand( Command = """ myParams = new Object(); myParams.fName = "some_data_file_if_needed_in_script.txt"; var scriptPath="geom_script.js"; runIt(scriptPath); # need this to run JScript inside DM properly function runIt(path) { ag.m.BeginUserScript(); try{ ag.runningScriptPath = path; ag.wb.ScriptEngine.AddNamedItem ("ag", ag); ag.wb.ScriptEngine.AddNamedItem ("myParams", myParams); ag.wb.ScriptEngine.RunScript(path); } catch(e){ag.m.DisplayMessage("Error in JScript-> " +path,2);} ag.m.EndUserScript(); } """) geometry1.Update() except Exception, err: logFile.write("Error:\n%s\n\n" % err) errNum=errNum+1 # save project if needed Save( FilePath="project_file.wbpj", Overwrite=True) # log all the WB messages for msg in GetMessages(): msgString =msg.MessageType + ":\n" + msg.Summary + "\n\n" logFile.write(msgString) logFile.close() if errNum > 0: WinForms.MessageBox.Show("some text about log-file created:\n%s" % logPath, "Error caption") |
||
September 22, 2014, 10:20 |
about command line in designmodeler
|
#12 |
New Member
Shuai Shao
Join Date: May 2011
Location: Xi'an, Shaanxi, China
Posts: 6
Rep Power: 15 |
Helle everyone! I need to use DesignModeler to conduct a multidisciplinary optimiziation for a radial-inflow turbine rotor. But I came across several problems:
This figure shows what I do through the DesignModeler Graphic user interface, I import a .BGD file which is generated from the BladeGen module firstly, and then I conduct Blend and Cut material. I have a lot of different but similar .BGD files, so what I want to do is changing the ImportBGD1 item in the Tree Outline (red rectangle). And change the ImportBGD1 item to another .BGD file like the figure shows below. And Generate at last, then all the steps will be carried out on the new .BGD object. I have tried through the Graphic user interface and succeed. Now I hope all of these can be conducted through the js script. I look for some command lines for the DesignModeler, but I can not find the command correspond to the “replace the ImportBGD1 item”. I attach the workbench project files below (http://yun.baidu.com/share/link?shar...2&uk=654753982), and hope you guys can help me! Thank you very much! I thought the command may be ag.GUI.CreateImportBGD('file path'), but it is not. In the dir: v145\aisol\BladeModeler\BladeEditor\BMPages\script s, there is a bmScriptInt.js file, and a function called CreatImportBGD(), how to use it? Last edited by uqzcpo; September 22, 2014 at 11:29. Reason: show the figure |
|
September 23, 2014, 03:50 |
|
#13 |
New Member
Alexander
Join Date: May 2014
Posts: 7
Rep Power: 12 |
Unfortunately I have no blade generator and corresponded DM import plug-in installed. However, I have found that the BGD-import feature has IAnsFThirdPartyHost object type.
The IAnsFThirdPartyHost does not support any 'source geometry' property (like IAnsImport::SourceName), but, maybe SetParameter() function can be helpfull: Code:
HRESULT SetParameter( [in] BSTR propname, [in] BSTR dimName, [in] BSTR typeName, [in] BSTR minDef, [in] BSTR minVal, [in] BSTR maxDef, [in] BSTR maxVal, [in] BSTR paramName, [in] VARIANT_BOOL checked); |
|
October 30, 2014, 07:21 |
|
#14 |
Member
Join Date: Oct 2011
Posts: 36
Rep Power: 15 |
Hello all,
my JScript file generating all the geometric entities and named selections for further use in CFX Pre is done. To get there, I had to implement a variety of ag.gui.CreateXYZ and other ag.gui commands. I bet you all know the feeling, when, after a long time of trying different things, something is finally working... I'm on Linux, so I run "runwb2 -B -R geometry.wbjn" with the following journalfile: Code:
# encoding: utf-8 SetScriptVersion(Version="15.0") template1 = GetTemplate(TemplateName="Geometry") system1 = template1.CreateSystem() geometry1 = system1.GetContainer(ComponentName="Geometry") geometry1.Edit(Interactive="True") script = open('/path/to/my/script.js', 'r') geometry1.SendCommand(Command=script.read()) Save( FilePath=GetAbsoluteUserPathName("/path/to/my/project.wbpj"), Overwrite=True) geometry1.Exit() So far, so good... Unfortunately, the final project is supposed to be running on a HPC system entirely without GUI. So, when I test the script in Terminal Mode (Ctrl-Alt-F1), apart from the error message "Cannot open x display (not specified)", I get a script error message regarding the ag.gui code snippets. It makes sense to me, because all those ag.gui objects depend on the gui stuff being loaded. And that's not going to happen when there is window. What I thought about is to pipe the request for a display to another, virtual display which does not need to pop up. Maybe one of you has already run into that wall and figured out how to tear it down Best regards ================= Solution: Solved the problem using TightVNC. Step 1: Create virtual display Code:
vncserver -geometry 1920x1080 :10 Code:
export DISPLAY=:10 Code:
runwb2 -B -R geometry.wbjn Last edited by vigges; October 30, 2014 at 09:12. Reason: Problem Solved!! |
|
March 25, 2015, 09:15 |
3D curve
|
#15 |
New Member
SG
Join Date: Jan 2015
Posts: 29
Rep Power: 11 |
Hi.
Do you know if it is possible to write a script to import a 3D curve? EDIT: This seems to do the job: var NL1 = ag.gui.CreateCurve(); NL1.Name = "Name"; NL1.CoordinateFile = "FilePath"; But now I have a problem as I am trying to script a skin feature between the curves. Does anyone know how to select 3D curves with the script? I guess I can use this command to create the feature: agb.Skin(agc.Add, agc.No, 0.0, 0.0), but I haven't figured out how to select the profiles. Last edited by stessigunn; March 26, 2015 at 10:15. |
|
May 22, 2015, 14:39 |
|
#17 |
Member
Join Date: Oct 2011
Posts: 36
Rep Power: 15 |
Hey guys,
does anybody happen to know how to access the entities stored in a Named Selection within DesignModeler? All I've been able to accomplish sofar was to get the count of stored entities. Have a nice weekend! |
|
May 24, 2015, 19:39 |
|
#18 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
Hi Victor,
Yes, You can access entities stored in NS Could you please elaborate your question bit more? and also post your code you have got so far? Cheers KAPI |
|
May 25, 2015, 11:24 |
|
#19 |
Member
Join Date: Oct 2011
Posts: 36
Rep Power: 15 |
Hello KAPI,
I processed all faces in my multi part model and assigned them to their respective NSs, i.e. Part1ToPart2 and Part2ToPart1 which contain faces Part1 and Part2 have in common. In a further step I'd like to refine this selection, like Part1ToPart2Axial (and vice versa) and Part1ToPart2Circumferential (and vice versa). For that, I'd like to consider only the faces already assigned to the base selections Part1ToPart2 (and vice versa). But I lack the knowledge how to "grab" the items of one NS. This is how I create the NS objects: Code:
Part1ToPart2 = ag.gui.CreateSelectionSet(); Part1ToPart2.AddFace(ag.m.ModelFaces().Item(i)); Thanks for your input. Best regards, Victor |
|
May 25, 2015, 20:46 |
|
#20 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
Hi Victor,
Try to use the below code to pick NS and see if it works Code:
agb.AddSelect(agc.TypeFace, Part1ToPart2); ag.b.Regen(); Code:
ag.facePick; Cheers KAPI |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Rotor 67 full compressor geometry | jf | Main CFD Forum | 3 | January 28, 2024 06:14 |
[ICEM] ICEM Scripting Issues | tylerplowright | ANSYS Meshing & Geometry | 33 | September 27, 2021 17:35 |
Physical size of geometry in DesignModeler | Michael Rasmussen | CFX | 9 | June 16, 2017 04:27 |
[DesignModeler] find features of Gambit in DesignModeler | code_source | ANSYS Meshing & Geometry | 13 | April 30, 2014 08:33 |
[Other] exchange of parameter values between TurboGrid and DesignModeler in Workbench | la7low | ANSYS Meshing & Geometry | 2 | February 21, 2011 16:12 |