Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

New BrowserPane with C# UserControl ?

8 REPLIES 8
Reply
Message 1 of 9
lochan94
1345 Views, 8 Replies

New BrowserPane with C# UserControl ?

Hi,

How do we add a new BrowserPane which has a C# UserControl ?



The VB example in the Inventor Programming Help uses a MSCAL.ocx, which is an ActiveX control and I am having a tough time in trying to convert a C# UserControl into an ActiveX control or .OCX type file. After a lot of searching, I found out concept called "shim" More info at

http://blogs.msdn.com/mshneer/archive/2006/06/09/com-shim-wizard-for-visual-studio-2005.aspx


Still I am not able to figure out how to achieve this. Could anyone point me in the right direction with some resources. I am working on VisualStudio 2005 and Inventor 2008




Thanks & Regards,

Rajeev Lochan

http://www.smallguru.com

http://www.ar-cad.com
8 REPLIES 8
Message 2 of 9
lochan94
in reply to: lochan94

"Hi Again,
I have tried having a C# UserControl to be used in Inventor BrowserPane with no success. Could anyone direct me in this regard. I tried to do the following.

a) Create a Interface(IComInterface) and a UserControl(UserControl1) as explained in http:// msmvps.com/blogs/pauldomag/archive/2006/08/16/107758.aspx

b) In the above article, they call the activeX control in a html/ASP using classid="CustomUserControlForBrowser.dll#CustomUserControlForBrowser.UserContro l1"

c) I have tried to use the above method for Inventor both as an external and internal addin.

Inventor.BrowserPane m_customBrowserPane = m_assemblyDocument.BrowserPanes.Add("Test","CustomUserControlForBrowser.dll#Cus tomUserControlForBrowser.UserControl1");

When I do this as an external EXE addin, I get "ComException was unhandled" with message "Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL)) "

*********
Can anyone please confirm if the above procedure is proper and if it is, where am I messing it ?

Thanks & Regards,
Rajeev Lochan
Blog: http://www.smallguru.com
Web: http://www.ar-cad.com

Message 3 of 9
Anonymous
in reply to: lochan94


Sorry, Inventor currently does not support adding
.NET controls into the browser.

 

Sanjay-
Message 4 of 9
Anonymous
in reply to: lochan94


I hope currently is the active word in that answer
;)

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">


Sorry, Inventor currently does not support adding
.NET controls into the browser.

 


size=2>Sanjay-
Message 5 of 9
lochan94
in reply to: lochan94

Thanks Sanjay for directing me.
I also have been trying to have a custom Browser made using Inventor API and the following is the code. When I run this code as an external Addin (EXE), before it builds, I get an error {color:#ff0000}"No overload for method 'CreateBrowserNodeDefinition' takes '3' "

{color}
**************************
//Declare BrowserPanes
Inventor.BrowserPanes m_browserPanes = m_assemblyDocument.BrowserPanes;
Inventor.ClientNodeResources m_clientNodeResources = m_browserPanes.ClientNodeResources;

//load image icons for UI items
Icon documentNameIcon = new Icon(this.GetType(), "docName.ico");
stdole.IPictureDisp m_icon1 = (stdole.IPictureDisp)Support.IconToIPicture(documentNameIcon);

Inventor.ClientNodeResource m_topNodeClientResource = m_clientNodeResources.Add("Test", 1, m_icon1);

//Add Top Node
Inventor.BrowserNodeDefinition m_topNodeDefinition = m_browserPanes.CreateBrowserNodeDefinition("Top Node", 3, m_topNodeClientResource);
Inventor.BrowserPane m_customBrowserPane = m_browserPanes.AddTreeBrowserPane("My Pane", "TestBrowser", m_topNodeDefinition);

*******************************************
From this thread ht tp://discussion.autodesk.com/forums/thread.jspa?messageID=5748644
It is evident that there is some problem with CreateBrowserNodeDefnintion in .Net as it returns a ClientBrowserNodeDefinition . So, even after changing the above code to the following, I get the same error message {color:#ff0000}"No overload for method 'CreateBrowserNodeDefinition' takes '3' " {color}

Inventor.ClientBrowserNodeDefinition m_topNodeDefinition = m_browserPanes.CreateBrowserNodeDefinition("Top Node", 3, m_topNodeClientResource);
Inventor.BrowserPane m_customBrowserPane = m_browserPanes.AddTreeBrowserPane("My Pane", "TestBrowser", (Inventor.BrowserNodeDefinition)m_topNodeDefinition);

**********************************************

In the thread ht tp://discussion.autodesk.com/forums/thread.jspa?messageID=2375910
Brian explains why IPictureDisp could be creating problems for BrowserNode icons, but that thread dates back to 2004. In another similar thread, someone had been successful after converting his code in C# to an internal Addin and his CustomBrowserPane had worked, but even after I had the above code in an internal addin, at the time of building it, I was getting the same error message.

By the way, I was successful in implementing the BrowserNode example code in VBA and it worked as expected.

I again seek guidance from Sanjay and others to enlighten me in this regard.

Thanks & Regards,
Rajeev Lochan
http://www.smallguru.com
http://www.ar-cad.com
Inventor 2008, Win XP
Message 6 of 9
Anonymous
in reply to: lochan94


Two things:


  1. As explained by Brian, IPictureDisp does not
    marshall across processes. So passing an IPictureDisp to an API method
    will fail in external Add-ins and when debugging internal Add-ins. It
    should work fine for internal Add-ins if you are running the add-in
    normally.

  2. For C++ and C#, you need to provide all the
    arguments for methods, even if they are optional. Note that
    CreateBrowserNodeDefinition has 7 arguments. Note that optional arguments
    can be omitted in VB/VBA.

Sanjay-
Message 7 of 9
lochan94
in reply to: lochan94

Thanks again for the direction Sanjay,

I tried again for a virgin C# Addin Template. I noticed that I was getting error because I was loading an .ico, then converting it into IPictureDisp, due to which I was getting Runtime error in Inventor.

After going through API help, it had mentioned that IPictureDisp can only be of .bmp format. When I changed the code to the following, it did work. So I am glad that I have cleared this hurdle. And yes, I have to pass all the optional parameters of ClientNodeResources.Add() for this to work.

****************************************************************
System.Drawing.Image oImage = System.Drawing.Bitmap.FromFile("C:\\Program Files\\Autodesk\\Inventor 2008\\IconsRajeev\\pm.bmp");

IPictureDisp m_IPictureDisp1 = (IPictureDisp)Microsoft.VisualBasic.Compatibility.VB6. Support.ImageToIPictureDisp(oImage);

Inventor.ClientNodeResource m_topNodeClientResource = m_clientNodeResources.Add("icon1", 200, m_IPictureDisp1);
//Add Top Node
Inventor.ClientBrowserNodeDefinition m_topNodeDefinition = m_browserPanes.CreateBrowserNodeDefinition("Top Node", 201, m_topNodeClientResource, "tooltip", m_topNodeClientResource, m_topNodeClientResource, "tooltip2");


Inventor.BrowserPane m_customBrowserPane = m_browserPanes.AddTreeBrowserPane("My Pane", "TestBrowser", (Inventor.BrowserNodeDefinition)m_topNodeDefinition);

//Add 1 Child Nodes.
Inventor.BrowserNodeDefinition m_childNode1Definition = (Inventor.BrowserNodeDefinition)m_browserPanes.CreateBrowserNodeDefinition("Chi ld1", 202, m_topNodeClientResource, "tooltip", m_topNodeClientResource, m_topNodeClientResource, "tooltip2");
Inventor.BrowserNode m_childNode1 = m_customBrowserPane.TopNode.AddChild(m_childNode1Definition);

////Add 1a Child Nodes.
Inventor.BrowserNodeDefinition m_childNode1aDefinition = (Inventor.BrowserNodeDefinition)m_browserPanes.CreateBrowserNodeDefinition("Chi ld 1a", 203, m_topNodeClientResource, "tooltip", m_topNodeClientResource, m_topNodeClientResource, "tooltip2");
Inventor.BrowserNode m_childNode1a = m_childNode1.AddChild(m_childNode1aDefinition);

m_customBrowserPane.Activate();

***********************************************************************
Thanks & Regards,
Rajeev Lochan
http://www.smallguru.com
http://www.ar-cad.com
Inventor 2008, Win XP,
C# VS 2005
Message 8 of 9
FRPT1257
in reply to: lochan94

Hi,

 

I am creating my pane with C# and everything works except that don’t shows the display status icon.

 

Here is my code:

 

   m_childNode1Definition = (Inventor.BrowserNodeDefinition)bps.CreateBrowserNodeDefinition(refDocument.DisplayName, 200 + count, m_topNodeClientResource1, refDocument.FullDocumentName, m_topNodeClientResource1, topNodeClientResource1, “ToolTip Status”);

 

What could be?

 

The “object DisplayState = Type.Missing” is an “Inventor.ClientNodeResource”?

 

Thanks & Regards,

Rui

Message 9 of 9
FRPT1257
in reply to: FRPT1257

I already found an way to use state icons using the BrowserNodeDisplayStateEnum in CreateBrowserNodeDefinition function.

 

But this way I only can use the predefined state icons that Inventor provide in BrowserNodeDisplayStateEnum enumerator.

 

It is not possible customize the state icons with my own icons? Like do the Vault interface?

 

Thanks & Regards,

Rui

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report