FIND AND REPLACE CODE INSIDE I-LOGIC RULE

FIND AND REPLACE CODE INSIDE I-LOGIC RULE

Anonymous
Not applicable
1,114 Views
18 Replies
Message 1 of 19

FIND AND REPLACE CODE INSIDE I-LOGIC RULE

Anonymous
Not applicable

Here is my situation:

I'm exporting my parts list and certain i properties to an excel sheet with a particular name that is the same as the dwg name so that they can be identified with one another for our MRP program. But there are multiple excel files in the same folder.  I do not want the less experienced to dive into the export rule to change the name of the .xls file just to export it with the specific name.

 

So does any one have an I-logic code or even vba that i can place inside the export rule to detect the generic name inside the rule and the .dwg name inside i-properties and replace it with the .dwg file name (minus the file extension) before exporting it?

 

 

0 Likes
1,115 Views
18 Replies
Replies (18)
Message 2 of 19

awatt
Advocate
Advocate

First you can get the full file name.
      sFname = oDoc.FullFileName
      
      InStrRev(sFname, "\") will give you the integer position of the last slash.

      InStrRev(sFname, ".") will give you the integer position of the last point.

 

your file name is the mid$ in between.

0 Likes
Message 3 of 19

Anonymous
Not applicable

 

iProperties.Value("Project", "Part Number")

THE ABOVE IS THE WHAT I'M USING FOR MY FILE NAME. IS THERE A WAY TO REPLACE THE GENERIC "FILENAME" IN SOMETHING LIKE

 

ThisBOM.Export("Parts Only", "fileName", kMicrosoftExcelFormat)

AND REPLACE IT WITH THE PART NUMBER BUT THROUGH A RULE? I KNOW THAT THERE IS A SEARCH AND REPLCE FUNCTION INSIDE THE RULE ITSELF BUT I'M TRYING TO DO IT AUTOMATICALLY WHEN A NEW DRAWING IS SAVEAS'D. THAT IS WHAT UPDATES THE PARTNUMBER WHICH UPDATES MY DRAWING TITLE. IT IS TO KEEP PEOPLE OUT OF MY I-LOGIC.

0 Likes
Message 4 of 19

awatt
Advocate
Advocate

I suppose you've tried this:?

 

ThisBOM.Export("Parts Only", iProperties.Value("Project", "Part Number"), kMicrosoftExcelFormat)

 

0 Likes
Message 5 of 19

Anonymous
Not applicable

I just did. The problem i have with that is that it doesn't let me pick where i want to store it. I also just searched my entire computer to try and find where it would have put it and found nothing.

Any suggestions?

0 Likes
Message 6 of 19

awatt
Advocate
Advocate

I haven't messed with it much, but it may also require a path and file extension.

So perhaps somthing like this:

 

ThisBOM.Export("Parts Only", "C:/mypath/" & iProperties.Value("Project", "Part Number") & ".xlsx", kMicrosoftExcelFormat)

 

I'm not sure if the path will require foreward or back slash.

0 Likes
Message 7 of 19

Anonymous
Not applicable

This is my current code:

 

'define oDoc
oDoc = ThisDoc.Document


'specify the drawing sheet
oSheet = oDoc.Sheets("Sheet:1") ' sheet by name
'oSheet = oDoc.Sheets(1) ' first sheet


 ' say there is a Partslist on the sheet.
oPartslist = oSheet.PartsLists(1)
      
' create a new NameValueMap object
oOptions = ThisApplication.TransientObjects.CreateNameValueMap

  
'specify the columns to export          
oOptions.Value("ExportedColumns") = "ITEM;QTY;M1 PART ID;PART DESCRIPTION;WIDTH;LENGTH;PERIMETER;DETAIL;Block Weight;FINISH WT"
  
'specify the start cell
oOptions.Value("StartingCell") = "A1"
  
'specify the XLS tab name
'here the file name is used 
oOptions.Value("TableName") = "BILL OF MATERIALS"


'choose to autofit the column width in the xls file
oOptions.Value("AutoFitColumnWidth") = True

        
' export the Partslist to Excel with options
oPartslist.Export(path_and_name & ".xls", _
PartsListFileFormatEnum.kMicrosoftExcel, oOptions)  


'-------------End of ilogic ------------------------------------------------

GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "M2")= iProperties.Value("Custom", "Total_Surface_Area")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "N2")= iProperties.Value("Custom", "Assembly_Weight")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "O2")= iProperties.Value("Custom", "QTY REQ'D")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "P2")= iProperties.Value("Project", "Part Number")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "Q2")= iProperties.Value("Custom", "Client")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "R2")= iProperties.Value("Custom", "Customer PO#")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "S2")= iProperties.Value("Custom", "Project")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "T2")= iProperties.Value("Custom", "Engineers Detail#")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "U2")= iProperties.Value("Custom", "DMI JOB#")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "V2")= iProperties.Value("Custom", "Operations")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "W2")= iProperties.Value("Custom", "Weld Procedure# 1")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "X2")= iProperties.Value("Custom", "Weld Procedure# 2")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "Y2")= iProperties.Value("Custom", "Delta LNFT of Weld")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "Y4")= iProperties.Value("Custom", "Shop LNFT of Weld")

 

 

The only thing That i have left is to figure out how to get the browser window to come up so i can can specify where i want to put it. I dont want the path to be in the rule because the path will change with every purchase order?

 

Any suggestions would help?

0 Likes
Message 8 of 19

awatt
Advocate
Advocate

It looks like you are looking for how to use the FileDialog object.  I don't have much experience with it.  Some examples came up on a search, but I didn't find much in the standard Inventor help file.  There may be more in the SDK help files.

0 Likes
Message 9 of 19

Anonymous
Not applicable

ANY IDEAS ON THE DIALOG BOX, AT LEAST WHAT THE STARTING CODE IS?

0 Likes
Message 10 of 19

Anonymous
Not applicable

You can use this code to bring up a dialog box and browse to a file. You can then derive the folder path from the file you selected.

 

Dim oFileDlg As inventor.FileDialog = Nothing

InventorVb.Application.CreateFileDialog(oFileDlg)

oFileDlg.InitialDirectory = oOrigRefName

oFileDlg.CancelError = True

On Error Resume Next

oFileDlg.ShowOpen()

If Err.Number <> 0 Then

Return

ElseIf oFileDlg.FileName <> "" Then

selectedfile = oFileDlg.FileName

End if

MessageBox.Show("You selected: " & selectedfile , "iLogic")

0 Likes
Message 11 of 19

Anonymous
Not applicable

I will try this as soon as I can. If it works Kudos to you sir. Thank you for you time and knowledge. I twould be an excel file that i need to place, so I will try replacing "inventor.FileDialog" with "excel.file dialog". I'm gonna have to figure out where to place it in the current code, but this helps a lot. Thanks again.

0 Likes
Message 12 of 19

MechMachineMan
Advisor
Advisor

DONT FEAR, THE CODE WIZARD IS HERE.

 

This chunk of code will simply bring up a dialog box and ask you for which excel file you want to save to; if called in a line it will return the full file path.

 

Also, you may want to check if a System.IO.File.Exists(oFilePath) exists for where your first option would be to save it to, and if it does, then call the dialog box and make that your new path.

ie; 

If File.Exists(oIdealSaveLocation) = True
      oIdealSaveLocation = FileBrowse(True) ' True to indicate you want to use the file to save to; False if it is just to open it. 

Else

'If the file does not already exists, make it there
End if

 

Private Function FileBrowse(Save As Boolean)
    Dim oFileDlg As FileDialog
    ' Create a new FileDialog object.
    Call ThisApplication.CreateFileDialog(oFileDlg)

    ' Define the filter to select part and assembly files or any file.
    With oFileDlg
    '"

    ' Define the part and assembly files filter to be the default filter.
        .FilterIndex = 1
        .MultiSelectEnabled = False

    ' Set the title for the dialog.
    

        ' Set the initial directory that will be displayed in the dialog.
        'oFileDlg.InitialDirectory = ThisApplication.FileOptions.ProjectsPath

        ' Set the flag so an error will be raised if the user clicks the Cancel button.
            .CancelError = True

        ' Show the open dialog.  The same procedure is also used for the Save dialog.
        ' The commented code can be used for the Save dialog.
           On Error Resume Next

        If Save = True
            .Filter = "Excel Files (*.xlsx)| *.xlsx"
            .DialogTitle = "Specify New Save Location and Name"
            .ShowSave
            Else
            '.Filter = "Inventor Files (*.iam;*.ipt;*.idw;*.dwg)|*.iam;*.ipt;*.idw;*.dwg|All Files (*.*)|*.*"
            .Filter = "Excel Files (*.xlsx)| *.xlsx"
            .DialogTitle = "Select Excel File To Use As Drawing List"
             .ShowOpen
        End If
'    oFileDlg.ShowSave
    End With
    If Err.Number <> 0 Then
        MsgBox("Error Exists")

   ElseIf Not oFileDlg.FileName = "" Then
        Dim fNames As Object
        fNames = Split(oFileDlg.FileName, "|")
        Dim curName As Object
        Dim lstSource As Object
        For Each curName In fNames
            lstSource.AddItem(curName)
        Next curName
    End If
Return oFileDlg.FileName
End Function

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 13 of 19

Anonymous
Not applicable

This code keeps telling me

"All other Sub's or Function's must be after Sub Main()"

What does that mean?

 

Any chance you can help me inplement this in my current code to export everything that i need but specify the location where i want to save it?

0 Likes
Message 14 of 19

MechMachineMan
Advisor
Advisor

It means your whole rule needs to look like:

Sub Main()

      ' Put your code here

End Sub

 

Private Function oFileBrowse

'Function code here

End function 

 

'Additional functions here


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 15 of 19

Anonymous
Not applicable

OK This is what i have. It's My code included with yours, but it's not bringing up the dialog box to save. it does however still save my stuff. but it doesn't allow me to pick the location i want it to save to.

 

The "oPartslist.export" part of my code is how it saves. I'm still new at vba so i dont quite fully understand what your caode is telling me. Or how it working in conjunction with mine. Any thoughts?

 

Sub Main()
'get the path and name of the drawing file
path_and_name = ThisDoc.PathAndFileName(False) ' without extension

'define oDoc
oDoc = ThisDoc.Document

'specify the drawing sheet
oSheet = oDoc.Sheets("Sheet:1") ' sheet by name
'oSheet = oDoc.Sheets(1) ' first sheet

 ' say there is a Partslist on the sheet.
oPartslist = oSheet.PartsLists(1)

      
' create a new NameValueMap object
oOptions = ThisApplication.TransientObjects.CreateNameValueMap


'-------------Start of ilogic ------------------------------------------------

'specify the columns to export          
oOptions.Value("ExportedColumns") = "ITEM;QTY;M1 PART ID;REV;PART DESCRIPTION;WIDTH;LENGTH;PERIMETER;DETAIL;BLOCK WT;FINISH WT"
  
'specify the start cell
oOptions.Value("StartingCell") = "A1"
  
'specify the XLS tab name
'here the file name is used 
oOptions.Value("TableName") = "BILL OF MATERIALS"

oOptions.Value("ApplyCellFormatting") = True

'choose to autofit the column width in the xls file
oOptions.Value("AutoFitColumnWidth") = True

' export the Partslist to Excel with options

oPartslist.Export(path_and_name & ".xls", _
PartsListFileFormatEnum.kMicrosoftExcel, oOptions)  


'-------------End of ilogic ------------------------------------------------

GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "L1")= "Total Surface Area"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "L2")= iProperties.Value("Custom", "Total_Surface_Area")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "M1")= "Total Weight"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "M2")= iProperties.Value("Custom", "Assembly_Weight")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "N1")= "QTY of Assemblies"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "N2")= iProperties.Value("Custom", "QTY REQ'D")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "O1")= "Tag#"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "O2")= iProperties.Value("Project", "Part Number")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "P1")= "Customer"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "P2")= iProperties.Value("Custom", "Client")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "Q1")= "Customer PO#"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "Q2")= iProperties.Value("Custom", "Customer PO#")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "R1")= "Project"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "R2")= iProperties.Value("Custom", "Project")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "S1")= "Eng Det#"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "S2")= iProperties.Value("Custom", "Engineers Detail#")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "T1")= "DMI JOB#"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "T2")= iProperties.Value("Custom", "DMI JOB#")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "U1")= "Fabrication Operations"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "U2")= iProperties.Value("Custom", "Operations")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "V1")= "Weld Procedure #1"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "V2")= iProperties.Value("Custom", "Weld Procedure# 1")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "W1")= "Weld Procedure #2"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "W2")= iProperties.Value("Custom", "Weld Procedure# 2")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "X1")= "Delta Total LNFT of Weld"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "X2")= iProperties.Value("Custom", "Delta LNFT of Weld")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "X3")= "Shop Total LNFT of Weld"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "X4")= iProperties.Value("Custom", "Shop LNFT of Weld")

End Sub

Private Function FileBrowse(Save As Boolean)
    Dim oFileDlg As FileDialog
    ' Create a new FileDialog object.
    Call ThisApplication.CreateFileDialog(oFileDlg)

    ' Define the filter to select part and assembly files or any file.
    With oFileDlg
    '"

    ' Define the part and assembly files filter to be the default filter.
        .FilterIndex = 1
        .MultiSelectEnabled = False

    ' Set the title for the dialog.
    

        ' Set the initial directory that will be displayed in the dialog.
        oFileDlg.InitialDirectory = ThisApplication.FileOptions.ProjectsPath

        ' Set the flag so an error will be raised if the user clicks the Cancel button.
            .CancelError = True

        ' Show the open dialog.  The same procedure is also used for the Save dialog.
        ' The commented code can be used for the Save dialog.
           On Error Resume Next

        If Save = True
            .Filter = "Excel Files (*.xlsx)| *.xlsx"
            .DialogTitle = "Specify New Save Location and Name"
            .ShowSave
            Else
            '.Filter = "Inventor Files (*.iam;*.ipt;*.idw;*.dwg)|*.iam;*.ipt;*.idw;*.dwg|​All Files (*.*)|*.*"
            .Filter = "Excel Files (*.xlsx)| *.xlsx"
            .DialogTitle = "Select Excel File To Use As Drawing List"
             .ShowOpen
        End If
   oFileDlg.ShowSave
    End With
    
    If Err.Number <> 0 Then
        MsgBox("Error Exists")

   ElseIf Not oFileDlg.FileName = "" Then
        Dim fNames As Object
        fNames = Split(oFileDlg.FileName, "|")
        Dim curName As Object
        Dim lstSource As Object
        For Each curName In fNames
            lstSource.AddItem(curName)
        Next curName
    End If
Return oFileDlg.FileName
End Function

 

0 Likes
Message 16 of 19

MechMachineMan
Advisor
Advisor

@Anonymous wrote:

OK This is what i have. It's My code included with yours, but it's not bringing up the dialog box to save. it does however still save my stuff. but it doesn't allow me to pick the location i want it to save to.

 

The "oPartslist.export" part of my code is how it saves. I'm still new at vba so i dont quite fully understand what your caode is telling me. Or how it working in conjunction with mine. Any thoughts?

 

Sub Main()
'get the path and name of the drawing file
path_and_name = ThisDoc.PathAndFileName(False) ' without extension

'define oDoc
oDoc = ThisDoc.Document

'specify the drawing sheet
oSheet = oDoc.Sheets("Sheet:1") ' sheet by name
'oSheet = oDoc.Sheets(1) ' first sheet

 ' say there is a Partslist on the sheet.
oPartslist = oSheet.PartsLists(1)

      
' create a new NameValueMap object
oOptions = ThisApplication.TransientObjects.CreateNameValueMap


'-------------Start of ilogic ------------------------------------------------

'specify the columns to export          
oOptions.Value("ExportedColumns") = "ITEM;QTY;M1 PART ID;REV;PART DESCRIPTION;WIDTH;LENGTH;PERIMETER;DETAIL;BLOCK WT;FINISH WT"
  
'specify the start cell
oOptions.Value("StartingCell") = "A1"
  
'specify the XLS tab name
'here the file name is used 
oOptions.Value("TableName") = "BILL OF MATERIALS"

oOptions.Value("ApplyCellFormatting") = True

'choose to autofit the column width in the xls file
oOptions.Value("AutoFitColumnWidth") = True

' export the Partslist to Excel with options

 

 

If File.Exists(path_and_name & ".xlsx") = True
      oSaveLocation = FileBrowse(True) ' True to indicate you want to use the file to save to; False if it is just to open it. 
Else
'If the file does not already exists, make it there
End if

 

oPartslist.Export(oSaveLocation, _
PartsListFileFormatEnum.kMicrosoftExcel, oOptions)  


'-------------End of ilogic ------------------------------------------------

GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "L1")= "Total Surface Area"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "L2")= iProperties.Value("Custom", "Total_Surface_Area")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "M1")= "Total Weight"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "M2")= iProperties.Value("Custom", "Assembly_Weight")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "N1")= "QTY of Assemblies"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "N2")= iProperties.Value("Custom", "QTY REQ'D")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "O1")= "Tag#"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "O2")= iProperties.Value("Project", "Part Number")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "P1")= "Customer"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "P2")= iProperties.Value("Custom", "Client")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "Q1")= "Customer PO#"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "Q2")= iProperties.Value("Custom", "Customer PO#")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "R1")= "Project"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "R2")= iProperties.Value("Custom", "Project")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "S1")= "Eng Det#"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "S2")= iProperties.Value("Custom", "Engineers Detail#")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "T1")= "DMI JOB#"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "T2")= iProperties.Value("Custom", "DMI JOB#")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "U1")= "Fabrication Operations"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "U2")= iProperties.Value("Custom", "Operations")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "V1")= "Weld Procedure #1"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "V2")= iProperties.Value("Custom", "Weld Procedure# 1")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "W1")= "Weld Procedure #2"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "W2")= iProperties.Value("Custom", "Weld Procedure# 2")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "X1")= "Delta Total LNFT of Weld"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "X2")= iProperties.Value("Custom", "Delta LNFT of Weld")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "X3")= "Shop Total LNFT of Weld"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "X4")= iProperties.Value("Custom", "Shop LNFT of Weld")

End Sub

Private Function FileBrowse(Save As Boolean)
    Dim oFileDlg As FileDialog
    ' Create a new FileDialog object.
    Call ThisApplication.CreateFileDialog(oFileDlg)

    ' Define the filter to select part and assembly files or any file.
    With oFileDlg
    '"

    ' Define the part and assembly files filter to be the default filter.
        .FilterIndex = 1
        .MultiSelectEnabled = False

    ' Set the title for the dialog.
    

        ' Set the initial directory that will be displayed in the dialog.
        oFileDlg.InitialDirectory = ThisApplication.FileOptions.ProjectsPath

        ' Set the flag so an error will be raised if the user clicks the Cancel button.
            .CancelError = True

        ' Show the open dialog.  The same procedure is also used for the Save dialog.
        ' The commented code can be used for the Save dialog.
           On Error Resume Next

        If Save = True
            .Filter = "Excel Files (*.xlsx)| *.xlsx"
            .DialogTitle = "Specify New Save Location and Name"
            .ShowSave
            Else
            '.Filter = "Inventor Files (*.iam;*.ipt;*.idw;*.dwg)|*.iam;*.ipt;*.idw;*.dwg|​All Files (*.*)|*.*"
            .Filter = "Excel Files (*.xlsx)| *.xlsx"
            .DialogTitle = "Select Excel File To Use As Drawing List"
             .ShowOpen
        End If
   oFileDlg.ShowSave
    End With
    
    If Err.Number <> 0 Then
        MsgBox("Error Exists")

   ElseIf Not oFileDlg.FileName = "" Then
        Dim fNames As Object
        fNames = Split(oFileDlg.FileName, "|")
        Dim curName As Object
        Dim lstSource As Object
        For Each curName In fNames
            lstSource.AddItem(curName)
        Next curName
    End If
Return oFileDlg.FileName
End Function

 


 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 17 of 19

Anonymous
Not applicable

I get the following error message:

 

Rule Compile Errors in Export properties to Excel for M1, in Delta Titleblock Template.dwg

Error on Line 41 : 'Exists' is not a member of 'Inventor.File'.

 

0 Likes
Message 18 of 19

MechMachineMan
Advisor
Advisor
System.IO.File instead of just File then.

Google msdn + vb.net.

It is your friend for all things iLogic programming.

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 19 of 19

Anonymous
Not applicable

The following pics is what i'm trying to accomplish.

 

1.png

When you right click on the Parts List it gives you the option to export. Click on that "Export" word and this Dialog Box pops up to choose where you want to save your export file.

 

Export Parts List Dialog Box.PNG

 

What is the code to make this box come up? Where do i insert it or what do i change in my code for this to happen? The Options button you see is the Code of "oOptions" you see in my code. I just want to be able to choose where i want to save the exported file.

 

0 Likes