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] Define a new point in a script (https://www.cfd-online.com/Forums/ansys-meshing/155175-define-new-point-script.html)

bongbang June 25, 2015 18:43

Define a new point in a script
 
Is there a way to define a point in the script without loading a text file? Or even if some initial points are loaded, is there a way to define subsequent points based on them? For example:

Code:

var PF1 = agb.FPoint(agc.FPointConstruction, agc.FPointCoordinateFile);  //Creates basic feature
        PF1.Name = "TablePoints";  //This is not required
        PF1.CoordinateFile = "D:\\Samples\\Table.txt";
        agb.Regen();        //Feature not complete until this is done

// The above is from the manual

NewPoint = PF1.GetPoint(1,1) + (0,0,1); // i.e. translated 1 unit in the Z-direction

Thank you.

Kapi June 25, 2015 19:04

Hi NC,

You can define your Point coordinate directly in the script just like you do in your coordinate file
Code:

p.c11= Point(0.446215,0.073264);
I am not sure how to use old geometry points and translate the point.

Hope it helps

Cheers
KAPI

bongbang June 25, 2015 19:23

Thanks, Kapi, but that doesn't work for me. Depending on the variable I use (left of the equality sign), I either get "'p' is not defined" or "object is expected." Any thoughts?

Can the Point() function really be used as is without any object prefix (like "agb")? And why is the coordinate (x,y) instead of (x,y,z)? If I can define a point in the script, then translation should be straightforward the GetPointZ() method and the like.

Kapi June 25, 2015 19:35

Hi NC,

This is How "P" is defined.

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.c11= Point(0.446215,0.073264,0.506585);
....
...
}
with (p.Plane)
{
}
p.Plane.EvalDimCons();
return p;
}
var ps1 = planeSketchesOnly6 (new Object());
agb.Regen();

You can define point straight forward like above and Lines as well if you need like below

Code:

p.Ln28= Line(0.96724,0.5359512,0.96724,1.075531);
Once you have Point like "c11" you can try and use translation, I have never used it hence cant comment on it.
Also can I suggest you to go thru Scripting Guide, you will find lot of your answers there and in Help Section.

Hope it helps

Cheers
KAPI

bongbang June 25, 2015 19:45

Many thanks. That gives me something to work with.

By "Scripting Guide," do you mean the section under Workbench help? I scanned that quickly but it doesn't seem to pertain to DM specifically. So instead, I've been reading "Scripting API" in DM's manual, which is more specific but doesn't answer all of my questions.

Kapi June 25, 2015 20:02

Hi NC,

"Scripting Guide" will help you understand the flow of how scripts are used.
"Scripting API" or DM user's guide will help you create Geometry specifically.
So you need to go thru both to understand the overall process.

Good Luck

Cheers
KAPI


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