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: 

Getting Apprentice to work in an Addin

17 REPLIES 17
Reply
Message 1 of 18
NachitoMax
1541 Views, 17 Replies

Getting Apprentice to work in an Addin

Hi

 

I know that apprentice doesn't work when trying to use it in an Addin however, people have managed to make a dll Class that has apprentice functions and they can be used from an Addin.

 

Before I delve into a bunch of code that may not work, I wanted to pass these methods as ideas to if its achievable? Maybe one of the Autodesk experts could offer some help?

 

Option 1

Create a separate dll Class and have the apprentice functions in there. Reference the dll into the Addin. (I understand that there may be instance issues)

 

Option 2

Create a separate exe Class and have the apprentice functions in there. I would still need to reference the Class from the addin as it needs to collect some ClientView images to display in the Addin.

 

Obviously there must be a way of doing it because its been done, I just sont really want to spent a few days writing code that ultimately wont work..

 

 

 

Cheers

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


17 REPLIES 17
Message 2 of 18

Hi,

Your idea of external executable file should work.
I will take a look at it and come back to this topic ASAP.
Please let me know if your idea works too.

Regards,

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

Message 3 of 18

Hi,

What would you like to do exactly?

Regards,

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

Message 4 of 18

Hi

 

That would be great if you could look into it? I have had chance to check anything yet

 

 

Cheers

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


Message 5 of 18

Hi

 

I need to collect a client view of a selected assembly (that i would browse to) and display it in a picturebox on a form. I would then need to save the client view as an image.

 

I know it cant be saved directly but i have already created a class that effectively takes a snapshot of the picturebox to create a new bitmap.

 

 

 

Thanks

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


Message 6 of 18

Hi,

If I understand correct you would like to take a snapshot of an assembly viewrepresentation (clientview) into another document (form) like word or what?

Am I right?

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

Message 7 of 18

Hi

 

In my addin, i currently have a form. on the form is a picturebox (PicBox1). I need to click a button, show the exe form, browse to the assembly using its controld and then load the clientView into a picturebox (PicBox2) on that exe form. I will then take a snapshot of the Picturebox (PicBox2) to save the visual image as a New Bitmap (Because you cannot save the ClientView as an image).

 

Because its an addin, i cant use apprentice directly and i cant use ClientViews inside the Addin (because they only work in apprentice). In my addin, i would reference the ClientView.exe and call the form

 

The form will take the snapshot, show the image in the picturebox (PicBox2), save the image to a location and store the path in a local Member. MY addin can then collect the path through the reference to retrieve the image and display it in PicBox1

 

 

Cheers

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


Message 8 of 18

Hi,

I do not exactly understand what you mean with the client view.

Can you please explain it a little?

Regards

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

Message 9 of 18

Hi

 

In Apprentice, there is a method called ClientView. This provides a visual representation of a part or assembly that is attached to a picturebox. The picturebox is required to display the clientView object even though the clientView is not exactly an image.

 

There is information on ClientViews in the API help file.

 

 

Cheers

 

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


Message 10 of 18

Hi,

Then I understand.
I will take a look at it.
Maybe there is another solution for it?
I will investigate it also.

Regards,

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

Message 11 of 18

Hi,

 

I use the following:

Imports Inventor
Imports Microsoft.VisualBasic
Module MdlPreviewFile
    Public Sub PreviewFile()
        Try
            ' Create an instance of Apprentice.  
            Dim apprentice As New ApprenticeServerComponent

            ' Open a document.  
            Dim doc As ApprenticeServerDocument
			
			'UFrmUpdateAndCheckInFile = the form you would like t have the image in
            doc = apprentice.Open(UFrmUpdateAndCheckInFile.oInvApp.ActiveDocument.FullFileName)
            
            ' Get the thumbnail image.  
            Dim thumbnail As stdole.IPictureDisp
            thumbnail = doc.Thumbnail

            ' Convert the IPictureDisp object to an Image.  
            Dim img As Image = Compatibility.VB6.IPictureDispToImage(thumbnail)

            ' Display the image in the picture box.  
            UFrmUpdateAndCheckInFile.PbPreview.Image = img
        Catch ex As Exception

        End Try

    End Sub


End Module

Does this help or solve the issue?

 

 

Regards,

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

Message 12 of 18

I also need to figure out how to use apprentice in an addin.

 

This blogpost suggests it's possible: http://adndevblog.typepad.com/manufacturing/2013/01/use-apprenticeserver-api-from-an-inventor-addin....

But there is no actual explanation how to do it in this blogpost.

 

Quoting the first lines of the blog:

"We can create an ActiveX executable, which references the ApprenticeServer API, and which also exposes a suitable API of its own. We can then call into our ActiveX executable from an Inventor AddIn dll to request updates to any file references."

 

This suggests you can call apprentice as a separate process with its own API from within an Addin.

If anyone has an example visual studio project or something that shows how to do that I am very very grateful.

 

Message 13 of 18
Anonymous
in reply to: Cadkunde.nl

Hello @Cadkunde.nl

 

It seems that it is not an easy task to create an out-of-process ActiveX component in .NET using just C# or VB.NET.

 

There is a short arcticle from Microsoft where they link to some sample code combining C++ and C# or VB.NET:

https://support.microsoft.com/da-dk/help/977996/how-to-develop-an-out-of-process-com-component-by-us...

 

But I have not looked at that sample so how useable it is I don't know.

 

Others typically tells you to make an exe and run a command line to do the out-of-process stuff and then use some other mechanism to get data from/to the command line exe and the in-process addin, such as temporary files, shared pipes or other program to program communication.

 

If you do find some sample code that enables you to run Apprentice out-of-process from an Inventor addin I think there are many others who would like to see this.

 

In VB6 it was much easier, but that does not help here.

 

Regards,

Jens Bejer Pedersendeveloper, Symetri A/S

www.symetri.com

 

Message 14 of 18
Cadkunde.nl
in reply to: NachitoMax

@NachitoMax

 

The help file on client views refers to 'InventorViewerCtrl'

http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-06D49EB6-7871-4A1B-917F-756735B5D0E7

Maybe that is an alternative to using apprentice.

 

And here is a forum post with a visual studio example:

https://forums.autodesk.com/t5/inventor-customization/implementing-apprentice-clientview-in-c/td-p/3...

 

Maybe this helps you find a solution to your problem.

Message 15 of 18
NachitoMax
in reply to: NachitoMax

Hi

It's still in-process. It needs to be out of process in order to work.

I have stubbled across some documentation on msdn about tempting and on code project for wrapping the code in an ActiveX.

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


Message 16 of 18
Jef_E
in reply to: NachitoMax

Hi,

 

Did you succeed in your attempt to use apprentice from the ADDIN? I would like to do this to.. but can't seem to make it happen.



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
Message 17 of 18
Anonymous
in reply to: Jef_E

-

 

Message 18 of 18
Cadkunde.nl
in reply to: Jef_E

Haven't been working on this anymore.

 

This is all the info about apprentice in an addin:

http://adndevblog.typepad.com/manufacturing/2016/03/using-apprentice-from-vba-ilogic-or-an-add-in.ht...

 

But I haven't solved how to:

"wrap all the Apprentice related functionality into your own exe and call that from inside Inventor"

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

Post to forums  

Autodesk Design & Make Report