|
[Sponsors] |
August 28, 2017, 08:02 |
CreateLineSk with JS?
|
#1 |
New Member
Felix L.
Join Date: Aug 2017
Posts: 5
Rep Power: 9 |
Hi guys,
my first post I'm trying to use several different functions of the DesignModeler via Javascript in order to have a fully automated model creation. Sadly no complete overview of the existing scripting features and functions can be found. More specifically: I'm trying to create a Line-Object out of a Sketch. I already found out the respective feature "ag.gui.CreateLineSk()". But I just can't figure out which functions I need to provide. With ps1.Sk2 being the sketch in question I tried sth like: Code:
var ps1 = planeSketchesOnly (new Object()); var lin1 = ag.gui.CreateLineSk(); lin1.Name = "line-object"; lin1.Add(ps1.Sk2); agb.Regen(); And isn't there a more thorough overview of all the implemented scripting commands for features and functions (more thorough than this anyways)? Thanks, greets from Germany Felix Edit: I figured that I might be able to do what I want to do with the "Lines from Points"-function. But that way I basically have to create all the lines twice, which seems kinda unnecessary to me. |
|
August 28, 2017, 20:24 |
|
#2 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
you can use something like this from points:
Code:
function planeSketchesOnly6 (p) { p.Plane = agb.GetActivePlane(); p.Origin = p.Plane.GetOrigin(); p.XAxis = p.Plane.GetXAxis(); p.YAxis = p.Plane.GetYAxis(); p.Sk6 = p.Plane.NewSketch(); p.Sk6.Name ="Sketch6"; with (p.Sk6) { p.Ln11= Line(0.37537,0.0756297,0.44646,0.0756297); p.Ln12= Line(0.44646,0.0756297,0.44646,1.18353); p.Ln13= Line(0.44646,1.18353,0.37537,1.18353); p.Ln14= Line(0.37537,1.18353,0.37537,0.0756297); } with (p.Plane) { } p.Plane.EvalDimCons(); return p; } var ps1 = planeSketchesOnly6 (new Object()); agb.Regen(); |
|
August 29, 2017, 04:26 |
|
#3 | |
New Member
Felix L.
Join Date: Aug 2017
Posts: 5
Rep Power: 9 |
Quote:
What I want to do is create a "Line"-Object from that sketch with the CreateLineSk() Feature. |
||
August 29, 2017, 20:15 |
|
#4 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
sorry but I dont understand what "line" object is?
what I understand now is that you want to create a line using CreateLineSk() right? |
|
August 30, 2017, 04:22 |
|
#5 | |
New Member
Felix L.
Join Date: Aug 2017
Posts: 5
Rep Power: 9 |
Quote:
And I'm trying to figure out which parameters the Jscript-function "ag.gui.CreateLineSk()" requires in order to work. |
||
August 30, 2017, 21:22 |
|
#6 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
gotcha, may be you can use something like this:
Code:
var createline = ag.gui.CreateLineSk(); ag.listview.ActivateItem("Base Objects"); ag.listview.ItemValue = "Apply"; createline.Operation = 2; ag.b.Regen(); Cheers KAPI |
|
August 31, 2017, 05:38 |
|
#7 |
New Member
Felix L.
Join Date: Aug 2017
Posts: 5
Rep Power: 9 |
Thanks for the idea! I tried, the command ag.listview.ActiveItem("Base Object") produced the error "Item not found". I tried different keywords ("Base Object", "BaseObject", "Base Objects", "BaseObjects"), all produce "Item not found". Using the german keyword ("Basisobjekte") crashes DesignModeler
I wonder...am I maybe not meant to make this work? I'm already thinking about doing the whole modeling thing in APDL instead... |
|
August 31, 2017, 20:35 |
|
#8 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
you have to use exact words what appear even the spaces.
|
|
September 1, 2017, 04:42 |
|
#9 | |
New Member
Felix L.
Join Date: Aug 2017
Posts: 5
Rep Power: 9 |
Yeah, I figured it out now. Apparently with functions like ag.xx the actual Input-fields in the GUI are used, which is why I had to use the german keywords since my version is german. Using the correct keyword on CreateLineSk() made the Designmodeler crash however, so I now use a workaround by first creating points with ag.gui.CreateSpot() and then using agb.LinePt():
Code:
var PF1 = ag.gui.CreateSpot(); ag.listview.ActivateItem("Typ"); ag.listview.ItemValue = "Design Point"; ag.listview.ActivateItem("Definition"); ag.listview.ItemValue = "Manuelle Eingabe"; ag.listview.ActivateItem("FD8, X-Koordinate"); str_ = String(x_base) strx_ = str_.replace(".",",") ag.listview.ItemValue = strx_; ag.listview.ActivateItem("FD9, Y-Koordinate"); str_ = String(y_base) stry_ = str_.replace(".",",") ag.listview.ItemValue = stry_; ag.listview.ActivateItem("FD10, Z-Koordinate"); str_ = String(z_koord) strz_ = str_.replace(".",",") ag.listview.ItemValue = strz_; agb.Regen(); var PF2 = ag.gui.CreateSpot(); ag.listview.ActivateItem("Typ"); ag.listview.ItemValue = "Design Point"; ag.listview.ActivateItem("Definition"); ag.listview.ItemValue = "Manuelle Eingabe"; ag.listview.ActivateItem("FD8, X-Koordinate"); str_ = String(x_mid) strx_ = str_.replace(".",",") ag.listview.ItemValue = strx_; ag.listview.ActivateItem("FD9, Y-Koordinate"); str_ = String(y_mid) stry_ = str_.replace(".",",") ag.listview.ItemValue = stry_; ag.listview.ActivateItem("FD10, Z-Koordinate"); str_ = String(z_koord) strz_ = str_.replace(".",",") ag.listview.ItemValue = strz_; agb.Regen(); Quote:
|
||
Tags |
javascript |
|
|