SW Api (Property Manager) and C#

Discussion in 'SolidWorks' started by -=RapidHail=-, Mar 18, 2007.

  1. I have implemented IPropertyManagerPage2Handler3 like somebody did it in SW
    Example
    http://files.solidworks.com/API/Examples/00000/0300s/0345/Example.htm in
    PMPHandler.cs. Only i changed is a constructor:

    public PMPageHandler (ISldWorks swApplication)
    {
    swApp = swApplication;
    }

    In User PMPage (named as PMPUserPage)

    public class PMPUserPage
    {
    IPropertyManagerPage2 swPropertyPage;
    PMPageHandler handler;

    IPropertyManagerPageButton button1;
    public const int button1ID = 0;

    ISldWorks swApp;
    public PMPUserPage(ISldWorks swApplication)
    {
    swApp = swApplication;
    CreatePropertyManagerPage();
    }
    protected void CreatePropertyManagerPage()
    {
    int errors = -1;
    int options =
    (int)SwConst.swPropertyManagerPageOptions_e.swPropertyManagerOptions_OkayButton
    |
    (int)SwConst.swPropertyManagerPageOptions_e.swPropertyManagerOptions_CancelButton;
    handler = new PMPageHandler(swApp);

    swPropertyPage =
    (IPropertyManagerPage2)swApp.CreatePropertyManagerPage("Title", options,
    handler, ref errors);
    AddControls();
    this.Show();
    }

    So, when it runs then on line (3rd from down) with (swPropertyPage =
    (Iproperty...) i get "Specified cast is not valid."
    It's a problem with handler, when i set handler=null then my property page
    will be shown in SolidWorks document.
    What am I doing wrong? Should I also implement ISwAddin?

    Thanks in advance.
     
    -=RapidHail=-, Mar 18, 2007
    #1
  2. I finded the answer, the problem was in an AssemblyInfo.cs
    line:
    [assembly: ComVisible(false)]

    Everything works now :)
     
    -=RapidHail=-, Mar 21, 2007
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.