turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Navigation
- Simcenter
- Forums
- Blogs
- Knowledge Bases

- Siemens PLM Community
- Simcenter
- 3D Simulation - Femap Forum
- API: Create Contraint Equation

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-16-2016 10:00 AM - edited 05-20-2016 03:59 PM

I started a thread and deleted it because I thought I found my answer. Looks like that was premature. I am trying to create a contraint equation using the API but the I don't understand the documentation. I know I need to create a BCEqn, but I can't seem to piece together the methods necessary to do so.

For example, I want to create an equation like the following:

{Node 1, DOF 6} = {Node 2, DOF 6} - {Node 3, DOF 6}

I can't figure out how to set these coefficient and DOF properties.

Solved! Go to Solution.

2 REPLIES

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-19-2016 01:47 PM

To create a constraint equation, you'll first need to create a constraint set (if you don't have one in your model), then use the BCEqn object to create the constraint equation.

Within the BCEqn object, there are 3 arrays, dof (1-6), node and coefficient. The length of the array corresponds to the number of terms in your constraint equation. Each index within each of the arrays needs to match up, so

[node1] [dof node 1] [factor node 1]

Say, have a 100 element model that was just generated with a simple 10x10 mesh and would like to create an MPC that ties together TX, TY and TZ. If the user selects 15 nodes, then each constraint is its own term, so the total array length is actually going to be 15 * 3 = 45.

Here's some code that should help. If you would like to practice with this, use the Mesh->Generate command (F11) and just create a 10x10 mesh of plotel's.

Code:

Sub Main Dim App As femap.model Set App = feFemap() Dim fsNode As femap.Set Dim fBCS As femap.BCSet Dim fBCD As femap.BCDefinition Dim fBCEq As femap.BCEqn Set fsNode = App.feSet Set fBCS = App.feBCSet Set fBCD = App.feBCDefinition Set fBCEq = App.feBCEqn Dim nnNodes() As Long Dim nnDof() As Long Dim ddFactor() As Double Dim nCount As Long Dim i As Long ' Ask the user which nodes to apply BCEqn If fsNode.Select( FT_NODE, True, "Select nodes" ) <> FE_OK Then Exit All ' Get the number of selected nodes and size the arrays ' for TX, TY, TZ. Array is size from 0 to number * 3 - 1 ' because there's going to be 3 DoF for each node nCount = fsNode.Count() ReDim nnNodes( 0 To nCount * 3 - 1 ) ReDim nnDof( 0 To nCount * 3 - 1 ) ReDim ddFactor( 0 To nCount * 3 - 1 ) ' Loop through the set of nodes and populate the arrays fsNode.Reset() i = 0 While fsNode.Next() ' Because we're setting 3 constraints for each node, ' each ID is repeated 3 times. DoF array is different ' and factor array could be different nnNodes( i * 3 + 0 ) = fsNode.CurrentID nnNodes( i * 3 + 1 ) = fsNode.CurrentID nnNodes( i * 3 + 2 ) = fsNode.CurrentID ' Set TX (1), TY (2), and TZ (2) DoF nnDof( i * 3 + 0 ) = 1 nnDof( i * 3 + 1 ) = 2 nnDof( i * 3 + 2 ) = 3 ' Set factors, just use all 1.0, 2.0 and 3.0 for this example ddFactor( i * 3 + 0 ) = 1.0 ddFactor( i * 3 + 1 ) = 2.0 ddFactor( i * 3 + 2 ) = 3.0 ' Increment counter i += 1 Wend ' Create constraint set fBCS.title = "Demo Set" fBCS.Put( App.Info_NextID( FT_BC_DIR ) ) ' Create constraint defintion ' setID property should be equal to ID for BCSet object ' OnType is Node ' DataType = FT_BEQ for constraint equation fBCD.setID = fBCS.ID fBCD.title = "Constraint Equation Defintion" fBCD.OnType = FT_NODE fBCD.dataType = FT_BEQ fBCD.Put( fBCD.NextEmptyID() ) ' Setup constraint equation ' setID needs to be equal to ID from set object ' BCDefintionID is from the constraint definition ' Object properties can be set individually, but it can be ' easier to use the PutAll method instead to set everything ' at once ' Count term in the method is not the number of nodes, ' but rather the total number of terms fBCEq.PutAll( fBCEq.NextEmptyID, fBCS.ID, fBCD.ID, _ UBound( nnNodes ) + 1, nnNodes, nnDof, ddFactor, _ FCL_BLUE, 1 ) End Sub

Here's a model with a created BCEqn on some selected nodes:

And verified via UI:

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-13-2016 01:43 PM

Perfect. Thanks so much for taking the time to post this explanation!

Follow Siemens PLM Software

© 2017 Siemens Product Lifecycle Management Software Inc