PropertyManagerPage

Hi all

A few questions about PropertyManagerPage, in VBA :

  1. Normally, controls appear on the PropertyManagerPage in the order they are declared. Except that apparently groups have priority over controls without a group. This is a personal conclusion, I have not found any indication in the documentation. Can anyone confirm?

  2. Does the PropertyManagerPage API allow you to reproduce all the PropertyManagers you see in solidworks:

    2.1. In the Constraint PropertyManager, icons are seen on the tabs. I haven't figured out how to do the same thing in a PropertyManagerPage.

    2.2. In the Constraint PropertyManager, there is text after the buttons to select the constraint. I know how to create these buttons, but I don't know how to add text behind them.

Le PropertyManager Contraintes

  1. Where to find examples of how to manage .Net control or ActiveX control in a
    PropertyManagerPage? This may be the solution to my points 2.1. and 2.2.

Basically, my PropertyManagerPage works, it's more about usability than anything else.

Thank you

Benedict

Hello @binoyte ,

PropertyManagerPage, a vast subject...
It allows a user/SW interface to be integrated into the SW environment, with standard and specialized components, all with a Solidworks look.

With three levels of containers: the page itself, tabbed cards (PropertyManagerPageTab), and groups (PropertyManagerPageGroup).
Each container can receive various and varied controls, similar to those of a UserForm (such as Label, TextBox, Button, etc.), and other specialized controls (selection of SW objects).

But the management of the position of the controls within the page is quite basic.
The problem is that Solidworks itself defines the position of the controls in the PropertyManager page, at least partially.
Let me explain: at the beginning, a tab card is created in the page. In this card, a button (PropertyManagerPageButton) and a group (PropertyManagerPageGroup) are created, in this order. We would logically expect to see the button placed above the group. In fact, it is placed underneath, thanks SW.
Because SW gives priority of position to the group(s), the buttons will come after...

It is also impossible to fine-tune the position of controls within the same container.
Since a Label and a TextBox are defined in the same group, they are by default placed one below the other with only one indentation, single or double.

This limitation can be circumvented by casting the Label (of type PropertyManagerPageLabel) to the OLE Variant type, and the TextBox (of type PropertyManagerPageTextBox) to the OLE Variant type. The controls thus take advantage of the Top and Left properties of their " ancestors " (such as PropertyManagerPageControl), which allows them to force their positions in the container.
image

But there too with limits since SW keeps all this under surveillance: the Left property seems to be limited to the interval [0... 100], making it impossible to place multiple buttons across the entire width of the page.
It is impossible to complete the line with 4 or 5 buttons.

image

As for the icons in front of the page components, they are displayed by the SetPictureLabelByName method defined for the controls. Again, you need to cast the components to the PropertyManagerPageControl type, or an OLE Variant neutral type.
image

Not to mention a few other miseries...

1 Like

Hello;

An example is available in the Solidworks Help:
https://help.solidworks.com/2024/english/api/sldworksapi/Create_PropertyManager_Page_Example_VB.htm
or a video of SolidXperts:

Thank you for your feedback @m_blt !

For the time being, casting objects despite their limitation, will satisfy me well.

On the other hand, apart from the standard types of vba as Cstr I don't really know how to do it. Set monControl = new Variant OLE ?

@Maclane I am familiar with the examples of online help. That's how I got started. But if you look closely, despite what is said at the top of the page, there is no ActiveX control. The lines are commented. And my research to go further stalled.

On the other hand I don't know the youtube tutorial; I'm going to watch it asap.

The cast is implicitly handled by VBA: a button named PrMgrButton " points " to a control named PrMgrControl by a simple assignment:

dim PrMgrButton as PropertManagerPageButton
dim PrMgrControl as PropertManagerPageControl

set PrMgrControl = PrMgrButton  ' Possible car le bouton est héritier du contrôle

The same goes for a variant:

dim PrMgrButton as PropertManagerPageButton
dim vrtControl as variant

set vrtControl = PrMgrButton  ' Usage de "set" à valider...

impec! I was unaware of this technique. I think I'll be able to use it again in other projects.

It's a bit HS, but I also have problems in late binding with the EdmVaultX object, I can't get an EdmVault where X will be at the right value, 5 instead of 21 or the other way around I don't remember. And I was looking for how to cast the object to the desired EdmVault version. I'll see if I can adapt. In Late binding only, and this is the only possible choice, when coding for SW task addin .

Anyway, otherwise I still have a question: OLE variant is the variant type or something else?

In VBA, there is only one variant type, regardless of the object being pointed to.

Judging by this line from a VB.NET example, the casting of EdmVaultX is possible between its successive clues...

  Dim CurrentVault As IEdmVault21 = TryCast(New EdmVault5(), IEdmVault21)

Hello
In vb.net yes it's possible, and in VBA too, as long as you're in early binding, that is, when you check the references in the project. You can write:

Dim eVault As IEdmVault21
Set eVault = New EdmVault5

And you get an object IEdmVault21/IEdmVault21 (in my opinion there is a mistake, we should have IEdmVault5/IEdmVault21):
{A14B1B02-D76A-4F55-B7E7-B78398D569C4}

Except that when you code a solidworks task (SolidWorks Tasks addin), you can't check the references. Therefore, you need to create the object in late binding :

Dim eVault As Object 'Futur objet EdmVault21
Set eVault = CreateObject("ConisioLib.EdmVault.1")

Contrary to what one might think, the number at the end is not the index of the object. I thus obtain an object of type Object/IEdmVault21.
{6E1FDD15-2E19-415C-B404-D1BB7F4D4330}

And the two are not equivalent. If I then write:

Dim eFile As Object  'Futur objet IEdmFile6
Set eFile = eVault.GetFileFromPath(sFichier)

I get an error 13: mismatch type. It goes by itself in early binding though. And it's understandable, the method GetFileFromPath is a member of IEdmVault5.

And there to cast, in late binding, well I don't know how to do it