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] Design Modeler scripting (https://www.cfd-online.com/Forums/ansys-meshing/201428-design-modeler-scripting.html)

winchler May 2, 2018 07:34

Design Modeler scripting
 
Hi all,
I need to automatically create a set of spheres, depending on a list of point coming from an external file. I tried using a .js macro and until now I produce the following:

Code:

//Import the points
var fp1 = agb.FPoint(agc.FPointConstruction, agc.FPointCoordinateFile);
fp1.Name = "coordinatePoints";
fp1.CoordinateFile = "PATH\\file.txt";
agb.Regen();

//Generate spheres according to the sets of points from fp1 above
var i = 1;
while (fp1.GetPoint(i, 1)) {
    var SP = ag.gui.CreatePrimitive(1);       
        SP.SphereRadius = "1";
        i = i + 1;
}
agb.Regen();

Points are correctly imported, but I am not able to do the following things:
  • Import points in a different unit systems
  • Create a sphere for each point (for the moment only one is generated)
  • Modify the center of the sphere using the previously read points

Can please someone help me or tell me where can I find a list of example and tutorials?
Thank you

Lorenzo

winchler May 2, 2018 09:53

Solved
 
Sorry, I just solved it:

Code:


//Import the points
var fp1 = agb.FPoint(agc.FPointConstruction, agc.FPointCoordinateFile);
fp1.Name = "coordinatePoints";
fp1.CoordinateFile = "PATH\\FILE.txt";
agb.Regen();

//Generate spheres according to the sets of points from fp1 above
var i = 1;
while (fp1.GetPoint(1, i)) {
    var SP = ag.gui.CreatePrimitive(1);       
        //
    SP.SphereRadius = "0.00125";
    //
    ag.listview.ActivateItem("Sphere");
    ag.listview.ItemValue = "SPHERE_" + i;
    ag.listview.ActivateItem("Operation");
    ag.listview.ItemValue = "Add Frozen";
    ag.listview.ActivateItem("Origin Definition");
    ag.listview.ItemValue = "Coordinates";
    ag.listview.ActivateItem("FD3, Origin X Coordinate");
    ag.listview.ItemValue = agb.GetPointX(fp1.GetPoint(1, i));
    ag.listview.ActivateItem("FD4, Origin Y Coordinate");
    ag.listview.ItemValue = agb.GetPointY(fp1.GetPoint(1, i));
    ag.listview.ActivateItem("FD5, Origin Z Coordinate");
    ag.listview.ItemValue = agb.GetPointZ(fp1.GetPoint(1, i));
    agb.Regen();
    //
    i = i + 1;
}


amin.z May 19, 2018 06:21

Hi Lorenzo,


I'm dealing with the same problem, gotta generate a plate with random holes in it and mesh it, all automaticaly using script,
would you mind sharing your text file containing the points you used in your script? I wanna generate the points using a code, but not sure yet how I should arrange them inside the text file

winchler May 21, 2018 05:01

Hi, you can refer to this topic for the format!


https://www.cfd-online.com/Forums/an...n-modeler.html

amin.z May 22, 2018 04:33

Quote:

Originally Posted by winchler (Post 693019)
Hi, you can refer to this topic for the format!


https://www.cfd-online.com/Forums/an...n-modeler.html




got it, thanks


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