iLogic update part Quantity

iLogic update part Quantity

Anonymous
Not applicable
531 Views
3 Replies
Message 1 of 4

iLogic update part Quantity

Anonymous
Not applicable

I'm new to iLogic. From a drawing file I want to update the Total Quantity (TQTY) of parts that I find in an Excel Spreadsheet. I wrote the following code and it will update the Custom Drawing Properties OK but I'm stumped as to why it won't update the model properties (TQTY) in the part file.

Any Help will be grateful.

 

 
 

 

0 Likes
532 Views
3 Replies
Replies (3)
Message 2 of 4

MechMachineMan
Advisor
Advisor

Check out Autodesk's documentation on iLogic.

 

'https://knowledge.autodesk.com/support/inventor-products/learn-explore/caas/CloudHelp/cloudhelp/2015...

 

Something like this should hopefully have you a bit closer. I'm not too well versed in iLogic, so some of it may be wrong.

 

oPath = ThisDoc.WorkspacePath()

oBack = InStrRev(oPath, "\")
ofileName = Mid(oPath,oBack+1,6) + ".xls"
oFilePath = oPath + "\" + oFileName

oDWG = ThisDrawing.ActiveSheet.Name

oColon = InStrRev(oDWG, ":")
oPart = Left(oDWG,oColon-1)

ExcelRow = GoExcel.FindRow(oFilePath, "Sheet1", "PART", "*", oPart)
oCell = "A" + CStr(ExcelRow)

QTY = GoExcel.CellValue(oCell)

iProperties.Value("Custom", "TQTY") = QTY

oPartName = oPath + "\" + oPart + ".ipt"

iProperties.Value(oPartName, "Custom", "TQTY") = QTY

InventorVb.DocumentUpdate()

 


--------------------------------------
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
Message 3 of 4

Owner2229
Advisor
Advisor

Hey, try this:

 

Dim oDoc As Document = ThisApplication.ActiveDocument
If oDoc.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub
Dim oPath As String = ThisDoc.WorkspacePath()
Dim oBack As Integer = InStrRev(oPath, "\")
Dim oFileName As String = Mid(oPath, oBack + 1, 6) & ".xls"
Dim oFilePath As String = oPath & "\" & oFileName
Dim oDWG As String = oDoc.ActiveSheet.Name
Dim oColon As Integer = InStrRev(oDWG, ":")
Dim oPart As String = Left(oDWG, oColon - 1)
Dim ExcelRow As Integer = GoExcel.FindRow(oFilePath, "Sheet1", "PART", "*", oPart)
Dim QTY As String = GoExcel.CellValue("A" & CStr(ExcelRow))

iProperties.Value("Custom", "TQTY") = QTY

Dim ModelDoc As Document = oDoc.ReferencedDocuments(1)
Dim oPropSet As PropertySet = ModelDoc.PropertySets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
oPropSet.Item("TQTY").Expression = QTY
ModelDoc.Save()

InventorVb.DocumentUpdate()

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 4 of 4

Anonymous
Not applicable

Got it to work. Had to change a couple of lines. Next will be to go through all the parts and update the quantities.

Final changes attached

Thanks