API: Access all View Options for Groups

Experimenter
Experimenter

I created some API-program, which is used to apply the active view of an active model to other potentially loaded models in the same FEMAP session. Afterwards, the active view is stored in every model with an offset, so views can later be retrieved after going through post processing.

 

I now want to extend the API in regard to the group view options. When you open the visibilty menu (CTRL+Q) in FEMAP, there are 4 checkboxes for group view options (see picture below, sorry for the German interface): whole model, active group, single group, multiple. From the API help I learned how to manipulate the options marked green via the view.group() method. Is there a way to access the modifier for "single group", which I marked as orange? My goal is to change the active group to single group status upon calling the program and apply this setting the other models.

 

This would be my favorite option as it would best serve our needs. I know that you can use the "active group" option as workaround, but I still would like to know if the single group option is somehow accessible via FEMAP API.

 

Thanks in advance, psaito.

 

Ashampoo_Snap_2018.10.09_15h24m48s_002_.png

 

8 REPLIES 8

Re: API: Access all View Options for Groups

Siemens Phenom Siemens Phenom
Siemens Phenom

You have really already found how to do it. You are setting the Group parameter on the view to 0, -1, -2 to control the radio buttons. All you have to do is set the same parameter to the positive ID of an existing Group and that will be used as the "single group".

Re: API: Access all View Options for Groups

Experimenter
Experimenter

You are right, just tried it on a test model. Thanks a lot, somehow this option didn't come to my mind...

 

Another short question:

 

While working out the solution for the API I got into some trouble with saving the visibility status of layers. I had the impression, that one should be able to store the status of layer visibility in a view object. However, this did not work. I experienced the same when saving the view from a model and loading it into another. The layer visibility would be reset to no layer being visible. Then again, using the combination command worked flawleslsy. I believe this is not intentional?

 

For my solution I had to store the visible layer ID's in an array and retrieve layer visibility this way.

Re: API: Access all View Options for Groups

Siemens Phenom Siemens Phenom
Siemens Phenom

I will say that the interface to this isn't very elegant. I'll see what we can do about that in the future. However, it should work as it is today.

 

An API like this...

The HTML Clipboard

Sub Main
    Dim App As femap.model
    Set App = feFemap()

    Dim v As femap.View
    Set v = App.feView

    v.Get(1)
    v.ShowAllLayers = False
    v.SetLayerVisible(2, True)
    v.Put(1)
End Sub

should Get View #1 and change it to show just Layer 2. You do have to set ShowAllLayers to False to get just the selected layers to show. The only real problem is that there isn't any way to set all layers on/off, so in general you would have to cycle thru all layers to make sure you have exactly what you want.

 

 

Re: API: Access all View Options for Groups

Experimenter
Experimenter

Yes, I am aware of the ShowAllLayers "problem". That's exactly how I had to implement it.

 

But this is not the problem I am adressing. Using your code example, if you were to "transfer" the stored view to another model in the same femap session via Put(), it would transfer all the visibility options just fine. Except for layer visibility. All layers would be turned invisible instead. As explained earlier, this also happens when you store a view manualy (from femap, not API) and load it into another model. The only way to get layer visibility correctly transferred is by using the combine model interface, from file -> combine models. I think this should be more consequent, so that all of the described methods lead to the same result.

Re: API: Access all View Options for Groups

Siemens Phenom Siemens Phenom
Siemens Phenom

I see what you are saying. When you say "...store a view manualy (from femap, not API) and load it into another model...." I assume you are saving the View to the View Library and then loading it into another model?  Is this correct?

Highlighted

Re: API: Access all View Options for Groups

Experimenter
Experimenter

Yes, that's it. I think you basicaly have 2 options when you want to transfer one view from a model to another, don't you? Either you save the active view to the library and load it into the other model or use file -> combine and check views only.

I guess most people will not really run into trouble regarding visible/invisible layers when loading views. It is just a bit annoying when you work with views and layers a lot.

Re: API: Access all View Options for Groups

Siemens Phenom Siemens Phenom
Siemens Phenom

What version of FEMAP are you using?  I ask because in every version I have tried saving a View to the Library and reloading it does "work". The visible layers are transferred correctly. I will say that there are a few caveats. In most cases I had to do an Autoscale to see my model...initially when you load the View the window goes blank. Also, I suspect this isn't your issue, but of course the corresponding Layers have to actually exist in the the model you are loading the View into. 

 

This last point highlights a problem with trying to do what you were doing with the API. When you get an entity from one model and put an entity to another all of the things that entity could potentially reference internally may or may not be there in the other model. While technically you can make this work, we don't really support this approach in the API and I would caution against it. There is no way for you to be 100% sure that everything will be correct in the model where you save the entity. If you do try this method, I would definitely suggest running a File->Rebuild after you are done just to point out any issues and clean up any internal pointers that probably are incorrect.

Re: API: Access all View Options for Groups

Experimenter
Experimenter

Now, that made me wondering... it took another call to a colleague and some experimenting to identify the problem.

The method my colleague uses, and this is also the method I assume you were using, is loading views via the visibility menu (CTRL+Q). Using this method, everything works perfectly fine! Now, what I did before was trying to load views via View -> Create/Manage! There, I have a hard time understanding what is going on to be honest. I'll try to sum it up in comparison:

 

1) via CTRL+Q: view from the library is loaded into the active view (usually view#1), everything works fine.

2) via View-> Create/Manage: the designated view is stored as a new view (e.g. view#2 in case #1 was active), but layers are all off; instead, layer visibility from the loaded view would be applied to the formerly active view, that is view#1.

 

For clarification: In my test model, I had one view (#1) and 3 layers (1,2 and the construction layer 9999), layer #1 being visible. The loaded view had layer #2 visible. Using method 2), the loaded view was stored as view#2, but all layers were turned off. In view#1 however, layer #1 was turned off and layer #2 on.

 

I don't know what to  make of this, maybe one of you does. On a sidenote, we use 11.4.2 and that's also were I did all the testing.