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   April 20, 2015, 02:53
Default
  #21
New Member
 
SG
Join Date: Jan 2015
Posts: 29
Rep Power: 11
stessigunn is on a distinguished road
Hi KAPI.

Quote:

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?
If I try to use the ListView functions to select the geometry and axis, it only works for the geometry, and I think that might be because the geometry tab is active when you create the feature, and I don't think that I can use ListView to activate it again if I want to select the axis (or change the geometry).

Other ListView commands that I have tried do not require that you right click the feature in the tree and click "edit selections" (if you do it manually), it is simply enough to double click the details you want to change, but this can not be done for the geometry or axis. If you double click the "not selected" tab to the right of "axis" the text only gets highlighted, and you don't have the option to select the geometry or axis.

Quote:
var Rev1 = agb.Revolve(agc.Add, ps1.Sk1, ps1.YAxis, agc.DirNormal,0.1, 0.0, agc.No, 0.0, 0.0);
To be honest, I am not sure how I should define the geometry here, I thought the other method would be easier for me so I have not given this that much time. Do you know what ps1 stands for?

Also, do you know a command for freeze? So far I have only seen the command for unfreeze.

Best regards,
SG

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

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

Quote:
To be honest, I am not sure how I should define the geometry here, I thought the other method would be easier for me so I have not given this that much time. Do you know what ps1 stands for?
ps1 = planesketch (XYPlane)
ps1.sk1 = sketch on that plane (Sketch1)(Geometry)
ps1.YAxis = axis selection on that plane( Y axis selected as axis to revolve)
agc.DirNormal=Direction Normal
FD1 angle = 0.1
as thin/surface? = No
Code:
var Rev1 = agb.Revolve(agc.Add, ps1.Sk1, ps1.YAxis, agc.DirNormal,0.1, 0.0, agc.No, 0.0, 0.0);
Try this code, it should work
I am not sure how you are defining plane sketch in your model thats why m not able to help!
Code:
var ps1 = planeSketchesOnly1 (new Object());
Command to freeze is:
Code:
Rev1.Operation = agc.Frozen;
if this dosent work then send me your js file and I will have a look.
Hope it helps,

Cheers
KAPI
Kapi is offline   Reply With Quote

Old   April 21, 2015, 11:20
Default Next problem!
  #23
New Member
 
SG
Join Date: Jan 2015
Posts: 29
Rep Power: 11
stessigunn is on a distinguished road
Hi KAPI.

I figured out how you can do this with 3D curves. I created named selection for the geometry I wanted to revolve, and created a sketch to define the axis, might be a complication but at least it worked for me. Then I used "var Rev1 = agb.Revolve(agc.Add, NamedSelection, ps1.YAxis, agc.DirNormal,0.1, 0.0, agc.No, 0.0, 0.0);" to create the revolve.

Onto the next problem. I have created a sketch projection to a plane (ZX plane) from a surface from the 3D geometry. Now I need to script what you would manually do by opening the sketch, choose the modify tab, select duplicate, left click the line you want to duplicate and then right click anywhere on the screen and select duplicate selection to copy the line to a new sketch. I tried to use the "write script: sketch(es) of active plane" but that does not help at all; all I get are the coordinates of the spline, and that is something that is going to vary in my case so I need the spline as a variable. Below is what I have so far, I found the Duplicate command in one of the .js files, but I am not sure how I can use it. Any ideas how to duplicate the projected lines to another sketch?


Quote:
var ZXPlane = agb.GetZXPlane();
agb.SetActivePlane (ZXPlane);
var Plan = ag.gui.CreatePlane(); //Creates a new ZX plane for the sketches
agb.Regen();

var proj = ag.gui.CreateSketchProject(); // insert sketch projection feature
var face1 = ag.m.ModelFaces(1); // select the faces I want to project to the plane
agb.AddSelect(agc.TypeFace, face1);
ag.listview.ActivateItem("Geometry")
ag.listview.ItemValue = "Apply"
agb.Regen();

var sketch1 = plan.NewSketch(); //new sketch to duplicate the lines in
sketch1.name = "sketch1";
ag.gui.Duplicate(); // duplicate command. Do not know how to select the projected lines in the previous sketch and execute the command
Best regards,
SG
stessigunn is offline   Reply With Quote

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

I have never used Duplicate function before and after quick search I was not able to find anything related to Duplicate function other than what you have mentioned.
Duplicate function would rather be complicated cuz you need to do RMB click for Duplicate selection.
I suggest you ask Ansys Customer support for this function and see what they say!

Cheers
KAPI
Kapi is offline   Reply With Quote

Old   April 24, 2015, 08:59
Default
  #25
New Member
 
SG
Join Date: Jan 2015
Posts: 29
Rep Power: 11
stessigunn is on a distinguished road
No solution to the duplicate command yet. But do you know if it is possible to select and edit previous features? I am now thinking of updating geometry files, and was thinking if it would be possible to do this with a script, using something like:

ag.listview.ActivateItem("Refresh");
ag.listview.ItemValue = "Yes";

This should work if I can select features created earlier in the process. (I am importing a bunch of files which I then want to be able to update via script)

Best regards,
SG
stessigunn is offline   Reply With Quote

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

Good Day!

If you want put refresh as "yes" while creating a curve, then you can refer to this thread

It will refresh your geometry automatically when you change the parameter!
Meanwhile I will try to do Duplicate function, btw did you try to contact customer service for duplicate function?? what did they say?

Hope it helps
Cheers
KAPI
Kapi is offline   Reply With Quote

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

If I understand correctly, you are suggesting that you import the curve every time you need to update the geometry. Since I have not found a way to use the duplicte function this would be a problem for me. I would like to be able to refresh the geometry without loosing the features I have created after the import, do you know if that is possible?

Best regards,
SG
stessigunn is offline   Reply With Quote

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

After importing, what are the changes you are doing?
How are you updating your geometry?
Have you setup parameters in your geometry file?
Is it possible to post dome picture here or send me your geometry file to visualize more of what you need?

KAPI
Kapi is offline   Reply With Quote

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

What I do is I create the geometry files(curves and igs) that I import to DM with Matlab. After the import I use some features like revolve, slice, sketch projection(and than I would have wanted to use the duplicate function) etc.

My parameters are in the Matlab file, so when I change them I get a set of new coordinate files, which I would like to refresh in the workbench geometry project without loosing the other features I have created (in this case it's specially the duplicate and blade editor functions).

Hope this make things a bit more clear.

Best regards,
SG
stessigunn is offline   Reply With Quote

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

Let me know if I am wrong,
You are creating Geometry coordinate file in Matlab and then importing it in DM and adding functions like revolve
Then if you update parameters in Matlab which creates another geometry coordinate file which you want to bring in DM without changing functions you have used before.
Basically you don't want to add same functions again.Right?

I dont think You can do that in DM.

You can only update DM if you certain parameters you have specified in DM and those parameters are changing.

If you are importing whole coordinate file again then it will have to check each and every point to see what has changed.
If certain parameters are changing then only you can update DM without touching any of functions.

Hope I am clear.

If you can share your code/drawing/geometry then I can have a look and suggest you something else which mite work in your case!


Cheers
KAPI
Kapi is offline   Reply With Quote

Old   May 4, 2015, 02:49
Default
  #31
New Member
 
SG
Join Date: Jan 2015
Posts: 29
Rep Power: 11
stessigunn is on a distinguished road
Hi KAPI.

In the figure attached is the tree outline of my project. This is all done with one script. All 3D curves and igs import are created in Matlab, and the geometry files will change in an optimization process. Since I can not script the whole geometry (duplicate) I would rather want to do it once manually, and then refresh the import files, rather then running the script every time and manually adding the last features. The new geometry files would be very similar, and I think it would be easier to manually fix the errors in the features after the import, if I would get any. The geometry changes are not that great, so I am hoping most of the functions would not need modification.

Best regards,
SG
Attached Images
File Type: jpg TreeOutline.jpg (25.7 KB, 13 views)
stessigunn is offline   Reply With Quote

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

I am glad that your program is working now.
Keep working to find duplicate function or ways to refresh your curve.
Also, contact customer support if they can help you get some codes from Ansys developers.

One thing crossed my mind, rather than bringing coordinate file for each curve why dont you try to create curve in the script itself.
This mite help you in refreshing your curve.

Give it a go and let me know how it goes!

Cheers
KAPI
Kapi is offline   Reply With Quote

Old   May 20, 2015, 02:48
Default
  #33
Member
 
Max
Join Date: May 2015
Posts: 48
Rep Power: 10
USER1234 is on a distinguished road
Quote:
Originally Posted by stessigunn View Post
Great, thank you KAPI.

I have managed to select edges on bodies and create a surface from edges.
Hi,

can you give me a hint how you did this? I have to write a script to get a volume of a complex tooth by importing a point cloud in designmodeler .. I#ve managed to write the script for getting line bodies from this points. Now I struggle to use skin/loft for line bodies ..

Actually I don't know how to write script for named selection .. maybe this is the actual problem.

Best regards

Max
USER1234 is offline   Reply With Quote

Old   May 20, 2015, 04:31
Default
  #34
New Member
 
SG
Join Date: Jan 2015
Posts: 29
Rep Power: 11
stessigunn is on a distinguished road
Hi USER1234

You can create a named selection of the edges using something like this:

var Edge1 = ag.m.ModelEdges(number of the edge);
agb.AddSelect(agc.TypeEdge3d, Edge1);
ag.gui.CreateSelectionSet();

I did not script the skin/loft command so I am not sure how to do that.

Best regards,
SG
stessigunn is offline   Reply With Quote

Old   May 20, 2015, 04:40
Default
  #35
Member
 
Max
Join Date: May 2015
Posts: 48
Rep Power: 10
USER1234 is on a distinguished road
Quote:
Originally Posted by stessigunn View Post
Hi USER1234

You can create a named selection of the edges using something like this:

var Edge1 = ag.m.ModelEdges(number of the edge);
agb.AddSelect(agc.TypeEdge3d, Edge1);
ag.gui.CreateSelectionSet();

I did script the skin/loft command so I am not sure how to do that.

Best regards,
SG
Hi SG,

thank you for your answer. Is there any possibility to count the single Lines of a Line Body as edges?
Did you do the Skin/Loft with Line Bodies or with single Lines?
How can I use the SelectionSet later to "addBaseObject" for Skin/Loft?

something like this:
skin1.AddBadesObject(SelectionSet);
??

Best regards

Max
USER1234 is offline   Reply With Quote

Old   May 20, 2015, 05:16
Default
  #36
New Member
 
SG
Join Date: Jan 2015
Posts: 29
Rep Power: 11
stessigunn is on a distinguished road
Hi,

Sorry, made a spelling mistake, I did not script the Skin/loft so I am not sure how to do it. To count edges you can use something like this:

var medges=ag.m.ModelEdges();
medges.Count();

Best regards,
SG
stessigunn is offline   Reply With Quote

Old   May 20, 2015, 08:24
Default
  #37
Member
 
Max
Join Date: May 2015
Posts: 48
Rep Power: 10
USER1234 is on a distinguished road
Hi SG,

the code for NamedSelection works and I get "NamedSel(i)" in my Tree Outline. You also got one "NamedSel1" in your TreeOutline in #31 - how do you use it later in script? How can I find the ID of each "NamedSel(i)" and name / choose it later in my script. I want to include the "NamedSel(i)" in my Skin/Loft ...

Best regards
Max
USER1234 is offline   Reply With Quote

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

You have to activate the item where you are using Namedselection first
Code:
ag.listview.ActivateItem("where you want use NS");
and then use listview function, something like this:
Code:
ag.listview.ItemValue = "NamedSel1";
Hope this helps.

Cheers
KAPI
Kapi is offline   Reply With Quote

Old   May 21, 2015, 02:59
Default
  #39
Member
 
Max
Join Date: May 2015
Posts: 48
Rep Power: 10
USER1234 is on a distinguished road
Quote:
Originally Posted by Kapi View Post
Hi User,
...
Cheers
KAPI
Hi KAPI,

thank you for your reply!

I'm really new to writing script like this. The problem is, that I have 2 LineBodies and I can create NamedSelections with a code like this where every NamedSelection contains all 4 Edges of the LineBody:

Code:
ag.gui.ClearSelect();
var Edge1 = ag.m.ModelEdges(1);
agb.AddSelect(agc.TypeEdge3d, Edge1);
var Edge2 = ag.m.ModelEdges(2);
agb.AddSelect(agc.TypeEdge3d, Edge2);
var Edge3 = ag.m.ModelEdges(3);
agb.AddSelect(agc.TypeEdge3d, Edge3);
var Edge4 = ag.m.ModelEdges(4);
agb.AddSelect(agc.TypeEdge3d, Edge4);
ag.gui.CreateSelectionSet();
To continue you gave me the following Code:

Code:
ag.listview.ActivateItem("where you want use NS");
I want to use it for creating a Skin so do I have to name it like this:

Code:
ag.listview.ActivateItem("CreateSkin");
???

Now I have to define the Value for the activated Item - right? The Code for this should be:

Code:
ag.listview.ItemValue = "NamedSel1";
"NamedSel1" should be the CreateSelectionSet which I have created above!? Besides: in the TreeOutline the NamedSelection is also called "NamedSel1".

To Create a Skin I also need the second LineBody so the whole Code should look like this (I will write a loop later for the "var Edge ... AddSelect.."):

Code:
ag.gui.ClearSelect();
var Edge1 = ag.m.ModelEdges(1);
agb.AddSelect(agc.TypeEdge3d, Edge1);
var Edge2 = ag.m.ModelEdges(2);
agb.AddSelect(agc.TypeEdge3d, Edge2);
var Edge3 = ag.m.ModelEdges(3);
agb.AddSelect(agc.TypeEdge3d, Edge3);
var Edge4 = ag.m.ModelEdges(4);
agb.AddSelect(agc.TypeEdge3d, Edge4);
ag.gui.CreateSelectionSet();

ag.gui.ClearSelect();

var Edge9 = ag.m.ModelEdges(9);
agb.AddSelect(agc.TypeEdge3d, Edge9);
var Edge10 = ag.m.ModelEdges(10);
agb.AddSelect(agc.TypeEdge3d, Edge10);
var Edge11 = ag.m.ModelEdges(11);
agb.AddSelect(agc.TypeEdge3d, Edge11);
var Edge12 = ag.m.ModelEdges(12);
agb.AddSelect(agc.TypeEdge3d, Edge12);
ag.gui.CreateSelectionSet();

ag.listview.ActivateItem("CreateSkin");
ag.listview.ItemValue = "NamedSel1";
ag.listview.ItemValue = "NamedSel2";
ag.gui.CreateSkin();
This Code creates "NamedSel1"+"NamedSel2" but leads to an error like this:

"Error: Item not found
Script: ag.listview.ActivateItem("CreateSkin");"

and doesn't create a Skin.

I changed the Code to write "ag.gui.CreateSkin();" at the top before AddSelect the Edges, but this leads to the same error!

Can you help me, what I did wrong?


I've attached a hardcopy of my imported Points which are the reference for the LineBodies. Also 1 NamedSelection is shown (green) and 1 Skin/Loft is executed manually - the tooth should build up with multiple Skin/Loft's like this one!

Best regards
Max

Last edited by USER1234; May 25, 2015 at 06:50.
USER1234 is offline   Reply With Quote

Old   May 25, 2015, 06:51
Default
  #40
Member
 
Max
Join Date: May 2015
Posts: 48
Rep Power: 10
USER1234 is on a distinguished road
... is there anybody who can figure out what I'm doing wrong?

Best regards
Max
USER1234 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 05:40.