iLogic parts list export to xls

iLogic parts list export to xls

Anonymous
Not applicable
1,896 Views
12 Replies
Message 1 of 13

iLogic parts list export to xls

Anonymous
Not applicable

Hello,

I've made a rule that creates an parts list on a drawing. (works perfect)

I've also made a rule wich exports this parts list to an exel file. (this also works perfect)

all parts in this list have an custom property A, B or C. 

 

Can someone tell me how i can export the different parts to different tabs in exel with iLogic? 

 

0 Likes
1,897 Views
12 Replies
Replies (12)
Message 2 of 13

Chirpyboy2060647
Advocate
Advocate

Heres something i use for one of my rules. You just change sheet1 to what ever sheet you want, hopefully that would work for you.

 

GoExcel.CellValue(ExcelFile, "Sheet1", "D2")  = iProperties.Value  ("Custom", "FI_001")

 

You will have to adjust the code to work for what your properties are but this should help you get started.

0 Likes
Message 3 of 13

Anonymous
Not applicable

Thanks, 

 

But i need to auto generate the bom in a folder i just created by copy design, with also a prefix on the assy name. 

So i can't specefy the folder and filename?

 

is there no code for ; all parts with property x value A send to sheet 1 and or all parts with property x value B send to sheet 2?

 

0 Likes
Message 4 of 13

Chirpyboy2060647
Advocate
Advocate

I believe so but sorry im not a real expert on ilogic, just started to get it going and have a script that creates excell file in the folder of my drawing its pulling from. It then pulls the custom iProperties/ Custom Table from my drawing and puts them where I need. You should be able to as long as the prop/value is called out in the iproperty of the part. Or you may just be stuck with picking one value over the other, not fully sure.

0 Likes
Message 5 of 13

Anonymous
Not applicable

Can I see your rule?

 

0 Likes
Message 6 of 13

Chirpyboy2060647
Advocate
Advocate

Sure its actually 2 rules. One writes the information to my template excel, while the other pulls my custom table onto the excel and writes a copy to my folder.

 

 

ExcelFile =  "\\Fig015\cad\0-File Transfer\Brian Maciejewski\Ship List Master" & ".xls"


'GoExcel.CellValue(ExcelFile, "Sheet1", "A1") = ("Date")'GoExcel.CellValue(ExcelFile, "Sheet1", "B1") = ("Team")'GoExcel.CellValue(ExcelFile, "Sheet1", "C1") = ("Project Number")'GoExcel.CellValue(ExcelFile, "Sheet1", "D1") = ("Project Name")'GoExcel.CellValue(ExcelFile, "Sheet1", "E1") = ("Description")'GoExcel.CellValue(ExcelFile, "Sheet1", "F1") = ("Fabric")

GoExcel.CellValue(ExcelFile, "Sheet1", "D2")  = iProperties.Value("Custom", "FI_001") 'Date Drawn
GoExcel.CellValue(ExcelFile, "Sheet1", "B2")  = iProperties.Value("Custom", "FI_002") 'Proj Manager
GoExcel.CellValue(ExcelFile, "Sheet1", "C2")  = iProperties.Value("Custom", "FI_005") 'Drawing Number
GoExcel.CellValue(ExcelFile, "Sheet1", "K1")  = iProperties.Value("Custom", "FI_007") 'Proj Name
GoExcel.CellValue(ExcelFile, "Sheet1", "E2")  = iProperties.Value("Custom", "FI_004")
GoExcel.CellValue(ExcelFile, "Sheet1", "F2")  = iProperties.Value("Custom", "FI_010") 'Fabric Application
GoExcel.CellValue(ExcelFile, "Sheet1", "F3")  = iProperties.Value("Custom", "FI_011") 'Fabric Type

GoExcel.CellValue(ExcelFile, "Sheet1", "K2")  = iProperties.Value("Custom", "FI_103") 'Order Numb
GoExcel.CellValue(ExcelFile, "Sheet1", "D1")  =  iProperties.Value("Custom", "FI_006") 'Client Name

and this is the second rule

'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.
oCustomTable = oSheet.CustomTables(2) 'this pulls the 2nd table
      
' create a new NameValueMap object
oOptions = ThisApplication.TransientObjects.CreateNameValueMap


'specify an existing template file 'to use For formatting colors, fonts, etc
oOptions.Value("Template") = "\\Fig015\cad\0-File Transfer\Brian Maciejewski\Ship List Master.xlsx"
  
  
'specify the start cell
oOptions.Value("StartingCell") = "M10"
  
'specify the XLS tab name'here the file name is used 
oOptions.Value("TableName") = ThisDoc.FileName(False) 'without extension


'choose to include the parts list title row'in this example "Ye Old List of Parts" is written to the StartingCell 
oOptions.Value("IncludeTitle") = True          


'choose to autofit the column width in the xls file
oOptions.Value("AutoFitColumnWidth") = True
        
' export the Partslist to Excel with options
oCustomTable.Export(path_and_name & ".xls", FileFormatEnum.kMicrosoftExcelformat, oOptions)


 

0 Likes
Message 7 of 13

Anonymous
Not applicable

here are my rules so far: (most parts I gathered on the forums)

 

create bom:

SyntaxEditor Code Snippet

iLogicVb.UpdateWhenDone = True   

'ThisBOM.Export("Parts Only", "Bom353.xls",  kMicrosoftExcelFormat)'ThisBOM.Export("Structured", "Bom631.xls",  kTextFileTabDelimitedFormat)'ThisBOM.Export("Structured", ThisDoc.ChangeExtension(".mdb"),  kMicrosoftAccessFormat)

'    On Error Resume Next
  
    ' Set a reference to the drawing document. This assumes a drawing document is active.    
    Dim oDrawDoc As DrawingDocument
     oDrawDoc = ThisApplication.ActiveDocument

    'Set a reference to the active sheet.    
    Dim oSheet As Sheet
    oSheet = oDrawDoc.ActiveSheet
    
    ' Set a reference to the first drawing view on the sheet. This assumes the first drawing view on the sheet is not a draft view.    
    Dim oDrawingView As DrawingView
    oDrawingView = oSheet.DrawingViews(1)
    
    ' Set a reference to the sheet's border    
    Dim oBorder As Border
    oBorder = oSheet.Border
    
    Dim oPlacementPoint As Point2d
        
        oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(0, 0)
        
         iLogicVb.UpdateWhenDone = True
    
    
    ' Create the parts list.    
    Dim oPartsList As PartsList
    'oPartsList = oSheet.PartsLists.Set(KPartsOnly)'    oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint,)
    PartList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint, PartsListLevelEnum.kPartsOnly)
'oPartsList = oSheet.PartsLists.Add(CurrView, oPt, kPartsOnly) 
    'oPartsList.Style = oDrawDoc.StylesManager.PartsListStyles.Item("Hoefnagels Small")
    
iLogicVb.UpdateWhenDone = True

iLogicVb.RunRule("export bom")

and export bom/ pdf:

 

SyntaxEditor Code Snippet

'start Of iLogic code----------------------------------------------------------------------------------'sort parts list
On Error Resume Next
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oPartsList1 As PartsList
oPartsList1 = oDrawDoc.ActiveSheet.PartsLists.Item(1)
'If oPartsList1 Is Nothing Then Resume Next

oPartsList1.Sort("TYPE")
'oPartsList1.Renumber'oPartsList1.SaveItemOverridesToBOM

'------------------------------------------------------------------------------------------------------------'Export Parts List
path_and_name = ThisDoc.PathAndFileName(False) ' without extension
Dim oDoc As Inventor.DrawingDocument
oDoc = ThisDoc.Document

Dim oSheet As Inventor.Sheet
'oSheet = oDoc.Sheets(1) ' first sheet
oSheet = oDoc.Sheets("Sheet:1") ' sheet by name

' say there is a Partslist on the sheet.
Dim oPartslist As PartsList

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

'specify an existing template file'to use For formatting colors, fonts, etc'oOptions.Value("Template") = "C:\Temp\PartListExport.xls"
 
'specify the columns to export         
oOptions.Value("ExportedColumns") = "QTY;PART NUMBER;DESCRIPTION;LENGTH;TYPE"
 
'specify the start cell
oOptions.Value("StartingCell") = "A3"
 
'specify the XLS tab name'here the file name is used'oOptions.Value("TableName") = ThisDoc.FileName(False) 'without extension

'choose to include the parts list title row'in this example "Ye Old List of Parts" is written to the StartingCell
oOptions.Value("IncludeTitle") = True          

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

On Error Goto handleXLSLock

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

''Publish document.'' export the Partslist to Excel.'oPartslist.Export(path_and_name & ".xls",PartsListFileFormatEnum.kMicrosoftExcel) 

'--------------------------------------------------------------------------------------------------------------------'set Drawn by name
iProperties.Value("Summary", "Author" ) = ThisApplication.GeneralOptions.UserName
'set date
iProperties.Value("Project", "Creation Date" ) = Now
InventorVb.DocumentUpdate()

'--------------------------------------------------------------------------------------------------------------------'Save PDF with options
path_and_namePDF = ThisDoc.PathAndFileName(False) ' without extension
PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
oDocument = ThisApplication.ActiveDocument
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

If PDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
'oOptions.Value("All_Color_AS_Black") = 0
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 400
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
'oOptions.Value("Custom_Begin_Sheet") = 2'oOptions.Value("Custom_End_Sheet") = 4
End If

'Set the destination file name
oDataMedium.FileName = path_and_namePDF & ".pdf"

On Error Goto handlePDFLock
'Publish document.
Call PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)

'--------------------------------------------------------------------------------------------------------------------
MessageBox.Show("PDF and Parts list saved in local VaultWorkingFolder", "files saved",MessageBoxButtons.OK,MessageBoxIcon.Information)
Exit Sub

handlePDFLock:MessageBox.Show("PDF could not be saved, most likely someone else has it open", "No PDF for you" & ThisApplication.GeneralOptions.UserName & "!")
Resume Next

handleXLSLock:MessageBox.Show("No XLS Saved", "Warning",MessageBoxButtons.OK,MessageBoxIcon.Warning)
Resume Next

'end of iLogic code-----------------------------------------------------------------------------









 

 

as you can see in the last rule I sort the parts list on property "TYPE".  

this is a custom text property which can be: A, B, C or D.

 

the thing is that I like to split these. A on sheet1, B on sheet2 etc.

0 Likes
Message 8 of 13

Chirpyboy2060647
Advocate
Advocate

Very nice, Hmmm could you some how change up where i call the go.excel ("") and add that to your last set but instead of sheet 1 you change it to whatever sheet you need?

0 Likes
Message 9 of 13

Anonymous
Not applicable

 

He can't find the custom property. 

I think because it's not a property in the assy, but only in the parts. 

 

even if he could find them i think all values for the property are placed, not only a specified value.

 

Check the picture. I'd like the values for TYPE on seperate sheets, but i find it very difficult..

 

 

0 Likes
Message 10 of 13

Chirpyboy2060647
Advocate
Advocate

If you right click on the part and go to iproperties then Custom, there is it typed in which type the part is? Or just manually entering in Type A-D

0 Likes
Message 11 of 13

mslosar
Advisor
Advisor

Can't you just For/Next your way throught the BOM? Then, if ThisProp="Whatever"then 'put this stuff on sheet1, elseif ThisProp="This" then 'put this on sheet2, etc?

0 Likes
Message 12 of 13

Chirpyboy2060647
Advocate
Advocate
Actually yeah, I don't see why something like that wouldn't work.
0 Likes
Message 13 of 13

Anonymous
Not applicable

Hi,

 

Yes this is what I'm trying, but i can't figure the exact code. 

I'm not a programmer. 

0 Likes