CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > ANSYS Meshing & Geometry

[DesignModeler] CreateLineSk with JS?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 28, 2017, 08:02
Default CreateLineSk with JS?
  #1
New Member
 
Felix L.
Join Date: Aug 2017
Posts: 5
Rep Power: 9
general_failure is on a distinguished road
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();
This only provides an error though. Obviously I need to assign the right sketch to the feature. I just don't know what specific function the CreateLineSk()-feature requires, and seemingly there's no way of finding out. Can somebody help?

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.
general_failure is offline   Reply With Quote

Old   August 28, 2017, 20:24
Default
  #2
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
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();
Kapi is offline   Reply With Quote

Old   August 29, 2017, 04:26
Default
  #3
New Member
 
Felix L.
Join Date: Aug 2017
Posts: 5
Rep Power: 9
general_failure is on a distinguished road
Quote:
Originally Posted by Kapi View Post
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();
Thanks for your reply, but your code only describes how to create a sketch with code, which I've already done
What I want to do is create a "Line"-Object from that sketch with the CreateLineSk() Feature.
general_failure is offline   Reply With Quote

Old   August 29, 2017, 20:15
Default
  #4
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
sorry but I dont understand what "line" object is?
what I understand now is that you want to create a line using CreateLineSk() right?
Kapi is offline   Reply With Quote

Old   August 30, 2017, 04:22
Default
  #5
New Member
 
Felix L.
Join Date: Aug 2017
Posts: 5
Rep Power: 9
general_failure is on a distinguished road
Quote:
sorry but I dont understand what "line" object is?
what I understand now is that you want to create a line using CreateLineSk() right?
Yes. I need those Line-Objects in order to be able to export them via igs or step. What I do is create a sketch with the geometry I need and then create a "Line-Object" out of that sketch with the "Create Line from Sketch"-feature. It's confusing since there's both "lines" within sketches and also "Lines" created through the operations "Line from Points" or "Line from Sketches". I enclosed 2 pics showing which functions I'm talking about (german version).

And I'm trying to figure out which parameters the Jscript-function "ag.gui.CreateLineSk()" requires in order to work.
Attached Images
File Type: jpg line_1.jpg (82.3 KB, 5 views)
File Type: jpg line_2.jpg (83.6 KB, 3 views)
general_failure is offline   Reply With Quote

Old   August 30, 2017, 21:22
Default
  #6
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
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();
see if it works

Cheers
KAPI
Kapi is offline   Reply With Quote

Old   August 31, 2017, 05:38
Default
  #7
New Member
 
Felix L.
Join Date: Aug 2017
Posts: 5
Rep Power: 9
general_failure is on a distinguished road
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...
general_failure is offline   Reply With Quote

Old   August 31, 2017, 20:35
Default
  #8
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
you have to use exact words what appear even the spaces.
Kapi is offline   Reply With Quote

Old   September 1, 2017, 04:42
Default
  #9
New Member
 
Felix L.
Join Date: Aug 2017
Posts: 5
Rep Power: 9
general_failure is on a distinguished road
Quote:
Originally Posted by Kapi View Post
you have to use exact words what appear even the spaces.
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();
Because of the german version I also have to change the decimal sign from "." to "," for my calculated point-coordinates. I do the whole thing for a second CreateSpot(), and afterwards this:
Quote:
LF1.AddSegment(PF1.GetPoint(1, 0),PF2.GetPoint(1, 0), 0);
All of this in a for-loop creates my desired Lines just fine. Only problem is that it's very slow. But at least I now got a solution. Thanks!
general_failure is offline   Reply With Quote

Reply

Tags
javascript


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 14:48.