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

API move nodes by deform question

Hi all,

 

We are building a program that needs to (among other things) move nodes according to the deformation output of a pre specified output set.

 

Basically, the desired operation is the same as the 'Nodes move by deform' script found under the Custom Tools.

 

Unfortunately, as we are making a stand alone application, the application writes each new coordinate to the Femap model, which costs a lot of time. I think this is because of the delay in communication between applications.

 

The question now is:

Is it possible to update all node coordinates at once, with each node having a different coordinate?

 

My code now is:

 

Public Sub DeformModel()


Dim DeformResults As femap.Results = app.feResults
Dim numColumns As Integer
Dim colIndices As Object
Dim dataLoc As Long
Dim NodeID As Object
Dim NodeDeformationResult As Object

 

DeformResults.AddColumn(CurrentOutputSet, 1, True, numColumns, colIndices)
DeformResults.DataLocation(dataLoc)
DeformResults.Populate()

 

DeformResults.GetColumns(numColumns, colIndices, NodeID, NodeDeformationResult)
Dim List As Integer
Dim ListX As Integer
Dim ListY As Integer
Dim ListZ As Integer
Dim AddFour As Integer = 0
Dim ListLength As Double
Dim ListXPos As Double
Dim ListYPos As Double
Dim ListZPos As Double

 

For Each Item As Integer In NodeID
List = AddFour
ListX = 1 + AddFour
ListY = 2 + AddFour
ListZ = 3 + AddFour
ListLength = NodeDeformationResult(List)
ListXPos = NodeDeformationResult(ListX)
ListYPos = NodeDeformationResult(ListY)
ListZPos = NodeDeformationResult(ListZ)
app.feMoveBy(zDataType.FT_NODE, -Item, False, ListLength, {ListXPos, ListYPos, ListZPos})
AddFour += 4
Next


End Sub

 

2 REPLIES
Solution
Solution
Accepted by topic author Michael684
‎09-01-2016 07:55 AM

Re: API move nodes by deform question

Hi,

Help > API > 5.43.2: either PutAllArray or PutCoordArray node methods . "This method is even faster than PutAllArray, and requires less memory, it does not however give you full control. The same layer, color... are used for every entity - only the coordinates are input as an array."

You'll pass new coordinates as an array and in only 1 call all node locations will be updated.

AP

Re: API move nodes by deform question

Thanks astrium_tls, it worked!

 

For who's interested I posted the code below. Note that I convert Arrays to lists and back. I couldn't find another way to cull NodeDeformationResult to exclude the total displacement vector.

 

'Get the deformations from the model
Dim DeformResults As femap.Results = app.feResults
Dim numColumns As Integer
Dim colIndices As Object
Dim dataLoc As Long
Dim NodeID As Object
Dim NodeDeformationResult As Object
DeformResults.AddColumn(CurrentOutputSet, 1, True, numColumns, colIndices)
DeformResults.DataLocation(dataLoc)
DeformResults.Populate()
DeformResults.GetColumns(numColumns, colIndices, NodeID, NodeDeformationResult)

'Convert the deformation array to a list
Dim DeformationListXYZArray() As Double = NodeDeformationResult
Dim DeformationListXYZList As New List(Of Double)
DeformationListXYZList = DeformationListXYZArray.ToList

'Remove the total vector of XYZ
Dim AddThree As Integer = 0
For Each Item As Integer In NodeID
DeformationListXYZList.RemoveAt(AddThree)
AddThree += 3
Next

'Get coordinates of nodes
Dim FemapNodes As femap.Node = app.feNode
Dim NumNode As Integer
Dim NodeID2 As Object
Dim CoordinateList As Object
FemapNodes.GetCoordArray(0, NumNode, NodeID2, CoordinateList)

'Update the coordinates of the nodes
Dim XYZCoordinateUpdate As New List(Of Double)
For ItemCount As Integer = 0 To DeformationListXYZList.Count - 1
XYZCoordinateUpdate.Add(CoordinateList(ItemCount) + DeformationListXYZList(ItemCount))
Next
Dim XYZCoordinateUpdateArray() As Double = XYZCoordinateUpdate.ToArray
FemapNodes.PutCoordArray(NumNode, NodeID, XYZCoordinateUpdateArray)
app.feViewRegenerate(0)