004 - Inventor装配体材料表输出及自定义属性的更新

2023-11-17  本文已影响0人  怪怪001

背景:创建一个iLogic规则从最大装配体中生成一个excel格式的材料表清单。

 BOM表输出

'Get the Filename of the file without the extension

FileName = ThisDoc.FileName(False) 'without extension

'Sets the path and filename of where the Exported BOM should be saved

BOMFile = "C:\BOMs\" & FileName & ".xls"

'Exports the BOM to the desired location

ThisBOM.Export("Structured", BOMFile, kMicrosoftExcelFormat)

'kMicrosoftAccessFormat = Microsoft Access

'kMicrosoftExcelFormat = Microsoft Excel

'kdBASEIIIFormat = dBASE III

'kdBASEIVFormat = dBASE IV

'kTextFileTabDelimitedFormat = Text File Tab Delimited

'kTextFileCommaDelimitedFormat = Text File Comma Delimited

'kUnicodeTextFileTabDelimitedFormat = Unicode Text File Tab Delimited

'kUnicodeTextFileCommaDelimitedFormat = Unicode Text File Comma Delimited

读取装配图的材料表信息并更新自定义属性值

'Gets name of reference assembly from iProperties and identifies the spreadsheet to be read

BOMFile = "C:\BOMs\" & iProperties.Value("Custom", "Assembly Name") & ".xls"

'Gets the name of the model represented in the oldest view on the drawing

modelName = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)

modelName = Strings.Left(modelName, modelName.Length - 4)

'Reads information from the specified spreadsheet and places values in properties

i = GoExcel.FindRow(BOMFile, "Sheet1", "Part Number", "=", modelName)

iProperties.Value("Custom", "Item") = GoExcel.CurrentRowValue("Item")

iProperties.Value("Custom", "QTY") = GoExcel.CurrentRowValue("QTY")

'Updates the view

iLogicVb.UpdateWhenDone = True

上一篇下一篇

猜你喜欢

热点阅读