[iLogic] Pack&Go rule problem

[iLogic] Pack&Go rule problem

amarcoc
Advocate Advocate
794 Views
8 Replies
Message 1 of 9

[iLogic] Pack&Go rule problem

amarcoc
Advocate
Advocate

Hi.

 

I am trying to make a pack and go rule that works as following:

- Create pack and go (in a folder with current date and time in it's name)

- Create ZIP

- Delete pack and go folder

- Ask to open ZIP 

 

The problem: It generates pack and go, but with only main assembly. It does not search for additional files. Why?

 

Here is complete rule:

 

If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then
	MessageBox.Show("Apenas pode executar esta macro num ficheiro *.iam", "Erro!")
	Return
End If

ThisApplication.ActiveDocument.Save2

Dim oFolder As String = System.IO.Directory.GetParent(ThisDoc.Path).ToString & "\8-BACKUP [ZIP]\PG_" & IO.Path.GetFileNameWithoutExtension(ThisDoc.ModelDocument.FullFileName) & "_" & DateTime.Now.ToString("yyyy.MM.dd_HH.mm.ss")' & "\"

Try
	MkDir(oFolder)
	Catch
End Try

Dim oPacknGoComp As New PackAndGoLib.PackAndGoComponent
Dim oPacknGo As PackAndGoLib.PackAndGo = oPacknGoComp.CreatePackAndGo(ThisApplication.ActiveEditDocument.FullFileName, oFolder)
'oPacknGo.ProjectFile = ThisApplication.DesignProjectManager.ActiveDesignProject.FullFileName

Dim oReferencedFiles = New String() {}
Dim oMissingFiles = New Object
'Dim oSearchedFiles = New String() {}
'Dim oReferencingFiles = New String() {}

oPacknGo.SkipLibraries = True
oPacknGo.SkipStyles = True
oPacknGo.SkipTemplates = True
oPacknGo.CollectWorkgroups = False
oPacknGo.KeepFolderHierarchy = True
oPacknGo.IncludeLinkedFiles = True

oPacknGo.SearchForReferencedFiles(oReferencedFiles, oMissingFiles)
oPacknGo.AddFilesToPackage(oReferencedFiles)
'oPacknGo.SearchForReferencingFiles(oSearchedFiles, oReferencingFiles, False, ThisDoc.WorkspacePath & "\", True)
'oPacknGo.AddFilesToPackage(oReferencingFiles)
	
oPacknGo.CreatePackage()

System.IO.Compression.ZipFile.CreateFromDirectory(oFolder, oFolder & ".zip")

Dim oCommand As String = CStr("cmd.exe /c rmdir /s /q " & """" & oFolder & "\""")
Dim oShellCommand As Object = CreateObject("WScript.Shell")
oShellCommand.Run (oCommand)

If MsgBox ("Deseja abrir o ficheiro ZIP do Pack And Go?",vbYesNo) = vbYes Then
	oCommand = CStr("cmd.exe /c """ & oFolder & ".zip""")
	oShellCommand.Run(oCommand)
End If

 

0 Likes
795 Views
8 Replies
Replies (8)
Message 2 of 9

JhoelForshav
Mentor
Mentor

Hi @amarcoc 

It seems as if this problem only occurs with iLogic. The same code should work as expected in an external application.

See this thread:

https://forums.autodesk.com/t5/inventor-customization/inventor-pack-and-go-using-ilogic/td-p/6405492

The problem has been investigated before but it seems like no one has come up with a solution.

Would it work for you to create an external app instead?

0 Likes
Message 3 of 9

amarcoc
Advocate
Advocate

Hi. Unfortunately I have no idea how to do it. 😞

 

Did anyone do the application before and provided it?

 

I have readed the topic, but the application was not provided.

 

 

EDIT: Would it work with VBA? Is there any VBA sample available? I can only find iLogic samples.

 

 

0 Likes
Message 4 of 9

JhoelForshav
Mentor
Mentor

I don't know about VBA. I suspect you'll get the same error but it shouldn't be that much of a hassle to convert it to VBA and try? 🙂

 

If it doesn't work, my recommendation is that you check out the "My first plugin" guide.

The first lesson is creating a simple forms app that interacts with inventor.

 

https://forums.autodesk.com/t5/inventor-customization/check-out-the-self-paced-guide-my-first-plug-i...

 

Since you already have the VB.Net code i think this will be fairly easy for you 🙂

0 Likes
Message 5 of 9

chandra.shekar.g
Autodesk Support
Autodesk Support

@amarcoc,

 

Instead of addin, you can also create standalone application. For more details, refer suggestions in the below links.

 

https://forums.autodesk.com/t5/inventor-customization/pack-and-go-api/td-p/6797037

https://adndevblog.typepad.com/manufacturing/2013/05/use-packandgo-of-2014-api.html

 

You can also try the below suggestions to copy files from one folder to another folder.

 

https://forums.autodesk.com/t5/inventor-customization/vba-copy-all-files-in-the-active-document-to-a...

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 6 of 9

amarcoc
Advocate
Advocate

I didnt get the problem solved yet.

 

I would like to try it on Visual Studio. Will be my first addin.

 

Is there any pack and go addin sample avaiable?

0 Likes
Message 7 of 9

JhoelForshav
Mentor
Mentor

Hi @amarcoc 

I made an example project for you.

See attached archive 🙂

0 Likes
Message 8 of 9

amarcoc
Advocate
Advocate

Thank you. That is great!

 

I will check it now. 

 

Can that be saved as a standalone exe file?

 

EDIT: I am unable to make a clean exe release. Here is log:

EDIT2: Solved. Just needed correct path for Autodesk.PackAndGo.Interop

 

 

 

0 Likes
Message 9 of 9

JhoelForshav
Mentor
Mentor
0 Likes