[DesignModeler] Pattern Function does not work,why?
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(); |
Hi Vallence,
Quote:
Quote:
Quote:
|
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. |
why do you have to select Y axis specifically?
if you only give reference to XY plane, it should work! |
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 . |
i will give it a go and let you know
|
1 Attachment(s)
I upload the actual result and the result I expect. You can find the difference between them.
|
With the help of many friends, I solved this problem
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(); |
good work and thanks for posting final codes.
|
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 |
Explain
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); } |
All times are GMT -4. The time now is 01:04. |