Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Vertices selection in Workbench 4

Status
Not open for further replies.

sachin46

Marine/Ocean
Jun 12, 2013
33
Dear All,
I am using ANSYS workbench Version 19.0 where ,I want to assign the "point mass" on several vertices. For this I have data of vertices in following format

X cord, Y Cord ,Z cord , mass of vertices

In order to assign mass can I select vertices based on their x,y,z location ? I have tried "Named selection"option where I have selected "scoping method"as worksheet .But it is available for x,y,z separately .It will be really helpful for me if anybody explain procedure to select the vertices for mass assignment.
Thanking you
Regards,

Regards,
sachin46
 
Replies continue below

Recommended for you

Dear sachin46,

You can add multiple rows in workbench, and then select x, y and z co-ordinates sequentially.

In case you have large number of vertices you can try using:
1. APDL commands or
2. create a single named selection of all vertices and create a point mass for single vertex manually and then object generator can be used to create point mass for all other vertices.
 
You can create named selection for each point using the following python code
in ACT console. Requirement is that point coordinates and masses are list of lists.
The code could be developed further by generating the point masses based on these
named selection. I tried it but was not successful in changing "scoping method" of
point masses using code.

#coordinates for each point, last item in each row is the mass
vertex_coordinates = [[0,0,0.01,10], [0,0.1,0.01,20], [0.1,0.1,0.01,30],[0.1,0,0.01,40]]


model = ExtAPI.DataModel.Project.Model
geom = model.Children[0]


for vertex in vertex_coordinates:

sel = model.AddNamedSelection()
sel.Name = "Point"
selws = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.WorksheetSpecific)
sel.Location = selws
point_ws = sel.Location

point_ws.AddRow()
point_ws.SetEntityType(0,NamedSelectionWorksheetEntityType.Vertex)
point_ws.SetCriterion(0,NamedSelectionWorksheetCriterion.Location_X)
point_ws.SetOperator(0,NamedSelectionWorksheetOperator.Equal)
point_ws.SetValue(0, vertex[0])

point_ws.AddRow()
point_ws.SetAction(1,NamedSelectionWorksheetAction.Filter)
point_ws.SetEntityType(1,NamedSelectionWorksheetEntityType.Vertex)
point_ws.SetCriterion(1,NamedSelectionWorksheetCriterion.Location_Y)
point_ws.SetOperator(1,NamedSelectionWorksheetOperator.Equal)
point_ws.SetValue(1,vertex[1])

point_ws.AddRow()
point_ws.SetAction(2,NamedSelectionWorksheetAction.Filter)
point_ws.SetEntityType(2,NamedSelectionWorksheetEntityType.Vertex)
point_ws.SetCriterion(2,NamedSelectionWorksheetCriterion.Location_Z)
point_ws.SetOperator(2,NamedSelectionWorksheetOperator.Equal)
point_ws.SetValue(2,vertex[2])

point_ws.Generate()


As previous poster said, probably the quickest way is to select the points manually and make a named selection of them and then use
object generator.

 
Dear SAG8 ,
Thank you very much for your help.
I would like to know how APDL commands can be used for this.
I am new to ANSYS workbench but knows APDL very well. I will appreciate if you explain this with an example.
Thanking you.,

Regards,

Sachin46
 
Hi Sachin46,

I've not verified this script but hopefully it gets you close:
Code:
! Assumes following arrays of dimension 'numlines' exists: 'x', 'y', 'z', 'MassOfVertices'
numlines = 1000

/prep7
alls
*get, etmax, etyp, 0, num, max
*get, rcmax, rcon, 0, num, max
et, etmax+1, 21, 0,0,2 ! mass only

type, etmax+1
*do, ct, 1, numlines
    nnow = node(x(ct), y(ct), z(ct)) ! node at vertice
    r, rcmax+ct, MassOfVertices(ct)  ! mass of element
    real, rcmax+ct
    e, nnow ! creates mass21 element
*enddo


Kind regards,
Jason
 
Dear sk_cheah,
Thank you for your reply but I am working in ANSYS workbench
 
Hi Sachin46,

Sorry, I should have added that the above script may be used as an APDL command snippet in Ansys Workbench. Example animation below:
gds_search_parameters_anim.gif



Kind regards,
Jason
 
Dear L_K,
Thank you very much for your help.
I have created "coordinate.txt"file in folder named "user_files" and run code which is given by you in ACT console.
But i got error message "EOL while scanning single-quoted string".Please check following screen shots for your reference.

file_ggz68t.png

err_g6j7ru.png


Kindly help on above error
Thanking you

Regards,
SACHIN46
 
The picture is a bit fuzzy. Is the last row missing parenthesis in the end?
 
even if I put parenthesis for last sentence it is showing same error.Please check following image
Untitled_nfxxjf.jpg
 
I just tested the code in 17.2 and it worked in Windows 7. Are you by any chance on Windows 10?
Try running the code one line at a time. I suspect defining userdir variable is the cause of problem
(because of the escape character \).
 
Based on link, try perhaps...
Python:
pm.Mass = Quantity(str(vertex[3])+" [kg]")


Kind regards,
Jason
 
Last line of the code I posted is following.
Kg is not in parenthesis.

pm.Mass = Quantity(vertex[3],'kg')
 
L_K

LK Your Script works fine for me. Good work[2thumbsup]. Would you please suggest any resource to learn the automation through python?(other than ACT learning material on customer portal)

Also Thumbs up to sk_cheah aka Jason.[thumbsup] Your command on APDL is commendable.

A star for both of you.

 
ACT Mechanical 17.0 in portal is quite throughout. I have been able to complete
all my codes using only it and manual as a source. There are also some videos in Youtube.
If you are not already familiar with Python, Automate Boring Stuff With Python is good.


 
Hi L_K ,
I got my error [smile2] code is running well .Thank you very much for your help.
Only thing I am looking in code that in "named selection " location of point mass is coming under the name "Point".

Untitled_jzpt2m.bmp


It will be better if it comes as "Point 1,point 2, point 3,.......",so that for assignment of Named selection for particular point mass it will be easy. e.g. Point Mass 2 named selection such as "Point 2 "will be useful instead of "point" only.Please check following image
Untifftled_uwrd8y.jpg

Thank you
 
There are a few options. One is to use enumerate to keep track of
the index:

for num, vertex in enumerate(coordinates, start=1):

...
sel.Name = "Point " + str(num)
...
...

pm.Name = "Point " + str(num)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor