Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

Sweeping elements by API

[ Edited ]

I'm using Femap with NX nastran 11.2.2. I'm new to Femap/Nastran, and I have trouble with sweeping elements by API.

 

I sweep two elements with a curve in fig.1, expecting it result in fig.2.

fig1  Initial statefig1 Initial statefig2  Expectedfig2 Expected


At first I sweep the plate element with ID of 1, next I sweep that with ID of 2.

Using GUI, Mesh -> Sweep -> Element*, I can get a result like fig.2, as I expected.
But using API, I got a result of fig.3.
I tried changing order of sweeping (firstly ID of 2, and then ID of 1), it result in fig.4.

fig3 ??fig3 ??fig4 ???fig4 ???

The API code is:

Sub Main
Dim App As femap.model
Set App = feFemap()

Set fset = App.feSet
curves = Array(11&)
aligns = Array()
alignLocation = Array(0#,0#,0#)
fset.Add(1) ' in case of fig.4, fset.Add(2)
femapret = App.feMeshSweepElem(fset.ID,1,curves,0,aligns,alignLocation,1,True,False)
fset.Clear
fset.Add(2) ' in case of fig.4, fset.Add(1)
femapret = App.feMeshSweepElem(fset.ID,1,curves,0,aligns,alignLocation,1,True,False)

App.feViewRegenerate(0)
End Sub

 

In each case of fig.3 and fig.4, first App.feMeshSweepElem() looks like working correctly.

I cannot understand why extra nodes appeared in fig.3 and why secondarily swept elements appeared in the opposite side in fig.4 after second App.feMeshSweepElem(). Am I missing something?

 

I would appreciate your help if you can put some comments.


*Possibly these words in menu bar are not correct, because I'm using a localized version.

2 REPLIES
Solution
Solution
Accepted by topic author Kuro1960
‎10-06-2016 07:05 PM

Re: Sweeping elements by API

This is a bug. When you call feMeshSweepElem( ) the first time, some internal information is not being properly cleaned up and causes your second call to work very strangely. This information is cleaned up when you use the commands from the UI. 

 

We will fix this problem in the next release but in the meantime there some possible workarounds.

 

For the sample you show, rather than using 2 calls to feMeshSweepElem( ) you could add both elements to "fset" and make only 1 call. 

 

I realize however that your actual case might be more complicated than the sample. If it is, the only workaround I can propose will sound rather strange. You will have to call some other API method that doesn't necessarily do anything, but does a general enough cleanup to wipe out the leftover data from feMeshSweepElem( ).  One possible example of this would be to add an invalid call to feProjectOntoCurve( ) as I show below.  This call will give a return code of FE_INVALID because the arguments I show aren't really supported but it will cleanup and the second call to feMeshSweepElem( ) will work as you expect.  Again, the real solution is when we fix the code, but hopefully this can help you until then.

 

The HTML Clipboard

 fset.Add(1)   ' in case of fig.4, fset.Add(2)
 femapret = App.feMeshSweepElem(fset.ID,1,curves,0,aligns,alignLocation,1,True,False)
 App.feProjectOntoCurve( FT_ELEM, -1,-1)
 fset.Clear
 fset.Add(2)   ' in case of fig.4, fset.Add(1)
 femapret = App.feMeshSweepElem(fset.ID,1,curves,0,aligns,alignLocation,1,True,False)

Re: Sweeping elements by API

I found your code correct my problem.

 

I need to call the method more than 1 time, for I have elements to be swept with different property. Your second suggestion is enough and seems reasonable for me.

 

Thank you.