File Directory For Custom Add-in not Working for Vault

File Directory For Custom Add-in not Working for Vault

RNDinov8r
Collaborator Collaborator
287 Views
3 Replies
Message 1 of 4

File Directory For Custom Add-in not Working for Vault

RNDinov8r
Collaborator
Collaborator

Last Summer we had an intern who was very, very  smart write an Add-in for inventor. We call it Easy BOM. It takes our top level model and ultimatley spits out a Strucutured BOM and a Parts Only BOM in an excel spread sheet. Additionally, it sorts a particular way, and then runs a bunch of back ground macros so when we open the .xlsm file, it has removed things we don't want, and high lighted things in a certain way...etc. It saves us a bunch of time and is always consistent with output. A large machine might take 20 minutes to export the BOM using Easy BOM add-in, but the manual process to create that same BOM could take 2-6 hours depending on Assembly complexity.

 

In any case, the original Add-in code was written for our usage of Inventor not in Vault, and it was on our server (we call it the "R-drive"). Now that we are using Vault, everything is local and the file structure of vault is somewhat different than the network server we were using.

 

This is what the original file structure looked like.

R:\Customer\Job No\Mech\CAD\Assembly,Parts,BOMs (these three folders existed in CAD). (Italics are variable)

Where the top level assembly 23G45678-T00 would be in the Assembly folder and the BOM would be created in the BOMs folder.

All projects have this exact structure once you get to the Job No folder level. This is an image of the original Structure.

RNDinov8r_0-1653498837468.png

Now that we have moved to Vault, it is somewhat simplified and it lives locally.

C:\\RND-LWR\Workspace\Projects\Customer Name\12R34567-T00.iam (Italics are variable)

 

I'd like to avoid create a BOMs folder in the Customer Name folder, I'd just like the BOM to be created at the same location as the -T00.iam file.

 

This is an image of the Vault Structure

RNDinov8r_1-1653499126371.png

This is the code snippet the controls calling the templates to export to and from as well as where to create them. Text in Bold Green is governing where the files go.

sTemplateDrawing = "K:\Inventor\R2022 Inventor\R2022 Templates\_RND\BOM Detail.idw"
oForm.ProgressBar1.Value = 1
oOptions = g_inventorApplication.TransientObjects.CreateNameValueMap
oOptions.Value("Template") = "L:\Mechanical\TEMPLATES\CombindedBOMTemplateNested_New2.xlsm" 'If the name of the template is changed, chnge this let chad know that changing names (ie adding _New) will break this addin
oOptions.Value("ExportedColumns") = "QTY;MULT MACH QTY;QOH;QTY TO ORDER;PART NUMBER;TITLE;REV;USED ON ASSEBMLY;ESTIMATED COST;MANUFACTURER;Manufacturers P/N;MATERIAL;Material2;Finish1;SPARE?;IndustryNo;BOM Responsibility"
oOptions.Value("StartingCell") = "B3"
oOptions.Value("TableName") = "Parts List"
oOptions.Value("IncludeTitle") = False
oOptions.Value("AutoFitColumnWidth") = True
sPartsListPath = Strings.Left(sFilePath, InStrRev(sFilePath, "\CAD\")) & "CAD\BOMs\"
sPartsListName = Strings.Right(sFilePath, Strings.Len(sFilePath) - InStrRev(sFilePath, "\"))
sPartsListName = Strings.Left(sPartsListName, InStrRev(sPartsListName, "-")) & "B" & Strings.Right(sPartsListName, Strings.Len(sPartsListName) - InStrRev(sPartsListName, "-T") - 1)
sPartsListName = Strings.Left(sPartsListName, InStrRev(sPartsListName, ".") - 1)
sBOMCustomizationPath = "K:\Inventor\R2022 Inventor\Customization\PartsOnlyBOMStructureWMicro.xml"

 

CAn anyone suggest a change to the code that would allow a BOM to be created in the same folder as the top level in our new Vault File structure?

0 Likes
288 Views
3 Replies
Replies (3)
Message 2 of 4

Michael.Navara
Advisor
Advisor

If you use VB.Net for addin, you can use System.IO.Path and its funckionality instead of direct string manipulation

Dim asmFullFileName As String '= ThisDoc.Document.FullFileName ' FOR iLogic TEST ONLY
Dim sPartsListPath = IO.Path.GetDirectoryName(asmFullFileName)

 

0 Likes
Message 3 of 4

RNDinov8r
Collaborator
Collaborator

I beleive we used straight up VBA, not VB.net.

0 Likes
Message 4 of 4

Michael.Navara
Advisor
Advisor

In this case I recommend you to try iLogic. It is much more powerful then VBA and IO.Path functionality is also available.

Lot of syntax is identical in VBA and iLogic. But if you want to continue using VBA, you can use FileSystemObject

 

 

Sub FileSystemObjectTest()
    'With reference to 'Microsoft Scripting Runtime'
    'It enables intelliSense
'    Dim fs As FileSystemObject
'    Set fs = New FileSystemObject
    
    'Without reference
    Set fs = CreateObject("Scripting.FileSystemObject")
    
    
    Dim fileName As String
    fileName = ThisApplication.ActiveDocument.FullFileName
    
    fileFolder = fs.GetParentFolderName(fileName)
    excelFile = fs.BuildPath(fileFolder, "ExcelFile.xls")
    
End Sub

 

 

0 Likes