|
[Sponsors] |
[DesignModeler] Scripting suppression of Features in DesignModeler |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
January 15, 2015, 12:23 |
Scripting suppression of Features in DesignModeler
|
#1 |
New Member
Mark
Join Date: Dec 2011
Posts: 4
Rep Power: 14 |
I'm trying to script the suppression/unsuppression of features (not bodies) in DesignModeler using agFeatureHandler. I have found how to do this for bodies, but I now need to apply it to features (i.e. Skin; BodyOp; etc...).
I've tried using the following to select and then suppress a feature, but this approach only seems to work on bodies var myFeature = ag.agApplet.FeatureMgr.feature(i); myFeature.setSuppression(true); Any ideas would be appreciated... Thanks Mark |
|
January 18, 2015, 22:49 |
|
#2 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
Hi Maw,
You may search "ag.m." in your installed Ansys directory and you will find lot many files. Under "agEventHandler.js" file you will find something called Code:
function agTreeHandler (eventName, eventID) I reckon you can get some help from there. Cheers KAPI |
|
March 5, 2015, 13:22 |
Suppress Bodies in Script
|
#3 |
New Member
Apostolos
Join Date: Feb 2013
Posts: 4
Rep Power: 13 |
Hi Mark,
Could you please provide some help? I am new in DM scripting. I have managed to create the five surfaces describing my simple 2D model, but before my script is finalised I need to implement two more steps. a) Suppress a line body b) Form a new part from the five surfaces (all existing parts). From your comment it seems you are familiar with a). If you could help with either of those I would appreciate it. Regards, Apostolos MY WORKING JOURNAL var LargestArray = 102; //Manually insert a value larger than the size of the largest curve var PF1 = agb.FPoint(agc.FPointConstruction, agc.FPointCoordinateFile); PF1.CoordinateFile = "/home/ttaas/Shared_Documents/Rolls-Royce_Concept-1/Diff-HX-Exit/2D-OPTIMISATION/Excel-Exports-for-ANSYS-Workbench/2D-DESIGN-OPTIMISATION-TOOL.txt"; agb.Regen(); //=============================== // Curves //=============================== var LF1 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF1.AddSegment (PF1.GetPoint(1, i), PF1.GetPoint(1, i+1), 1); } agb.Regen(); LF1.Name = "BezierCurveA"; var LF2 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF2.AddSegment (PF1.GetPoint(2, i), PF1.GetPoint(2, i+1), 2); } agb.Regen(); LF2.Name = "BezierCurveB"; var LF3 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF3.AddSegment (PF1.GetPoint(3, i), PF1.GetPoint(3, i+1), 3); } agb.Regen(); LF3.Name = "BezierCurveC"; var LF4 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF4.AddSegment (PF1.GetPoint(4, i), PF1.GetPoint(4, i+1), 4); } agb.Regen(); LF4.Name = "BezierCurveD"; var LF5 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF5.AddSegment (PF1.GetPoint(5, i), PF1.GetPoint(5, i+1), 5); } agb.Regen(); LF5.Name = "InletDown"; var LF6 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF6.AddSegment (PF1.GetPoint(6, i), PF1.GetPoint(6, i+1), 6); } agb.Regen(); LF6.Name = "LowerDuct"; var LF7 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF7.AddSegment (PF1.GetPoint(7, i), PF1.GetPoint(7, i+1), 7); } agb.Regen(); LF7.Name = "UpperDuct"; var LF8 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF8.AddSegment (PF1.GetPoint(8, i), PF1.GetPoint(8, i+1), 8); } agb.Regen(); LF8.Name = "hx1In"; var LF9 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF9.AddSegment (PF1.GetPoint(9, i), PF1.GetPoint(9, i+1), 9); } agb.Regen(); LF9.Name = "hx1Out"; var LF10 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF10.AddSegment(PF1.GetPoint(10, i), PF1.GetPoint(10, i+1),10); } agb.Regen(); LF10.Name = "hx2In"; var LF11 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF11.AddSegment(PF1.GetPoint(11, i), PF1.GetPoint(11, i+1),11); } agb.Regen(); LF11.Name = "hx2Out"; var LF12 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF12.AddSegment(PF1.GetPoint(12, i), PF1.GetPoint(12, i+1),12); } agb.Regen(); LF12.Name = "hx1Up"; var LF13 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF13.AddSegment(PF1.GetPoint(13, i), PF1.GetPoint(13, i+1),13); } agb.Regen(); LF13.Name = "hx1Down"; var LF14 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF14.AddSegment(PF1.GetPoint(14, i), PF1.GetPoint(14, i+1),14); } agb.Regen(); LF14.Name = "hx2Up"; var LF15 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF15.AddSegment(PF1.GetPoint(15, i), PF1.GetPoint(15, i+1),15); } agb.Regen(); LF15.Name = "hx2Down"; var LF16 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF16.AddSegment(PF1.GetPoint(16, i), PF1.GetPoint(16, i+1),16); } agb.Regen(); var LF17 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF17.AddSegment(PF1.GetPoint(17, i), PF1.GetPoint(17, i+1),17); } agb.Regen(); LF17.Name = "ExitDown"; var LF18 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF18.AddSegment(PF1.GetPoint(18, i), PF1.GetPoint(18, i+1),18); } agb.Regen(); LF18.Name = "ExitVain1Down"; var LF19 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF19.AddSegment(PF1.GetPoint(19, i), PF1.GetPoint(19, i+1),19); } agb.Regen(); LF19.Name = "ExitVain1Up"; var LF20 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF20.AddSegment(PF1.GetPoint(20, i), PF1.GetPoint(20, i+1),20); } agb.Regen(); var LF21 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF21.AddSegment(PF1.GetPoint(21, i), PF1.GetPoint(21, i+1),21); } agb.Regen(); LF21.Name = "ExitVain2Up"; var LF22 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF22.AddSegment(PF1.GetPoint(22, i), PF1.GetPoint(22, i+1),22); } agb.Regen(); LF22.Name = "ExitUp"; var LF23 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF23.AddSegment(PF1.GetPoint(23, i), PF1.GetPoint(23, i+1),23); } agb.Regen(); LF23.Name = "ExitOut"; var LF24 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF24.AddSegment(PF1.GetPoint(24, i), PF1.GetPoint(24, i+1),24); } agb.Regen(); var LF25 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF25.AddSegment(PF1.GetPoint(25, i), PF1.GetPoint(25, i+1),25); } agb.Regen(); var LF26 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF26.AddSegment(PF1.GetPoint(26, i), PF1.GetPoint(26, i+1),26); } agb.Regen(); LF26.Name = "InletUp"; var LF27 = agb.LinePt(); for ( var i=0; i<LargestArray; i++) {LF27.AddSegment(PF1.GetPoint(27, i), PF1.GetPoint(27, i+1),27); } agb.Regen(); LF27.Name = "InletChord"; agb.ClearSelections(); edge = LF1.GetEdge(1); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF2.GetEdge(2); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF3.GetEdge(3); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF4.GetEdge(4); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF5.GetEdge(5); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF6.GetEdge(6); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF7.GetEdge(7); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF8.GetEdge(8); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF9.GetEdge(9); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF10.GetEdge(10); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF11.GetEdge(11); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF12.GetEdge(12); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF13.GetEdge(13); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF14.GetEdge(14); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF15.GetEdge(15); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF16.GetEdge(16); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF17.GetEdge(17); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF18.GetEdge(18); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF19.GetEdge(19); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF20.GetEdge(20); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF21.GetEdge(21); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF22.GetEdge(22); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF23.GetEdge(23); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF24.GetEdge(24); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF25.GetEdge(25); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF26.GetEdge(26); agb.AddSelect(agc.TypeEdge3d, edge); agb.ClearSelections(); edge = LF27.GetEdge(27); agb.AddSelect(agc.TypeEdge3d, edge); agb.AddSelectEdgeID(1); agb.AddSelectEdgeID(6); agb.AddSelectEdgeID(5); agb.AddSelectEdgeID(27); agb.AddSelectEdgeID(2); agb.AddSelectEdgeID(10); var Surf1 = agb.SurfFromLines(); agb.Regen(); agb.AddSelectEdgeID(3); agb.AddSelectEdgeID(27); agb.AddSelectEdgeID(26); agb.AddSelectEdgeID(7); agb.AddSelectEdgeID(4); agb.AddSelectEdgeID(8); var Surf2 = agb.SurfFromLines(); agb.Regen(); agb.AddSelectEdgeID(13); agb.AddSelectEdgeID(8); agb.AddSelectEdgeID(12); agb.AddSelectEdgeID(9); var Surf3 = agb.SurfFromLines(); agb.Regen(); agb.AddSelectEdgeID(15); agb.AddSelectEdgeID(10); agb.AddSelectEdgeID(14); agb.AddSelectEdgeID(11); var Surf4 = agb.SurfFromLines(); agb.Regen(); agb.AddSelectEdgeID(17); agb.AddSelectEdgeID(21); agb.AddSelectEdgeID(11); agb.AddSelectEdgeID(18); agb.AddSelectEdgeID(19); agb.AddSelectEdgeID(9); agb.AddSelectEdgeID(22); agb.AddSelectEdgeID(23); var Surf5 = agb.SurfFromLines(); agb.Regen(); |
|
March 5, 2015, 18:30 |
|
#4 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
Hi Gafalos,
As I mentioned in my previous post, did you try to find "agEventHandler.js" and find the function to suppress or just came to ask the answer to your solution? I suggest you go there and spend 5 minutes of your time to understand the codesand if you are still not sure then ask question. You can make part of existing bodies Code:
var Prt1 = agb.FormNewPartFromAllBodies(); Code:
Prt1.Name ="Part1"; Hope it helps Cheers KAPI |
|
March 6, 2015, 05:46 |
Just an Update
|
#5 |
New Member
Apostolos
Join Date: Feb 2013
Posts: 4
Rep Power: 13 |
Hi again,
This is just an update, as I have managed to merge all the bodies in one part. Just added the following lines at the end of my code: var Surf6 = agb.FormNewPartFromAllBodies(); agb.Regen(); Still haven't found a way to suppress a body though. Anyone that can help? Thank you in advance, Apostolos |
|
March 6, 2015, 05:47 |
ooops
|
#6 |
New Member
Apostolos
Join Date: Feb 2013
Posts: 4
Rep Power: 13 |
Thank you Kapi,
Just saw your reply |
|
March 6, 2015, 06:50 |
|
#7 |
New Member
Apostolos
Join Date: Feb 2013
Posts: 4
Rep Power: 13 |
Hi KAPI,
First of all thank you very much for your indication of where to look. That really helps me clarify a little bit how things work. I have now had a look at the agEventHandler.js and the details of: function agTreeHandler (eventName, eventID). From this I expect that the command "agb.agTreeHandler (Part1, 702);" would suppress Part1, but it gives me an error. I would appreciate it if you could help me a little bit more on how to use this command. thank you in advance, Apostolos |
|
March 17, 2015, 21:05 |
|
#8 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
Hi gafalos,
What error are you getting? I have never used this function before but I guess You have to select "Part1" first then you may use something like this Taking your EventID as 702 Code:
// Perform the suppression if (ag.currentFeature) ag.gui.FeatureSuppression (eventID - 700); else if (ag.currentBodyGroup) { ag.currentBodyGroup.BodyGroupSuppression (eventID - 700); ag.gb.Redraw(ag.c.RedrawAll); } Try and this and let me know what you get! Hope it helps CHeers KAPI |
|
March 24, 2015, 04:29 |
Script curve
|
#9 |
New Member
SG
Join Date: Jan 2015
Posts: 29
Rep Power: 11 |
Hi.
I have never used scripting in DesignModeler but it could make me work a lot faster. I was wondering if it is possible to create 3D curves from coordinate files (i.e. I need to make a journal similer to the one gafalos posted above, but connect the points with curves)? I have managed to create lines between my coordinates but I need to have smooth curves. EDIT This seems to work: var NL1 = ag.gui.CreateCurve(); NL1.Name = "FileName"; NL1.CoordinateFile = "FilePath"; agb.Regen(); Last edited by stessigunn; March 26, 2015 at 04:22. |
|
March 26, 2015, 05:56 |
|
#10 |
New Member
SG
Join Date: Jan 2015
Posts: 29
Rep Power: 11 |
I figured out how I can import the curve, but now I have to connect the ends of two curves with a line. Any ideas how to do that?
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 12:10. |
|
March 29, 2015, 21:12 |
|
#11 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
Hi SG,
to create line joining your curve, you need coordinates. something like this will make line then curve and make a rectangle with curved edges. Code:
p.Ln1= Line(0.377565,0.07422,0.461705,0.07422); p.Cr3= ArcCtrEdge(0.460705,0.07622,0.461705,0.07422,0.462705,0.07522); p.Ln5= Line(0.462705,0.07522,0.462705,0.08442); p.Cr7= ArcCtrEdge(0.460705,0.08342,0.462705,0.08442,0.461705,0.08542); p.Ln9= Line(0.461705,0.08542,0.377565,0.08542); p.Cr11= ArcCtrEdge(0.378565,0.08342,0.377565,0.08542,0.376565,0.08442); p.Ln13= Line(0.376565,0.08442,0.376565,0.07522); p.Cr15= ArcCtrEdge(0.378565,0.07622,0.376565,0.07522,0.377565,0.07422); Code:
SM.ForceSelect(); Hope it helps, Cheers KAPI |
|
June 17, 2015, 08:58 |
|
#12 | |
Member
Max
Join Date: May 2015
Posts: 48
Rep Power: 11 |
I have several Line Bodies and one Solid. I only want to have the single solid and the Line Body's should be susspressed.
I also tried this code here: Code:
for (var i = 0; i < ag.fm.BodyCount-1; i++) { agb.agTreeHandler (Line_Body_PartID:(i), 701) } agb.Regen(); Quote:
Max |
||
June 17, 2015, 19:44 |
|
#13 | |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
Hi Max,
Quote:
Hope it helps Cheers KAPI |
||
June 18, 2015, 02:48 |
|
#14 |
Member
Max
Join Date: May 2015
Posts: 48
Rep Power: 11 |
I renamed my Line Bodies to Line_Body_PartIDi) ("i" is the counter in my for-loop) with this code in a for-loop before:
Code:
var f1=ag.fm.body(i); f1.Name = "Line_Body_PartID: "+f1.PartID But I will try a named selection as well! Best Regards Max |
|
June 18, 2015, 03:16 |
|
#15 | |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
Hi User,
what I meant was Quote:
Cheers KAPI |
||
July 13, 2015, 07:06 |
|
#16 |
New Member
Michelangelo
Join Date: Apr 2015
Posts: 17
Rep Power: 11 |
Hi User,
I created a group of 3Dcurve with command var NL1 = ag.gui.CreateCurve(); NL1.Name = "Curve1"; NL1.CoordinateFile = "..." now I want to use this curve to created a skin. how can I select the curve? |
|
July 13, 2015, 22:55 |
|
#17 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
Hi Mizor,
You can create skin by this code which you can change according to your use. Code:
var Skin1 = agb.Skin(agc.Add, agc.No, 0.0, 0.0); Skin1.Name = "Point2OvalSkin" Skin1.AddBaseObject(ps1.Sk1); Skin1.AddBaseObject(ps2.Sk2); Skin1.AddBaseObject(ps3.Sk3); Skin1.AddBaseObject(ps4.Sk4); agb.Regen(); ps1, ps2..: Planes of sketch Example: Code:
var XYPlane = agb.GetXYPlane(); agb.SetActivePlane (XYPlane); var ps1 = plane1SketchesOnly (new Object()); Example: Code:
p.Sk1 = p.Plane.newSketch(); p.Sk1.Name = "Sketch1"; Cheers KAPI |
|
July 14, 2015, 02:50 |
|
#18 |
New Member
Michelangelo
Join Date: Apr 2015
Posts: 17
Rep Power: 11 |
Hi Kapi,
Thanks for you reply, but I have curves that develop in 3D. I tried to use SM.ForceSelect(NL1) \\ NL1 name of curve but I have problem with SM (ERROR SM is undefined) my code is this var NL1 = ag.gui.CreateCurve(); NL1.Name = "Curve1"; NL1.CoordinateFile = "...."; var NL2 = ag.gui.CreateCurve(); NL2.Name = "Curve2"; NL2.CoordinateFile = "..."; ag.b.Regen(); var SK1 = agb.Skin(agc.Add, agc.No, 0.0, 0.0) SK1.Name = "Skin_carena"; SM.ForceSelect(NL1); SM.ForceSelect(NL2); ag.b.Regen(); i tried to use also agb.AddSelect(agc.TypeEdge3d, NL1); agb.AddSelect(agc.TypeEdge3d, NL2); but DesignModeler doesn't create the Skin because the curves are not selected. sorry, I'm a newcomer to this program. Cheers MIZOR |
|
July 15, 2015, 20:01 |
|
#19 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
I am not sure mate,
I will have a look soon and get back at ya! Cheers KAPI |
|
July 15, 2015, 21:49 |
|
#20 |
New Member
Michelangelo
Join Date: Apr 2015
Posts: 17
Rep Power: 11 |
Hi Kapi,
thanks, but i solved the problem changing 3D curve in spline generated with sketch as you suggested and I created the Skin. You know the script command to merge two bodies? I should merge original geometry with Skin. Cheers MIZOR |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[DesignModeler] DesignModeler Scripting: How to get Full Command Access | ANT | ANSYS Meshing & Geometry | 53 | February 16, 2020 16:13 |
[DesignModeler] Designmodeler java scripting | Herbert2014 | ANSYS Meshing & Geometry | 13 | October 16, 2019 17:19 |
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 |
[DesignModeler] change import by scripting | dragonwei | ANSYS Meshing & Geometry | 0 | September 17, 2012 06:08 |