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

[DesignModeler] Jscript to create surface from point

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 7, 2016, 11:12
Default Jscript to create surface from point
  #1
New Member
 
adrien gros
Join Date: Oct 2016
Location: curitiba
Posts: 2
Rep Power: 0
adwien is on a distinguished road
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
adwien is offline   Reply With Quote

Old   October 9, 2016, 23:51
Default
  #2
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
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
Kapi is offline   Reply With Quote

Old   October 10, 2016, 17:23
Default
  #3
New Member
 
adrien gros
Join Date: Oct 2016
Location: curitiba
Posts: 2
Rep Power: 0
adwien is on a distinguished road
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
adwien is offline   Reply With Quote

Old   October 10, 2016, 18:30
Default
  #4
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hiya Adrien,

I have never done it before, so I cant really help with 3d coordinate system!
Kapi is offline   Reply With Quote

Reply

Tags
design modeler, jscript


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in toposet Ahmed Khattab OpenFOAM Pre-Processing 27 March 3, 2023 21:12
[snappyHexMesh] How to create internal boundaries using snappyHexMesh robyTKD OpenFOAM Meshing & Mesh Conversion 2 October 19, 2014 09:57
a reconstructPar issue immortality OpenFOAM Post-Processing 8 June 16, 2013 11:25
Help: Create offset surface from existing surface??!! tobiley FLUENT 2 May 22, 2013 07:34
[Gmsh] Gmsh and samplesurface touf OpenFOAM Meshing & Mesh Conversion 2 December 10, 2007 02:27


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