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

[DesignModeler] Scripting Skin/Loft

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 18, 2014, 06:44
Default Scripting Skin/Loft
  #1
maw
New Member
 
Mark
Join Date: Dec 2011
Posts: 4
Rep Power: 14
maw is on a distinguished road
I'm trying to script the generate a Skin/loft from a series profiles defined by line bodies. The line bodies were created using the 3DCurve feature tool. However, I struggling to find the correct syntax for selecting the line bodies as my profiles.

var Skin1 = agb.Skin(agc.Frozen, agc.Yes, 0.0, 0.0);
var Crv1 = ag.agApplet.FeatureMgr.Body(0); // Select 1st line body
var Crv2 = ag.agApplet.FeatureMgr.Body(1); // Select 2nd line body
var Crv3 = ag.agApplet.FeatureMgr.Body(2); // Select 3rd line body
Skin1.AddBaseObject(Crv1);
Skin1.AddBaseObject(Crv2);
Skin1.AddBaseObject(Crv3);
agb.Regen();

DesignModeler crashes when it gets to the line Skin1.AddBaseObject(Crv1);

Does anyone know the correct syntax for this command or an alternative method for selecting a series of line bodies as profiles for a Skin/Loft.

Thanks in advance.
maw is offline   Reply With Quote

Old   November 19, 2014, 00:19
Default
  #2
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi Maw,

Crv1 is storing body in this variable whereas you need edge or face or some sketch to make the skin feature.
It is basically a profile where you stretch and put the skin on.
Try to store profile(sketch/edge) of skin in Crv1 and then use the same feature. it should work that way.

Cheers Kapi
Kapi is offline   Reply With Quote

Old   November 19, 2014, 04:19
Default
  #3
maw
New Member
 
Mark
Join Date: Dec 2011
Posts: 4
Rep Power: 14
maw is on a distinguished road
Hi Kapi

Thanks for your response. Unfortunately the profile is not planar so I cannot use a sketch. If I do this manually the skin tool accepts a lnie body as a profile.

Does anyone know how I can add a series of line bodies to a selection using a command like agb.AddSelect(type, item) or how I can select an edge associated with a line body?

Cheers

Mark
maw is offline   Reply With Quote

Old   November 19, 2014, 17:37
Default
  #4
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi Maw,

I reckon the best way to AddSelect series of line bodies is by named selection.
Once you pick all bodies and Named Selection is done, you can add code like this,


Code:
agb.AddSelect(agc.TypeBody, Crv1);
hope this helps

Cheers
Kapi
Kapi is offline   Reply With Quote

Old   March 27, 2015, 09:07
Default
  #5
New Member
 
SG
Join Date: Jan 2015
Posts: 29
Rep Power: 11
stessigunn is on a distinguished road
Hi Maw.

Have you figured out how to do this? It would solve a lot of problems for me if I knew how to select things (lines, bodie, surface etc.) with the script.

Last edited by stessigunn; March 27, 2015 at 10:38.
stessigunn is offline   Reply With Quote

Old   March 29, 2015, 20:05
Default
  #6
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi SG,

You can select body, surface, point, edge anything if you know the "ID" they are carrying. Find "ID", do "Named selection" and then you can call them in your script.
If you are not sure how to get "partID" or "topoID" then let me know, I can send you a small snippet how to get those ID and do "named selection" for it.

Hope it helps

Cheers
KAPI
Kapi is offline   Reply With Quote

Old   March 30, 2015, 02:23
Default
  #7
New Member
 
SG
Join Date: Jan 2015
Posts: 29
Rep Power: 11
stessigunn is on a distinguished road
Quote:
Originally Posted by Kapi View Post
Hi SG,

You can select body, surface, point, edge anything if you know the "ID" they are carrying. Find "ID", do "Named selection" and then you can call them in your script.
If you are not sure how to get "partID" or "topoID" then let me know, I can send you a small snippet how to get those ID and do "named selection" for it.

Hope it helps

Cheers
KAPI

Thank you for your reply KAPI.

I do not know how to get the "partID" or "topoID", so I would appreciate if you could show me how to get those IDs and create the named selection so I can try the command you talked about on the other thread (http://www.cfd-online.com/Forums/ans...tml#post538894), the tip to use "SM.ForceSelect();".

This is how I create the curves I want to use to do the skin:

var NLHub = ag.gui.CreateCurve();
NLHub.CoordinateFile = "FilePath";

I also need some help selecting the bodies for a body operation and I guess it could be done in a similar way. Do you know how to use the body operation? I have not managed to find the "agc.xxxx" commands for BodyOp, I have only used "ag.gui.CreateBodyOp(8);" but as before, I do not know how to select the bodies or edit the details of the feature.

Thank you for your help,
-SG
stessigunn is offline   Reply With Quote

Old   March 31, 2015, 17:13
Default
  #8
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi SG,

You may use the below code to get PartID and TopoID

Code:
var part = ds.SelectionManager.PartMgr.PartById(partID[i]);
    var brep = part.BRep;
    var body = brep.Cell(TopoId[i]);

    var faces = body.faces;//get total faces of each body
    
    //loop the faces to get the face partID and topoID.
    var faceCount = faces.Count;
    for (j=1;j<=faceCount; j++) {
	face = faces(j);
	var aTopoId = face.Id;
	SM.Clear(); //clear any existing selection
	SM.ForceSelect(partID[i], aTopoId); //force select face based on part id and topo id
	name = "NS_" + i + "_" + j;
	ds.Script.addNamedSelection(false, name); //create named selection
	ds.Script.updateNamedSelectionsToolbar();
	SM.Clear();
    }
From above TopoID and PartID you should be able to select particular body.
You have to create ".js" file with the body selection code and use at reference "FilePath".

Hope it helps.

Cheers
KAPI

ps: you can search for fucntions/codes in your "C:/Ansys Inc/V150......" folder. Search for extension ".js" and it should do the trick!
crevoise likes this.
Kapi is offline   Reply With Quote

Old   April 1, 2015, 05:02
Default
  #9
New Member
 
SG
Join Date: Jan 2015
Posts: 29
Rep Power: 11
stessigunn is on a distinguished road
Hi KAPI.

Thank you for the help. I tried your code but I get an error right away, saying 'ds' is undefined.

I have been browsing the .js files but can not find how this should be defined in DesignModeler (I am using Ansys 15.0 if that matters). Can you help me with this?

Best regards,
SG
stessigunn is offline   Reply With Quote

Old   April 1, 2015, 17:23
Default
  #10
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi SG,

You have to search .js file and try to understand how coding works.
search for "ds" if required and understand how it is being used.

for this ds, it shud be.

Code:
var ds = DS;
similarly, you have search and find how to define partID and TopoID as well since its an array.
You should get you answers if you search inside .js files

hope it helps

cheeers
KAPI
Kapi is offline   Reply With Quote

Old   April 2, 2015, 09:54
Default
  #11
New Member
 
SG
Join Date: Jan 2015
Posts: 29
Rep Power: 11
stessigunn is on a distinguished road
Hi KAPI.

I tried defining ds as: "var ds = DS", but then I just get an error that DS is undefined, and I get an error on SM as well.

I have been trying to browse the .js files, but they don't help me much. I have mainly been trying to understand the script files with the prefix ag, but it has not helped me to understand this better or get this to work. There are a lot of .js files in the directory, is there any file you recommend to have a look at rather than other?

I tried the code you provided in Ansys Mechanical as macro, and did not get any error message there. Is there anything special I have to do for DesignModeler?

Appreciate your help.
-SG
stessigunn is offline   Reply With Quote

Old   April 6, 2015, 19:38
Default
  #12
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi SG,

I thought u were trying to run functions for mesh, hence I gave you last codes( my bad).
for design modeler:

Code:
var body1 = ag.fm.Body(ag.fm.BodyCount-i);
body1.Name = BODY1"
this should help you select bodies and then help you rename them, You can use same code with FaceCount as well I suppose. If it dosent work then let me know, I will check at my end.

Cheers
KAPI
Kapi is offline   Reply With Quote

Old   April 9, 2015, 12:00
Default
  #13
New Member
 
SG
Join Date: Jan 2015
Posts: 29
Rep Power: 11
stessigunn is on a distinguished road
Great, thank you KAPI.

I have managed to select edges on bodies and create a surface from edges. I am now trying to use a body operation, using sew. Do you know how to change the details in the body operation? I want to change the option Create Solids? from No to Yes. What I have tried looks like this:

var Stator = ag.gui.CreateBodyOp(8); //creates the sew feature
Stator.CreateSolids = ag.c.Yes; //Does not work to create a solid...

Also, do you know how to select single vertices from 3D objects? I have two 3D curves that I want to connect with a line.

Best regards,
-SG
stessigunn is offline   Reply With Quote

Old   April 9, 2015, 19:40
Default
  #14
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi SG,


Quote:
var Stator = ag.gui.CreateBodyOp(8); //creates the sew feature
Stator.CreateSolids = ag.c.Yes; //Does not work to create a solid...
Where did you get this function "CreateSolids" and "CreateBodyOp(8)" ?
Have you tested if (8) is for sew function and "CreateSolids" take you to the next item?
I would use "ag.c.Yes;" as well to pick value, if its not able to pick then try either of these and see if they work

Code:
Stator.CreateSolids = 1;

or

Code:
ag.listview.ActivateItem("Create Solids?");
ag.listview.ItemValue = "Yes";
and in the end don't forget to regenerate

If not then tell me what error are you getting, try to manually sew and see if its creating solid.

Cheers
KAPI
Kapi is offline   Reply With Quote

Old   April 10, 2015, 10:52
Default
  #15
New Member
 
SG
Join Date: Jan 2015
Posts: 29
Rep Power: 11
stessigunn is on a distinguished road
Hi KAPI

Thanks, this did the trick.

Code:
ag.listview.ActivateItem("Create Solids?");
ag.listview.ItemValue = "Yes";
Do you know if I can select single vertices (end point of 3D curve)?
I have used somthing similar to this to select edges:

Code:
var edge1 = ag.m.ModelEdges(EdgeNumber);
agb.AddSelect(agc.TypeEdge3d, edge1);
and have tried using a similar way for vertices but this does not work :

Code:
var vertex1 = ag.m.ModelVertices(VerticeNumber); // get error here, (error:Object not a collection)
agb.AddSelect(agc.TypeVertex, vertex1);
so I am guessing the vertices are not stored in the same way as edges or bodies. Do you know how I can do this?

Best regards,
SG
stessigunn is offline   Reply With Quote

Old   April 12, 2015, 18:55
Default
  #16
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi SG,

I have not used Vertices in my codes before but by quick check, the below code you mentioned seems right to me.

Code:
var vertex1 = ag.m.ModelVertices(VerticeNumber); 
agb.AddSelect(agc.TypeVertex, vertex1);
Are you able to get VerticeNumber for the vertice you want to select?? or is it giving error as well?
Have you tried Named selection for that Vertice and then use AddSelect to select that body?

Its very much possible that vertices are not stored similar to edge/face/body.
I think you need to contact Ansys customer support unless there is someone who can help us find the right code(Simon Pereira)

I will try from my end and let you know if I get something and you shall do the same for the benefit of Forum.

Cheers
KAPI
Kapi is offline   Reply With Quote

Old   April 16, 2015, 16:29
Default
  #17
New Member
 
SG
Join Date: Jan 2015
Posts: 29
Rep Power: 11
stessigunn is on a distinguished road
Hi KAPI.

I managed to find a way to work around the vertices so I have no solution for that yet. I am now working on the revolve function. I use the gui function to create the feature, and select the geometry by selecting edges as I have shown in previous post, and use

ag.listview.ActivateItem(“Geometry”);
ag.listview.ItemValue = “Apply”;

This works fine but I also need to select the axis of rotation, which I have not managed to do yet. I do not know how I can select the axis directly, so I created a line and tried to select it, and then use:

ag.listview.ActivateItem(“Axis”);
ag.listview.ItemValue = “Apply”;

I have confirmed that I have selected only the line I want to revolve around by creating a named selection, but this still does not work. Any thoughts (I don’t get any error message, just no axis selected when the feature is generated)?

The code looks something like this:
ag.gui.CreateRevolution();
var edge1 = ag.m.ModelEdges(EdgeNumber);
agb.AddSelect(agc.TypeEdge3d, edge1);
ag.listview.ActivateItem(“Geometry”);
ag.listview.ItemValue = “Apply”;
ag.gui.ClearSelect();
var EdgeAxis = ag.m.ModelEdges(EdgeNumber);
agb.AddSelect(agc.TypeEdge3d, EdgeAxis);
ag.listview.ActivateItem(“Axis”);
ag.listview.ItemValue = “Apply”;
agb.Regen();

Best regards,
SG
stessigunn is offline   Reply With Quote

Old   April 16, 2015, 18:36
Default
  #18
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi SG,

Good Day!!

You are trying to use listview function but you are not selecting Axis to revolve to! Hence after calling "Axis" you should pick your sketch/edge and then click apply, just like we do manually!!

Anyways, I think you are after this function!

Code:
var Rev1 = agb.Revolve(agc.Add, ps1.Sk1, ps1.YAxis, agc.DirNormal,0.1, 0.0, agc.No, 0.0, 0.0);
the above example is revolving sketch(ps1) around Y Axis.

Code:
p.YAxis  = p.Plane.GetYAxis();
p.Sk1 = p.Plane.NewSketch();

Hope it helps,

Cheers
KAPI
Kapi is offline   Reply With Quote

Old   April 17, 2015, 02:27
Default
  #19
New Member
 
SG
Join Date: Jan 2015
Posts: 29
Rep Power: 11
stessigunn is on a distinguished road
Hi KAPI.

I have seen the code you suggested, but can it be applied to 3D curves?

I tried to write the code as you would do manually, activate the item, select the axis and click apply:

ag.listview.ActivateItem("Axis");
var axis1 = ag.m.ModelEdges(5);
agb.AddSelect(agc.TypeEdge3d, axis1);
ag.listview.ItemValue = "Apply";

This does not work and I can't see why, everything else I have tried to do using ActivateItem has worked but not this.. Any thoughts?

edit: what I think I might have to do is to find a command comparable to manually right click on the feature in the feature tree and select "Edit Selections" to browse the details of the feature.

Best regards,
SG

Last edited by stessigunn; April 17, 2015 at 04:34.
stessigunn is offline   Reply With Quote

Old   April 19, 2015, 20:01
Default
  #20
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi SG,

I have not used that code for 3D curves hence I have no idea, have you tried it? what does it say?
Quote:
I have seen the code you suggested, but can it be applied to 3D curves?
what error are you r getting when you are running the code you mentioned?
I reckon if should work unless you are not able to pick the right edge there!

what will you gain from this? details of feature?
Quote:
edit: what I think I might have to do is to find a command comparable to manually right click on the feature in the feature tree and select "Edit Selections" to browse the details of the feature.
cheers
KAPI
Kapi is offline   Reply With Quote

Reply


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
[ICEM] ICEM Scripting Issues tylerplowright ANSYS Meshing & Geometry 33 September 27, 2021 16:35
Macro scripting in netbeans, importing star libraries laurensvd STAR-CCM+ 3 October 31, 2020 22:06
record actions via scripting Marabelle ANSYS 0 July 31, 2013 11:57
[DesignModeler] change import by scripting dragonwei ANSYS Meshing & Geometry 0 September 17, 2012 05:08
skin/loft error fkonias CFX 0 June 6, 2008 10:43


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