Pack and Go API

Pack and Go API

Anonymous
Not applicable
5,820 Views
35 Replies
Message 1 of 36

Pack and Go API

Anonymous
Not applicable

Looking for a bit of guidance with the Pack and Go API.

 

I have ran the example API provided in Inventor 2017 within VB.NET as follows (This is running on a simple form on button press):

 

 

Private Sub Button2_Click(sender As System.Object, e As EventArgs) Handles Button2.Click
Dim oPacknGoComp As New PackAndGoLib.PackAndGoComponent

Dim oPacknGo As PackAndGoLib.PackAndGo
oPacknGo = oPacknGoComp.CreatePackAndGo("C:\PacknGo\Source\Castor Parts.iam", "C:\PacknGo\Castor Parts")

' Set the design project. This defaults to the current active project.
oPacknGo.ProjectFile = "C:\PacknGo\Source\Castor Parts.ipj"

Dim sRefFiles = New String() {}
Dim sMissFiles = New Object

' Set the options
oPacknGo.SkipLibraries = True
oPacknGo.SkipStyles = True
oPacknGo.SkipTemplates = True
oPacknGo.CollectWorkgroups = False
oPacknGo.KeepFolderHierarchy = True
oPacknGo.IncludeLinkedFiles = True

' Get the referenced files
oPacknGo.SearchForReferencedFiles(sRefFiles, sMissFiles)

' Add the referenced files for package
oPacknGo.AddFilesToPackage(sRefFiles)

' Start the pack and go to create the package
oPacknGo.CreatePackage()

End Sub

 

This is causing an Error message "An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred {"Error HRESULT E_FAIL has been returned from a call to a COM component."}"

 

 

All file paths are correct and output directory is created, I have double checked this as well as running the following:

 

Dim ProjFile As DesignProjectManager
            ProjFile = g_inventorApplication.DesignProjectManager
            'Convert Project name to string
            Dim ProjName As String
            ProjName = ProjFile.ActiveDesignProject.FullFileName
            Debug.Print("Active project: " & ProjName)

Which returns the debug print string correctly and then tried using:

 

oPacknGo.ProjectFile = ProjName

So I know the Project File is correct but no matter what I try it seems to continually fall over.

 

I can run the code successfully if I comment out the Project file line, however this only creates a Pack and Go of the singular Part/Assembly that is open and no linked files (which defeats the point of Pack and Go)

 

Any resolution/advise would be greatly appreciated.

0 Likes
Accepted solutions (1)
5,821 Views
35 Replies
Replies (35)
Message 21 of 36

Anonymous
Not applicable

Thanks you!!!

It works really well !

0 Likes
Message 22 of 36

avinash.andhale
Alumni
Alumni

In C# project (add-in, also from the standalone project) we are getting the exception at below statement.

PackAndGoLib.PackAndGoComponent oPacknGoComp = new PackAndGoLib.PackAndGoComponent();

I think the apprentice server can be created easily, but here it will not solve the error.
PackAndGoError.JPG


We also tried manually registering the .dll assembly using the command prompt. But this is neither helping us.
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe "C:\Program Files\Autodesk\Inventor 2018\Bin\Autodesk.PackAndGo.Interop.dll"
PackAndGoErrorClassRegistration.JPG

0 Likes
Message 23 of 36

psaarloos
Collaborator
Collaborator
Hi,

Can you post a zip of your C# stand-alone project? I will not run from within an Inventor add-in. It needs to run within a separate process, so the stand-alone application should work.
Regards,
Pim Saarloos
Product Manager
If my post answers your question, please click the "Accept as Solution" button. Kudos are much appreciated!
0 Likes
Message 24 of 36

avinash.andhale
Alumni
Alumni

PackAndGo project as a standalone application.
Please find the attached zip file.

0 Likes
Message 25 of 36

psaarloos
Collaborator
Collaborator

Hi,

 

It's working now. In the project properties on the build tab the option 'Prefer 32-bits' was checked. That caused the issue.

 

Good luck with creating your solution!

Regards,
Pim Saarloos
Product Manager
If my post answers your question, please click the "Accept as Solution" button. Kudos are much appreciated!
0 Likes
Message 26 of 36

avinash.andhale
Alumni
Alumni

Even after unticking "Prefer 32 bit", the exception is the same.
This is working at your end, means I have messed up with the registry entries.

I will check the same project on another machine.

Please share, why the PackAndGo will not work within add-in project.

0 Likes
Message 27 of 36

psaarloos
Collaborator
Collaborator

My guess is that the Pack And Go API is making use of Inventor Apprentice, which is basically a light weight, very fast 'Inventor' version with limited functionality. It is very fast for gathering references, querying properties, etc, but you can't do anything with graphics for example.

 

You can't access Inventor Apprentice from an add-in as well. It's because the add-in runs within the Inventor process. The best 'trick' is to launch a console application with a command in your Inventor add-in and work with ExitCode or something like that to get feedback from the console application back in your add-in.

 

Hope it helps.

Regards,
Pim Saarloos
Product Manager
If my post answers your question, please click the "Accept as Solution" button. Kudos are much appreciated!
Message 28 of 36

Anonymous
Not applicable

hey pim,

 

I know this thread is a Little old by now, nevertheless maybe you can still help me with this.

 

I am using your solution to execute an console application from an Inventor addin to make a PackandGo Operation.

 

The Launch seems to work fine, but in the console application there is something wrong. As I didn't know how to work with

 

                    Try
                        PackAndGo(args(1),args(2))
                    Catch ex As Exception
                        Environment.Exit(1)
                    End Try

I implemented the whole PackAndGo Task directly, instead of the line "PackAndGo(args(1),args(2))"

 

For the PackandGo Code I used your example wich makes use of the ApprenticeServerComponent as posted earlier. But this line causes Problems:

 

Dim oPacknGoComp As New PackAndGoLib.PackAndGoComponent

 

The code never passes this line, but no error is thrown. I put a MsgBox before and after the line. The one before Pops up, the MsgBox after does not. It's like there would stand "Exit Sub" directly after.

 

Please see the Attachment for the full Code

0 Likes
Message 29 of 36

psaarloos
Collaborator
Collaborator

Hi Jake,

 

Code is looking all fine to me. Couple of things to verify:

 

  1. Is your console application set to use '.NET Framework 4.5' (or higher)? (Project Properties --> Application tab).
  2. Is the target CPU set to AnyCPU?
  3. Option prefer 32-bit unchecked? (Project Properties --> Build tab)
  4. Did you reference the 'Autodesk.PackAndGo.Interop.dll' assembly from the same Inventor version as being used? 
Regards,
Pim Saarloos
Product Manager
If my post answers your question, please click the "Accept as Solution" button. Kudos are much appreciated!
Message 30 of 36

Anonymous
Not applicable

Hey pim,

 

indeed.

 

Prefer 32bit was checked in the console application. Man.. for hours I searched for an error in the code.

 

Thank you very much!

0 Likes
Message 31 of 36

Anonymous
Not applicable

Best

I cannot find a solution how I can take the dwg drawings with me. These are in the workspace but in a different folder.

I have to change this rule. But I don't find the information. I tried

     

  

 oPacknGo.AddFilesToPackage(path,sRefFiles)

 

path stands for the location of the folder. But this gives an error 😞

Do you know of a possible solution or where I can find more information about how it works?

 

thank you in advance

0 Likes
Message 32 of 36

bradeneuropeArthur
Mentor
Mentor

Could you create a new topic for it?

I have some new code for you!

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
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:
My 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 !


 


EESignature

0 Likes
Message 33 of 36

amarcoc
Advocate
Advocate

Hi.

 

I am complete newbie on .NET (already done a lot in VBA ana iLogic).

 

Since P&G API is broken for iLogic and VBA, I will try using Visual Studio.

 

Would you kindly share your full project?

 

I need to make a custom pack and go.

 

Thanks!

0 Likes
Message 34 of 36

Anonymous
Not applicable

Hi ,

This is avalable in Inventor programing help.

 

But the Issue is it is VBA Code , Here I need VB.Net code.

There is a variation in that.

 

Please find my issue in the screen shot.Untitled.png

0 Likes
Message 35 of 36

bradeneuropeArthur
Mentor
Mentor

Hi,

 

Could you upload your code?

 

Regards,

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
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:
My 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 !


 


EESignature

0 Likes
Message 36 of 36

tobias_wiesendanger
Advocate
Advocate

This changed to be even more worse. You now need to also add a manifest described here:

 

https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-api-error-quot-ordinal-345-could...

 

0 Likes