|
[Sponsors] |
[DesignModeler] [DesignModeler] Pattern Function does not work,why? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 11, 2017, 02:43 |
[DesignModeler] Pattern Function does not work,why?
|
#1 |
New Member
LC
Join Date: Jun 2017
Posts: 6
Rep Power: 9 |
Hi,everyone!
The following js code is a simple DesignModeler example.I want to body2 pattern around YAxis. But it does not work. How to set pattern axis? var XYPlane = agb.GetXYPlane(); agb.SetActivePlane (XYPlane); function planeSketchesOnly (p) { //Plane p.Plane = agb.GetActivePlane(); p.Origin = p.Plane.GetOrigin(); p.XAxis = p.Plane.GetXAxis(); p.YAxis = p.Plane.GetYAxis(); //Sketch1 p.Sk1 = p.Plane.NewSketch(); p.Sk1.Name = "Sketch"; //Edges with (p.Sk1) { a=10 b=20 h=20 p.Ln11 = Line(a,0,b,0); p.Ln12 = Line(b,0,b,h); p.Ln13 = Line(b,h,a,h); p.Ln14 = Line(a,h,a,0); } edge1=p.Ln14; //Sketch2 p.Sk2 = p.Plane.NewSketch(); p.Sk2.Name = "Sketch2"; //Edges with (p.Sk2) { a=15 b=24 h=10 h0=12 p.Ln21 = Line(a,h0,b,h0); p.Ln22 = Line(b,h0,b,h0+h); p.Ln23 = Line(b,h0+h,a,h+h0); p.Ln24 = Line(a,h+h0,a,h0); } //Dimensions and/or constraints with (p.Plane) { } p.Plane.EvalDimCons(); //Final evaluate of all dimensions and constraints in plane return p; } //End Plane JScript function: planeSketchesOnly //Call Plane JScript function var ps1 = planeSketchesOnly (new Object()); //BODY1 var MyRevolve1 = agb.Revolve(agc.Add, ps1.Sk1, ps1.YAxis, agc.DirNormal, 360.0, 0.0, agc.No, 0.0, 0.0); agb.Regen(); //BODY2 var MyRevolve2 = agb.Revolve(agc.Frozen, ps1.Sk2, ps1.YAxis, agc.DirNormal, 3.0, 0.0, agc.No, 0.0, 0.0); agb.Regen(); //To insure model validity var MyPattern = ag.gui.CreatePattern(); MyPattern.Name="Pattern1"; ag.listview.ActivateItem("Pattern Type"); ag.listview.ItemValue = "Circular"; ag.listview.ActivateItem("Geometry"); agb.ClearSelections(); body1 = ag.fm.Body(1); agb.AddSelect(agc.TypeBody, body1); ag.listview.ItemValue = "Apply"; //============================== ag.listview.ActivateItem("Axis"); //ag.bodyPick; ag.edgePick; //These two methods have been tried, No Pass! ag.gui.SelectAll(); ag.listview.ItemValue = "Apply"; //============================ ag.listview.ActivateItem("FD2, Angle"); ag.listview.ItemValue = "Evently Spaced"; ag.listview.ActivateItem("FD3, Copies (>=0)"); ag.listview.ItemValue = "8"; agb.Regen(); Last edited by Vallence; June 13, 2017 at 22:51. |
|
June 12, 2017, 20:07 |
|
#2 | |||
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
Hi Vallence,
Quote:
Quote:
Quote:
|
||||
June 13, 2017, 00:54 |
|
#3 |
New Member
LC
Join Date: Jun 2017
Posts: 6
Rep Power: 9 |
Hi KAPI!
Thans for your reply. I have seen the advice you suggested, it is not the essence of the problem. What i want to do is to select XYPlane's YAxis. |
|
June 13, 2017, 01:07 |
|
#4 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
why do you have to select Y axis specifically?
if you only give reference to XY plane, it should work! |
|
June 13, 2017, 01:14 |
|
#5 |
New Member
LC
Join Date: Jun 2017
Posts: 6
Rep Power: 9 |
Hi Kapi,Thank you for your prompt reply.
I tried the following code,but it deos not work. var PatAxis=XYPlane.GetYAxis(); ag.listview.ActivateItem("Axis"); agb.AddSelect(agc.TypeEdge3d, PatAxis); ag.listview.ItemValue ="Apply"; The key question is i do not know how to select YAxis and let it work . |
|
June 13, 2017, 19:52 |
|
#6 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
i will give it a go and let you know
|
|
June 13, 2017, 22:51 |
|
#7 |
New Member
LC
Join Date: Jun 2017
Posts: 6
Rep Power: 9 |
I upload the actual result and the result I expect. You can find the difference between them.
|
|
June 14, 2017, 00:31 |
With the help of many friends, I solved this problem
|
#8 |
New Member
LC
Join Date: Jun 2017
Posts: 6
Rep Power: 9 |
Thanks very much for Kapi and EFRIVIDA's selfless help,now I solved the problem that bothered me for several days. I will publish the code for my friends Who meet the same trouble with them.
//============================================== var XYPlane = agb.GetXYPlane(); agb.SetActivePlane (XYPlane); function planeSketchesOnly (p) { //Plane p.Plane = agb.GetActivePlane(); p.Origin = p.Plane.GetOrigin(); p.XAxis = p.Plane.GetXAxis(); p.YAxis = p.Plane.GetYAxis(); //Sketch1 p.Sk1 = p.Plane.NewSketch(); p.Sk1.Name = "Sketch"; //Edges with (p.Sk1) { a=10 b=20 h=20 p.Ln11 = Line(a,0,b,0); p.Ln12 = Line(b,0,b,h); p.Ln13 = Line(b,h,a,h); p.Ln14 = Line(a,h,a,0); } //Sketch2 p.Sk2 = p.Plane.NewSketch(); p.Sk2.Name = "Sketch2"; //Edges with (p.Sk2) { a=14; b=24; h=10; h0=12; p.Ln21 = Line(a,h0,b,h0); p.Ln22 = Line(b,h0,b,h0+h); p.Ln23 = Line(b,h0+h,a,h+h0); p.Ln24 = Line(a,h+h0,a,h0); } //Dimensions and/or constraints with (p.Plane) { } p.Plane.EvalDimCons(); //Final evaluate of all dimensions and constraints in plane return p; } //End Plane JScript function: planeSketchesOnly //Call Plane JScript function var ps1 = planeSketchesOnly (new Object()); var MyRevolve1 = agb.Revolve(agc.Add, ps1.Sk1, ps1.YAxis, agc.DirNormal, 360.0, 0.0, agc.No, 0.0, 0.0); agb.Regen(); var MyRevolve2 = agb.Revolve(agc.Frozen, ps1.Sk2, ps1.YAxis, agc.DirNormal, 3.0, 0.0, agc.No, 0.0, 0.0); agb.Regen(); //To insure model validity // Key Code var PF1 = ag.gui.CreateSpot(); ag.listview.ActivateItem("Type"); ag.listview.ItemValue = "Construction Point"; ag.listview.ActivateItem("Definition"); ag.listview.ItemValue = "Manual Input"; ag.listview.ActivateItem("FD8, X Coordinate"); ag.listview.ItemValue = "0"; ag.listview.ActivateItem("FD9, Y Coordinate"); ag.listview.ItemValue = "0"; ag.listview.ActivateItem("FD10, Z Coordinate"); ag.listview.ItemValue = "0"; agb.Regen(); var PF2 = ag.gui.CreateSpot(); ag.listview.ActivateItem("Type"); ag.listview.ItemValue = "Construction Point"; ag.listview.ActivateItem("Definition"); ag.listview.ItemValue = "Manual Input"; ag.listview.ActivateItem("FD8, X Coordinate"); ag.listview.ItemValue = "0"; ag.listview.ActivateItem("FD9, Y Coordinate"); ag.listview.ItemValue = "100"; ag.listview.ActivateItem("FD10, Z Coordinate"); ag.listview.ItemValue = "0"; agb.Regen(); var LF1 = agb.LinePt(); LF1.AddSegment(PF1.GetPoint(1, 0),PF2.GetPoint(1, 0), 0); agb.Regen(); //=================== var MyPattern = ag.gui.CreatePattern(); MyPattern.Name="Pattern1"; ag.listview.ActivateItem("Pattern Type"); ag.listview.ItemValue = "Circular"; ag.listview.ActivateItem("Geometry"); agb.ClearSelections(); body1 = ag.fm.Body(1); agb.AddSelect(agc.TypeBody, body1); ag.listview.ItemValue = "Apply"; //=========================================== ag.listview.ActivateItem("Axis"); ag.edgePick; ag.gui.SelectAll(); ag.listview.ItemValue = "Apply"; //=========================================== ag.listview.ActivateItem("FD2, Angle"); //ag.listview.ItemValue = "Evently Spaced"; ag.listview.ItemValue = "40"; ag.listview.ActivateItem("FD3, Copies (>=0)"); ag.listview.ItemValue = "8"; agb.Regen(); |
|
June 14, 2017, 02:32 |
|
#9 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
good work and thanks for posting final codes.
|
|
June 14, 2017, 03:44 |
|
#10 | |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
Hey vallence,
Did this work because you changed the geometry? previously 1 of the edges was coming in center which is why you were trying for Y axis in XY plane. New geometry shows the body is away from center, is that why Quote:
Cheers KAPI |
||
June 14, 2017, 03:57 |
Explain
|
#11 |
New Member
LC
Join Date: Jun 2017
Posts: 6
Rep Power: 9 |
I tried different a'values while I was debugging the code.Different a shows different result. Under current code,the final result can not vary with
a. with (p.Sk2) { a=15 //when a=0 the final result is the same b=24 h=10 h0=12 p.Ln21 = Line(a,h0,b,h0); p.Ln22 = Line(b,h0,b,h0+h); p.Ln23 = Line(b,h0+h,a,h+h0); p.Ln24 = Line(a,h+h0,a,h0); } |
|
Tags |
axis, pattern |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Lets talk about relaxation factor optimization | chriss85 | OpenFOAM Running, Solving & CFD | 35 | June 21, 2019 10:54 |
[blockMesh] error message with modeling a cube with a hold at the center | hsingtzu | OpenFOAM Meshing & Mesh Conversion | 2 | March 14, 2012 10:56 |
ParaView for OF-1.6-ext | Chrisi1984 | OpenFOAM Installation | 0 | December 31, 2010 07:42 |
Compilation errors in ThirdPartymallochoard | feng_w | OpenFOAM Installation | 1 | January 25, 2009 07:59 |
Problem with compile the setParabolicInlet | ivanyao | OpenFOAM Running, Solving & CFD | 6 | September 5, 2008 21:50 |