0 Replies Latest reply on Nov 29, 2013 5:46 AM by Hilkka Lemettinen

    From Property Manager Selection Box to Cosmos Shell Manager

    Hilkka Lemettinen

      I'm working with VBA aiming to create a macro which changes the material and thickness in simulation study (something like that, but with suface bodies in the active study:  Create Nonlinear Study and Apply Materials Example). The surface bodies, material and thickness will be given by user. Surface bodies can be selected using Property manager selection box.

               Dim pm_Selection As PropertyManagerPageSelectionbox

               Set pm_Selection = pm_Group.AddControl(SelectionID, controlType, caption, alignment, options, tip)

       

       

               filters(0) = swSelSURFACEBODIES

               pm_Selection.SingleEntityOnly = False

               pm_Selection.AllowMultipleSelectOfSameEntity = False

               pm_Selection.Height = 50

               pm_Selection.SetSelectionFilters filters

       

      How to connect the chosen surface bodies to the shells of CosmosWorksLib.CWShell (Dim Shell As CosmosWorksLib.CWShell)? Is there any other (=better) way than looking for them by using names, that can be achieved by pm_Selection.ItemText?

       

      The problem seems to be when trying to get selections:

       

          For i = 1 To swSelectionMgr.GetSelectedObjectCount2(mark)                      ' This works OK

              ReDim Preserve selectedBodies(1 To i)

              selectedBodies(i) = pm_Selection.ItemText(i - 1)                                        ' This works OK

              MsgBox swSelectionMgr.GetSelectedObjectType3(i, mark)                        ' This works OK

              selObject = swSelectionMgr.GetSelectedObject6(i, mark)                          ' This is not working, selObject is of type Object

              so(i) = selobj

          Next i

       

      Message was edited by: Hilkka Lemettinen