Showing results for 
Search instead for 
Do you mean 

API - Constraint, Spider Curves



I am writing an API that creates meshes a plate with a hole, applies constraints, loads and then runs static analysis.


I already have the model created with material and property. I have written the code for meshing the surface of the plate. My questions are:


1) Is there any examples showing how to use the spider curves command from with the api. I want to apply load at the centre of the hole so I need to create a spider curve but I am not sure how to do it. I can copy the entire code from the "Spider Cuves.bas" into a function in my program but that does not seem efficient.


2) I want to create  a new constraint on the boundary curves (not the nodes on the curve) of the plate. Is there any example showing this. I looked through the Femap API Manual but there are not many methods on this. 






Re: API - Constraint, Spider Curves

Hi saptarshi14datt,


here is an API to create Rigid from Node to Surfaces:


'Create Rigid from Node to Nodes on Surface
Dim App As femap.model
Dim surfaceSet As femap.Set
Dim nodeSet As femap.Set
Dim feRigid As femap.Elem
Dim activeLayerID As Long
Dim surfaceID As  Long
Dim RigidID As Long
Dim nodeID As Long
Dim tmpNodeID As Long
Dim nodeArray() As Long

Sub Main

	Set App = feFemap()
	Set surfaceSet = App.feSet
	Set nodeSet = App.feSet
	Set feRigid =App.feElem

	App.feAppMessage( FCM_COMMAND, "Create Rigid from Node to Nodes on Surface")

	If App.Info_Count(FT_NODE)<1 Then
		App.feAppMessage( FCM_ERROR, "Node isn't exist - Cancelled")
		App.feViewRegenerate( 0 )
		Exit Sub
	End If

	If App.Info_Count(FT_SURFACE)<1 Then
		App.feAppMessage( FCM_ERROR, "Surface isn't exist - Cancelled")
		App.feViewRegenerate( 0 )
		Exit Sub
	End If


	rc = nodeSet.Select( FT_NODE, True, "Select Node as Rigid Independent Node (Cancel for Exit)")
	If rc=FE_CANCEL Then Exit Sub
	If nodeSet.Count<>1 Then
		App.feAppMessage( FCM_ERROR, "No one Node is selected - Cancelled")
		App.feViewRegenerate( 0 )
		Exit Sub
	End If


	rc = surfaceSet.Select( FT_SURFACE, True, "Select Surface to Create Rigid (Cancel for Exit)")
	If rc=FE_CANCEL Then Exit Sub
	If surfaceSet.Count<1 Then
		App.feAppMessage( FCM_ERROR, "Surfaces isn't selected - Cancelled")
		App.feViewRegenerate( 0 )
		Exit Sub
	End If

	rc=nodeSet.AddSetRule( surfaceSet.ID , FGD_NODE_ATSURFACE)

	If nodeSet.Count=0 Then
		rc=MsgBox ("There aren't any Nodes on selected Surface" & vbCrLf & vbCrLf & "Do you want to continue?", _
			vbYesNo, "Create Rigid from Node to Nodes on Surface")
		If rc=vbNo Then GoTo SELECT_NODE
	End If

	If nodeSet.Count>0 Then
		ReDim nodeArray(nodeSet.Count-1)
		For i=1 To nodeSet.Count

		feRigid.Node(0)=nodeID	'Independent Node
		feRigid.release(0, 0)=True
		feRigid.release(0, 1)=True
		feRigid.release(0, 2)=True
		feRigid.release(0, 3)=True
		feRigid.release(0, 4)=True
		feRigid.release(0, 5)=True
		rc=feRigid.PutNodeList(0,UBound(nodeArray)+1, nodeArray, Null, Null, Null)
		If rc=FE_FAIL Then MsgBox "Unable to create the Rigid Element"
	End If

	App.feViewRegenerate( 0 )

End Sub


Best regards,


Peter Kaderasz



Re: API - Constraint, Spider Curves

Hi Peter,


Thanks. for your help. However, I am already aware that such a function already exists. I wanted to know how can I call that function from within my code and pass on the parameters.





Re: API - Constraint, Spider Curves

[ Edited ]

For item 2, setting up constraints, I have come up with the following code. However this does not seem to work:


The HTML Clipboard

The HTML Clipboard

'Set containing  curve  where constraints are placed on the nodes
Dim BC_Curve_Set As femap.Set
Set BC_Curve_Set = App.feSet
rc = BC_Curve_Set.AddRule(5,FGD_CURVE_ID)

'Set containing the nodes on the curves which are to be constrained
Dim Constraint_nodes_set As femap.Set
Set Constraint_nodes_set = App.feSet
rc = Constraint_nodes_set.AddNodesOnGeometry(FT_CURVE,BC_Curve_Set.ID,True,False,False)

'Setting up a constraint set
Dim constraint_set As femap.BCSet
Set constraint_set = App.feBCSet
constraint_set.title = "Constraint Set"

'Setting a constraint definition
Dim constraint_def As femap.BCDefinition
Set constraint_def = App.feBCDefinition
constraint_def.ID = constraint_set.ID
constraint_def.title="Nodal Constraint"
constraint_def.OnType = FT_NODE
rc = constraint_def.Put(constraint_def.NextEmptyID )
'rc = constraint_def.PutAll(1,FT_BCO,FT_NODE,"Constraint Set")

'Setting pinned constraints on the Nodes
Dim constraint_nodes As femap.BCNode
Set constraint_nodes = App.feBCNode
rc = constraint_nodes.Add(Constraint_nodes_set.ID,True,True,True,False,False,False)