Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

APDL macro to export element numbers form Workbench named selections to an external text file. 2

Status
Not open for further replies.

-orion-

Structural
Dec 27, 2017
3
Hello everyone!

I am a beginner structutal analysis engineer working for an aerospace company.

Problem description:

Usually only a small portion of the mesh has significant stress and needs to be included in downsteam fatigue post-processing. To tell the external fatigue solver which parts of the mesh to analyse I have to export element lists from Wrokbench. External fatigue solver requires the text file to be formated nastran-wise (hence the hard coded FSET3 and ELEM keywords and 8 charter per column formatting).

I have written a macro (pasted below) which works properly as long as I specify whole bodies as named selections in WB. It then outputs a separate text file for each named selection named EXPORT1, EXPORT2, EXPORT3 which contain elements for that particular selected body.

Subsequently I tried to limit the scope of the export even further because usually I do not require an entire body to be analysed for fatigue. It is sufficient for me to export just a few critical fillets of a body. The problem is that when I specify a face or even use the worksheet add>face>convert to>mesh node>convert to> mesh element to create the named selection the macro does not work properly, it starts putting out all the nodes in the model! Right clicking on the named selection and exporting manually to a text file is of no use since I require the element numbers and not the node numbers WB writes out.

Here is the macro that works properly only when EXPORT%l% is scoped on a body, does anyone know what I did wrong? Can anyone point me in the right direction? Thanks in advance :).

!EXPORT_MACRO:
! Input:
ll=5 ! number of bodies to export
!------------------------------------------------------------------
*dim,s,string,24
*do,l,1,ll,1
cmsel,s,EXPORT%l%,elem
*get,ee,elem,,count
e_id=0
*cfopen,EXPORT%l%,out
val=chrval(l)
s(1)='FSET3'
s(9)=val
s(17)='ELEM'
*vwrite,s(1)
%C
*do,i,1,ee,1
s(1)=' '
*GET,e_id,ELEM,e_id,NXTH
s(9)=chrval(e_id)
*vwrite,s(1)
%C
*enddo
*cfclose
allsel
*enddo
 
Replies continue below

Recommended for you

Try to modify the selection procedure like below. I think basically if you
use cmsel on a face, nodes will be selected. In the below code
elements associated with the selected nodes are picked.

The last line (select only SOLID186 elements) is added because
the second line might select also surface effect elements
(SURF154), which are associated with the nodes.



#####
cmsel,s,EXPORT%l%
esln,s
esel,r,ename,,186
#####
 
Hi -orion-,

Using worksheet to create the named selection (add>face>named selection>convert to>mesh node>convert to> mesh element [any node]), then renaming that new named selection as export1 in WB, I was able to run your script without any problems.

Does the preview of the elements selected what you expect? Mine looks like this:
w3mf6y8.png



Happy new year,
Jason
 
Hi Gents, I forgot to add I am using Workbench 18.2.

I have implemented L_Ks suggestions as psted below (just changed the element type to 187 as the cast housings I analyse are usually meshed with TET10s).

It seems to have solved some of the problems and exports properly (In Ansys WB 18.2) when the EXPORT named selection is scoped on a face (yay!).

It does incorrectly export all the tets in the model (in all bodies!) when scoped to a single body or to a worksheet via add>face>named selection>convert to>mesh node>convert to> mesh element [any node]).

Examples of reuslts after the esln and esel additoin:

1)A fillet containing 10k elements in the first layer exports correctly with 10k elements in the txt file as long as the named selection is scoped on a face or faces (thats fantastic, I'm almost home ;).

2) When I make a nodal named selection on the aforementioned face and convert it to nodes then mesh elements as per sk_chehah's suggestion Ansys WB displays the selection correctly and lists the correct number of elements selected in the "statistics /total selection" box in WB. Only the 1st layer of elements is visible the rest is translucent as in sk_cehah's screen. Unfortunately the macro export is incorrect. I get ALL the tets in the ENTIRE MODEL the text file. The same goes when I scope the named selection to a body with the new modified macro- i get all tets from all bodies in the txt output.

sk_cheah:
I know the macro runs without errors but are You sure it exports exactly what You told it to do?
Try scoping bodies (have more than one with tets in the environment and scope 1 for export).
Try scoping faces and lastly scoping nodal named selections converted to mesh elements via worksheet and you should start to see inconsistencies in the output.

To sum the matter up:

The old macro exported bodies properly and worksheets properly(add>face>named selection>convert to>mesh node>convert to> mesh element [any node]) but not faces.
The modified macro exports elements from named selections scoped on faces properly, but exports all tets in the model when scoped on bodies or nodal named selections form worksheets.


I cant seem to get everything quite right :), is it possible to have a macro which exports everyhing correctly regardless of what I scope or is it too mych to ask from Ansys and I'll have to watch out which feature I export with which macro?

Can You guys help? Thanks :)


!EXPORT_MACRO_2.0:
! Input:
ll=5 ! number of bodies to export
!------------------------------------------------------------------
*dim,s,string,24
*do,l,1,ll,1
cmsel,s,EXPORT%l%
esln,s !NEW CODE
esel,r,ename,,187 !NEW CODE
*get,ee,elem,,count
e_id=0
*cfopen,EXPORT%l%,out
val=chrval(l)
s(1)='FSET3'
s(9)=val
s(17)='ELEM'
*vwrite,s(1)
%C
*do,i,1,ee,1
s(1)=' '
*GET,e_id,ELEM,e_id,NXTH
s(9)=chrval(e_id)
*vwrite,s(1)
%C
*enddo
*cfclose
allsel
*enddo
 
Try this. Only change is on the second row (s --> r).

cmsel,s,EXPORT%l%
esln,r !NEW CODE
esel,r,ename,,187 !NEW CODE

Few tips for the future:

Element and node selections are separate.
In Workbench, command cmsel selects either elements (if named
selection is scoped on a body) or nodes (if named selection is scoped
on a face, edge or point).
 
I got this macro working on my test model whether the named selection was scoped to a body
or face.

Actually in the case of body named selection the 2nd and 3rd row are not needed.
I am sure there is a more sophisticated way to accomplish this.
 
Hi L_K

I am aware that part of the code is redundant but I wanted to make it "foolproof" and exporting valid output regardless what the uses specifies.
I am not the only person who will use this macro nad it has to be as robust and user friendly (or idiot-proof ;) )as possible...

The last change from s to r fixed everything, now the output is exactly what I wanted regardless whether I scope a body a face or a worksheet :).

Thank You very much, have a happy year, all the best in 2018 :D.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor