Showing results for 
Search instead for 
Do you mean 
Reply

How to check through API whether a node is constrained?

Hello, everybody!

 

I've posted a doubt last week (Using API to check if a node is used as dependent node of either a SPC or a MPC.) and I think it was a little bit complex, and maybe this is why nobody answered it yet. So I am posting this new doubt, that is part of the older, but would be helpful if I get the answer because it would help me go on with my code while I wait by the answer of the other one.
How can I check whether a node is constrained by a nodal constraint or by a constraint equation? The check must be done node by node or it is possible check a set of nodes at once?

 

Best regards,

 

Fabiano.

5 REPLIES

Re: How to check through API whether a node is constrained?

Dear Fabiano,

 

 

There is no ready function to get constraint nodes (or I haven't find one). We solve this by custom function. The idea is that you loop through constraint definitions of nodal and geometric types.

 

If you constraint is applied on nodes it is easier. You get node Id from each BCNode object:

Dim bco As femap.BCNode 

bco.ID - is node ID

 

if you have also constraint on point/curve/surface you have to get them first and then get attached nodes.

 

 

Our function is on VB.net. It is different from VB6 (inside of Femap). If you it will be handy for you I can share it with. (let me know)

 

Yarko

Re: How to check through API whether a node is constrained?

You can do this easily graphically via the Entity Selection dialog -> Method -> ID Constrained (or ID Constraint Equation).

Note that you can use either one or all constraint sets.  Then just drag a box around the whole model and only the constrained nodes will be selected.  

 

You may need to use Model -> Constraint -> Expand if you also want the nodes of constrained geometry to be included.

Re: How to check through API whether a node is constrained?

Hello, Yarko!

 

Actually, I don't need to know what are the constrained nodes, but whether a given node is constrained or not. Based on your hint, I thought to create a Set to store the IDs of all constrained nodes and then check if the given node is contained in this set. It is something like follows:

 

Sub Main
	'Declare variables.
	Dim rc As Long

	'Attach to FEMAP.
    Dim App As femap.model
    Set App = feFemap()

	'Ask user to select the nodes to be checked.
	Dim CheckNdSet As femap.Set
	Set CheckNdSet = App.feSet
	Dim BCNdSet As femap.Set
	Set BCNdSet = App.feSet
	Dim bco As femap.BCNode
	Set bco = App.feBCNode
	Dim InterNdSet As femap.Set
	Set InterNdSet = App.feSet

	rc = CheckNdSet.Select(FT_NODE, True, "Select the nodes to be checked")
	If rc = FE_OK And CheckNdSet.Count > 0 Then
        While bco.Next
    		BCNdSet.Add(bco.ID)
	    Wend
	    InterNdSet.AddCommon(CheckNdSet.ID, BCNdSet.ID)
	    If InterNdSet.Count > 0 Then
	    	While InterNdSet.Next
	    		App.feAppMessage(FCM_ERROR, "Node " & InterNdSet.CurrentID & " is constrained.")
	    	Wend
	    Else
	    	App.feAppMessage(FCM_COMMAND, "None selected node is constrained.")
	    End If
	Else
		App.feAppMessage(FCM_WARNING, "None node selected.")
	End If
End Sub

 

As FEMAP doesn't have a function to check constrained nodes, this could be a way to do this.
I would like to see the function you've mentioned. If you could post it here, it would be nice.

 

Thank you!

 

Fabiano

Re: How to check through API whether a node is constrained?

Dear Fabiano,

 

 

Below you can see function which get constraints nodes from Constraint Set and print them in message window. In attachment you can find text file with code.

 

IMPORTANT: Function reads only constraints applied to nodes. If you need to get nodes from constrainted points/curves/surfaces let me know and I will update this function).

 

 

All nodes are in nodes list. And it is very easy to check if any node is constrainted:

You can loop over your all nodesIDs and call nodes.Contains(NodeID).

 

I think this should help. In case of questions let me know.

 

 

Yarko

 

 

 

 

Re: How to check through API whether a node is constrained?

[ Edited ]

The example I posted above was done in Visual Studio and can't be run in Femap. I've decided to make example for Femap. If somebody is interested you can find attached BAS file.

 

Example prints all nodes from Constraint ID = 1 and checks if node ID = 9 is constrained:

 

Yarko