Export material list to personalized excel file

Export material list to personalized excel file

Anonymous
Not applicable
1,375 Views
8 Replies
Message 1 of 9

Export material list to personalized excel file

Anonymous
Not applicable

Hi,

 

I need to export a material list to a personalized excel file, how I can do it?.

 

Thanks

 

Iñigo

0 Likes
1,376 Views
8 Replies
Replies (8)
Message 2 of 9

b_sharanraj
Advocate
Advocate

Try this iLogic Code once 🙂

 

Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument
    
Dim Material As Material

ExcelFile = "C:\Users\XYZ\AppData\Local\Temp\Material_List.xlsx"

ExcelApp = CreateObject("Excel.Application")

ExcelApp.Visible = True

ExcelApp.DisplayAlerts = False

ExcelWorkbook = ExcelApp.Workbooks.Open(ExcelFile)
ExcelSheet = ExcelWorkbook.Worksheets(1)

Count = 1
With ExcelApp
For Each Material In oPartDoc.Materials    .Range("A" & Count).Select    .ActiveCell.FormulaR1C1 = Material.Name
    Count = Count + 1
Next
End With   

ExcelApp.Columns.AutoFit   
ExcelWorkbook.SaveAs (ExcelFile)

ExcelWorkbook.Close
ExcelApp.Quit
ExcelApp = Nothing 

 

Regards

B.Sharan Raj

0 Likes
Message 3 of 9

Anonymous
Not applicable

Hi,

 

That error ocurred:

 

System.InvalidCastException: No se puede convertir el objeto COM del tipo 'Inventor._DocumentClass' al tipo de interfaz 'Inventor.PartDocument'. Ocurrió un error de operación debido a que la llamada QueryInterface en el componente COM para la interfaz con IID '{29F0D463-C114-11D2-B77F-0060B0F159EF}' generó el siguiente error: Interfaz no compatible (Excepción de HRESULT: 0x80004002 (E_NOINTERFACE)).
en LmiRuleScript.Main()
en Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
en iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

We have inventor 2018

 

Thanks


0 Likes
Message 4 of 9

MechMachineMan
Advisor
Advisor
If ThisApplication.ActiveDocument.DocumentType <> 12290 Then
    MsgBox("This rule is only valid for Part Documents")
    Exit Sub
End if

Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument
    
Dim Material As Material

ExcelFile = "C:\Users\XYZ\AppData\Local\Temp\Material_List.xlsx"

ExcelApp = CreateObject("Excel.Application")

ExcelApp.Visible = True

ExcelApp.DisplayAlerts = False

ExcelWorkbook = ExcelApp.Workbooks.Open(ExcelFile)
ExcelSheet = ExcelWorkbook.Worksheets(1)

Count = 1
With ExcelApp
For Each Material In oPartDoc.Materials
    .Range("A" & Count).Select
    .ActiveCell.FormulaR1C1 = Material.Name
    Count = Count + 1
Next
End With   

ExcelApp.Columns.AutoFit   
ExcelWorkbook.SaveAs (ExcelFile)

ExcelWorkbook.Close
ExcelApp.Quit
ExcelApp = Nothing 

 

BUT I assume by material list you don't mean "material" as in what you select in Inventor, but instead a field that describes the material used for the part (Ie; HSS 2 X 2 X .25W) which highlights the importance of not withholding information and being clear about your requirements.


--------------------------------------
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 5 of 9

Anonymous
Not applicable

Hi,

 

My assembly when is finished i make a drawing with it and then i put in a material list with all parts, then i make the same material list in an excel file but with personalized excel file. So I want to export the Inventors material list to that excel file. Is complicated to do it?

 

 

Thanks

0 Likes
Message 6 of 9

Anonymous
Not applicable

Material list = Part list

0 Likes
Message 7 of 9

b_sharanraj
Advocate
Advocate

Do you need to Export the Applied Material of Each Part from the Assembly?

Regards

B.Sharan Raj

0 Likes
Message 8 of 9

Anonymous
Not applicable
A part list with quantities

Thanks
0 Likes
Message 9 of 9

MechMachineMan
Advisor
Advisor

Hi,

 

Place the desired parts list in a drawing. Edit PartsList. Export Parts List. Select desired template. Done.


--------------------------------------
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