Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ilogic drawing export to Excel, need iProperties from assembly also

3 REPLIES 3
Reply
Message 1 of 4
anders.klahr
2650 Views, 3 Replies

ilogic drawing export to Excel, need iProperties from assembly also

Hi, I am using iLogic to export BOM from a drawing to excel on a custom sheet that I have develop with a lot of help from earlier posts from this forum.

I would like to get the iProperties from the assembly file NOT the drawing.

Can I change it over from path_and_name & ".dwg" to path_and_name & ".asm" some how and then add the rows for what I need?

 

Below is my current code.

 


'-------------Start of ilogic ------------------------------------------------
'get the path and name of the drawing file
path_and_name = ThisDoc.PathAndFileName(False) 'without extension

'Define oDoc
oDoc = ThisDoc.Document

If Dir(path_and_name & ".xls") <> "" Then
Kill (path_and_name & ".xls")
Else
End If


'Specify the drawing sheet
oSheet = oDoc.Sheets("Sheet:1") 'Sheet by name
'oSheet = oDoc.Sheet(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 an existing template file
'To use For Formatting Colors, Fonts, etc
oOptions.Value("Template") = "D:\XXX\XXX.xls"

'Specify the columns to export
''oOptions.Value("ExportedColumns") = "DET. #; QTY.; DESCRIPTION; MATERIAL/VENDOR; PART NUMBER"
''oOptions.Value("ExportedColumns") = "Pos"

'Specify the start cell
oOptions.Value("StartingCell") = "A7"

'Specify the XLS Table Name
''oOptions.Value("TableName") = "BOMs"

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


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


'define Excel Application object
excelApp = CreateObject("Excel.Application")
'set Excel to run visibly
'change to false if you want to run it invisibly
excelApp.Visible = True
'open the workbook
wb = excelApp.Workbooks.Open(path_and_name & ".xls")

'Remove titles
excelApp.Range("A8:F200").Cut
excelApp.Range("A7").Insert

'Article nr
excelApp.Range("C7:C200").Cut
excelApp.Range("J7").Insert
excelApp.Cells(1,1).Select

'Description
excelApp.Range("C7:C200").Cut
excelApp.Range("I7").Insert
excelApp.Cells(1,1).Select

'Remark
excelApp.Range("C7:C200").Cut
excelApp.Range("L7").Insert
excelApp.Cells(1,1).Select

'Vendor
excelApp.Range("C7:C200").Cut
excelApp.Range("K7").Insert

excelApp.Cells(2,8) = iProperties.Value("Project", "Part Number")
excelApp.Cells(4,8) = iProperties.Value("Project", "Revision Number")
excelApp.Cells(5,8) = iProperties.Value("Project", "Creation Date")

excelApp.Cells(1,1).Select

'suppress prompts (such as the compatibility checker)
excelApp.DisplayAlerts = False

'save the workbook
wb.Save

'Close the workbook
''wb.Close

'------End of iLogic------

3 REPLIES 3
Message 2 of 4
adam.nagy
in reply to: anders.klahr

Hi,

 

You can use the Inventor API to access any iProperty in any document.

If you know the path of the document you can just open it up in the background and read the property from it.

e.g. http://forums.autodesk.com/t5/Inventor-General/iLogic-to-create-custom-iProperty-in-sub-component/td...

 

Cheers,



Adam Nagy
Autodesk Platform Services
Message 3 of 4
anders.klahr
in reply to: adam.nagy

Hi Adam, I suspected that I could do that but how??

For excample I want it to pick:

excelApp.Cells(X,X) = iProperties.Value("Project", "Description") But not from the drawing but from the IAM.

 

Any suggestions?

 

Kind regards

Anders

Message 4 of 4
Anonymous
in reply to: anders.klahr

Try the following to see if this is what you are looking at doing.

 

 

Modeldoc = ThisDrawing.ModelDocument

'for custom properties
Dim invCustomPropertySet As PropertySet
invCustomPropertySet = Modeldoc.PropertySets.Item("Inventor User Defined Properties")

 

'for standard properties
Dim invDesignInfo As PropertySet
invDesignInfo = Modeldoc.PropertySets.Item("Design Tracking Properties")

Dim invPartNumberProperty As Inventor.Property
invPartNumberProperty = invDesignInfo.Item("Part Number")

MessageBox.Show(invPartNumberProperty.Value)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report