|
[Sponsors] |
November 18, 2014, 06:44 |
Scripting Skin/Loft
|
#1 |
New Member
Mark
Join Date: Dec 2011
Posts: 4
Rep Power: 14 |
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. |
|
November 19, 2014, 00:19 |
|
#2 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
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 |
|
November 19, 2014, 04:19 |
|
#3 |
New Member
Mark
Join Date: Dec 2011
Posts: 4
Rep Power: 14 |
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 |
|
November 19, 2014, 17:37 |
|
#4 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
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); Cheers Kapi |
|
March 27, 2015, 09:07 |
|
#5 |
New Member
SG
Join Date: Jan 2015
Posts: 29
Rep Power: 11 |
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. |
|
March 29, 2015, 20:05 |
|
#6 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
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 |
|
March 30, 2015, 02:23 |
|
#7 | |
New Member
SG
Join Date: Jan 2015
Posts: 29
Rep Power: 11 |
Quote:
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 |
||
March 31, 2015, 17:13 |
|
#8 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
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(); } 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! |
|
April 1, 2015, 05:02 |
|
#9 |
New Member
SG
Join Date: Jan 2015
Posts: 29
Rep Power: 11 |
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 |
|
April 1, 2015, 17:23 |
|
#10 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
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; You should get you answers if you search inside .js files hope it helps cheeers KAPI |
|
April 2, 2015, 09:54 |
|
#11 |
New Member
SG
Join Date: Jan 2015
Posts: 29
Rep Power: 11 |
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 |
|
April 6, 2015, 19:38 |
|
#12 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
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" Cheers KAPI |
|
April 9, 2015, 12:00 |
|
#13 |
New Member
SG
Join Date: Jan 2015
Posts: 29
Rep Power: 11 |
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 |
|
April 9, 2015, 19:40 |
|
#14 | |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
Hi SG,
Quote:
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"; If not then tell me what error are you getting, try to manually sew and see if its creating solid. Cheers KAPI |
||
April 10, 2015, 10:52 |
|
#15 |
New Member
SG
Join Date: Jan 2015
Posts: 29
Rep Power: 11 |
Hi KAPI
Thanks, this did the trick. Code:
ag.listview.ActivateItem("Create Solids?"); ag.listview.ItemValue = "Yes"; I have used somthing similar to this to select edges: Code:
var edge1 = ag.m.ModelEdges(EdgeNumber); agb.AddSelect(agc.TypeEdge3d, edge1); Code:
var vertex1 = ag.m.ModelVertices(VerticeNumber); // get error here, (error:Object not a collection) agb.AddSelect(agc.TypeVertex, vertex1); Best regards, SG |
|
April 12, 2015, 18:55 |
|
#16 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
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); 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 |
|
April 16, 2015, 16:29 |
|
#17 |
New Member
SG
Join Date: Jan 2015
Posts: 29
Rep Power: 11 |
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 |
|
April 16, 2015, 18:36 |
|
#18 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
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); Code:
p.YAxis = p.Plane.GetYAxis(); p.Sk1 = p.Plane.NewSketch(); Hope it helps, Cheers KAPI |
|
April 17, 2015, 02:27 |
|
#19 |
New Member
SG
Join Date: Jan 2015
Posts: 29
Rep Power: 11 |
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. |
|
April 19, 2015, 20:01 |
|
#20 | ||
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
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 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:
KAPI |
|||
|
|
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 |