Hello All this is my first post. I am trying to create an API to select elements from select layers. I am new to the API and this is not working. Can anyone help get this working? I want to select the emelents from layers and store them to use later.
Sub Main Dim App As femap.model Set App = feFemap() Dim rc As Object Dim layerID As Integer Dim propID As Integer Dim elemID As Integer Dim elemSET As Object Dim aProp As Object Dim aLayer As Object Dim csysID As Long Dim printResults As Boolean Dim printDetails As Boolean Dim longueur As Double Dim area As Double Dim volume As Double Dim structmass As Double Dim nonstructmass As Double Dim totalmass As Double Dim structCG As Variant Dim nonstructCG As Variant Dim totalCG As Variant Dim inertia As Variant Dim inertiacG As Variant aLayerSET.Select(FT_LAYER, "Select Layer(s) for Mass Property Check.") elemSET = elemID.ID elemID.AddSetRule(elemSET, FGD_ELEM_BYLAYER)
elemID.AddGroup End Sub
Solved! Go to Solution.
FGD_ELEM_BYLAYER is a strange rule in FEMAP. You do not enter an entity that is on that layer -
Sub Main Dim App As femap.model Set App = feFemap() Dim elSet As femap.Set Set elSet = App.feSet Dim feElem As femap.Elem Set feElem = App.feElem If feElem.SelectID("Pick Seed Element") = FE_OK Then elSet.AddRule( feElem.ID, FGD_ELEM_BYLAYER) elSet.Show( FT_ELEM ) End If End Sub
In this API the user picks a single element, and then that element ID is used as the seed element, elSet is then filled in with all elements matching the layer of the input element.
Yes, the following API will prompt the user for a Layer, and then walk the elements until it finds one on that layer. It then adds all on that layer and jumps of of the element loop -
The HTML Clipboard
Sub Main Dim App As femap.model Set App = feFemap() Dim feLayer As femap.layer Set feLayer = App.feLayer Dim elSet As femap.Set Set elSet = App.feSet Dim feElem As femap.Elem Set feElem = App.feElem If feLayer.SelectID("Pick Layer") = FE_OK Then While feElem.Next = FE_OK If feElem.layer = feLayer.ID Then elSet.AddRule(feElem.ID, FGD_ELEM_BYLAYER) GoTo GOT_EM End If Wend End If GOT_EM: elSet.Show(FT_ELEM) End Sub
There is an API command which is not available in the Femap User interface - but which overcomes the unusual case of how Femap selects entities by layer. Virtually all other selection methods in Femap are direct association (eg. elements on a surface, nodes on a solid, elements of a type). As Mark says, when selecting by layer, you select an entity of a type that you want, which is already on the layer you want, and then Femap collects all the rest of the selected entity type on that layer.
The more direct API command is "AddEntitiesOnLayer"
The negative sign indicates that you are using a single layer id, rather than: "the ID of a Set of layer id's".
This is interesting. forgive my ignorance but is there a way to expand this to select multiple Layers? Such as .SelectMultiID or selectList? Those aren't working and I would really like to try and expand this out so I can select multiple layers.
Also why aren't they working?...if you don't mind educating me.
Well I suppose I may be learning somethings after all! I was able to get a list to pop up and allow me to select multiple layers and use the elements on those layers.
The HTML Clipboard
Dim laySet As femap.Set Set laySet= App.feSet laySet.SelectMultiID(FT_LAYER, 1, "Pick Layers")