SW Api (Property Manager) and C#

Mar 18, 2007 1 Replies

I have implemented IPropertyManagerPage2Handler3 like somebody did it in SW Example

formatting link
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.


I finded the answer, the problem was in an AssemblyInfo.cs line: [assembly: ComVisible(false)]

Everything works now :-)

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required