CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   ANSYS Meshing & Geometry (https://www.cfd-online.com/Forums/ansys-meshing/)
-   -   [DesignModeler] Jscript to create surface from point (https://www.cfd-online.com/Forums/ansys-meshing/178429-jscript-create-surface-point.html)

adwien October 7, 2016 11:12

Jscript to create surface from point
 
Hi all,
I have geometry defined by point ( coordinates x,y & z) So i try to use jscript to build this geometry in designbuilder. I found some function in ANSYS Workbench documentation that can help me i think:
//Points
var PF1 = agb.FPoint(agc.FPointConstruction, agc.FPointCoordinateFile);
PF1.CoordinateFile = "D:\\Users\\adrien.gros\\Documents\\fluent_project \\new 1.txt";
agb.Regen(); //To insure model validity
//Bottom
var LF1 = agb.LinePt();
LF1.AddSegment(PF1.GetPoint(1, 1), PF1.GetPoint(1, 2));
LF1.AddSegment(PF1.GetPoint(1, 2), PF1.GetPoint(1, 3));
LF1.AddSegment(PF1.GetPoint(1, 3), PF1.GetPoint(1, 4), 1); //Note setting ID=1
LF1.AddSegment(PF1.GetPoint(1, 4), PF1.GetPoint(1, 1));
agb.Regen();
var LF2 = agb.LinePt();
//Note these also set IDs
LF2.AddSegment(PF1.GetPoint(1, 3), PF1.GetPoint(2, 1), 2);
LF2.AddSegment(PF1.GetPoint(2, 1), PF1.GetPoint(2, 2), 3);
LF2.AddSegment(PF1.GetPoint(2, 2), PF1.GetPoint(1, 4), 4);
var i;
var edge;
var numb1 = LF1.GetNumEdges();
if(numb1 == 4)
{
agb.ClearSelections();
for(i=1; i<5; i++)
{
edge = LF1.GetEdge(i);
agb.AddSelect(agc.TypeEdge3d, edge);
}
var surf1 = agb.SurfFromLines();
agb.regen();
}
//Now select using IDs
agb.ClearSelections();
agb.AddSelectEdgeID(1);
agb.AddSelectEdgeID(2);
agb.AddSelectEdgeID(3);
agb.AddSelectEdgeID(4);
var surf2 = agb.SurfFromLines();
agb.Regen();
Where the used txtfile new 1.txt is :
# Group 1
1 1 0.000 0.00 0.0
1 2 10.000 0.00 0.0
1 3 10.000 20.000 0.0
1 4 0.000 20.000 0.0
# Group 2
2 1 -10.000 -10.00 0.0
2 2 20.000 -10.00 0.0
2 3 20.000 30.000 0.0
2 4 -10.000 30.000 0.0
But when i run this script in designmodeler, it does't work and this error message appear:
'Error: Line-Body operation failed
Context: Geometry Engine, while generating Feature Line10

Error: Empty selection
Context: Geometry Engine, while generating Feature Line10 '
Somebody may help me to understand what i did wrong?
Thank you

Kapi October 9, 2016 23:51

you can just create lines and then revolve it as "thin surface"

Example:
Code:

function planeSketchesOnly5 (p)
{
p.Plane  = agb.GetActivePlane();
p.Origin = p.Plane.GetOrigin();
p.XAxis  = p.Plane.GetXAxis();
p.YAxis  = p.Plane.GetYAxis();
p.Sk5 = p.Plane.NewSketch();
p.Sk5.Name ="Sketch5";
with (p.Sk5)
{
p.Ln187= Line(0.725425,0.03,0.725425,1.825);
p.Ln188= Line(0.725425,1.825,0.728425,1.825);
p.Ln189= Line(0.728425,1.825,0.728425,0.03);
p.Ln190= Line(0.728425,0.03,0.725425,0.03);
}
with (p.Plane)
{
}
p.Plane.EvalDimCons();
return p;
}
var ps1 = planeSketchesOnly5 (new Object());
agb.Regen();
var Rev4 = agb.Revolve(agc.Add, ps1.Sk5, ps1.YAxis, agc.DirNormal,0.1, 0.0, agc.Yes, 0.0, 0.0);
agb.Regen();
Rev4.Operation = agc.Frozen;
agb.Regen();


Hope it helps

Cheers
KAPI

adwien October 10, 2016 17:23

thank you for your help.
But i would like a jscript to build surface from 3d coordinate points without using symetry functions ( as revolve, extrude...). Here i presented very simple exemple to understand my probleme. But in reality i have a lot of point and they are not in the same plan ( z is different for each point)
Do you know if it is possible to write a jscripte that allow to build polyhedra, only by knowing coordinate of the edges?
thank you

Kapi October 10, 2016 18:30

Hiya Adrien,

I have never done it before, so I cant really help with 3d coordinate system!


All times are GMT -4. The time now is 08:00.