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: 

Change Parts list item via iLogic

1 REPLY 1
SOLVED
Reply
Message 1 of 2
rhasell
1507 Views, 1 Reply

Change Parts list item via iLogic

Hi all

 

I need some help from all the iLogic guru's please.

 

I need to change a cell value in the parts list.

1. There is a User Parameter "LENGTH" which is not always populated.

2: If the Value is = "0" (Zero) OR is empty then replace the cell value to a dash "-"

3: It does not need to be written back to the parts.

 

I tried to re-work the examples from the Programming help files, but I did not know what I was doing, and end up changing everything to a dash.

 

See screen shot of what I am trying to achive.

 

If needed I can post my attempt at the code, but it just might confuse the whole issue.

 

Thanks.

 

partslist-mod.JPG

 

Reg
2024.2
Please Accept as a solution / Kudos
1 REPLY 1
Message 2 of 2
rhasell
in reply to: rhasell

Okay, can I give Kudo's to myself?

 

Anyway, I spent a little more time on the subject, and came across this thread here:

http://forums.autodesk.com/t5/Inventor-General/Write-text-string-to-Parts-List-with-iLogic/td-p/3797...

 

I then modified it a little to accomplish two required tasks.

 

I have not spent too much time on the clean-up, and/or troubleshooting, but it works quite well.  The only reason I wrote back the Quantity parameter, was for reference purposes in a form.

 

The only bug I have found is that on large Parts lists, it slows down a lot, and will take a minute or two to execute.

 

Sub Main()
' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
'''---------------------
'define custom property collection
oCustomPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties")
Try
'set property value
oProp = oCustomPropertySet.Item("ASSQTY")
Catch
' Assume error means not found so create it
oCustomPropertySet.Add("", "ASSQTY")
End Try
'''-----------------------

' Set a reference to the first parts list on the active sheet.
Dim oPartList As PartsList
oPartList = oDrawDoc.ActiveSheet.PartsLists.Item(1)
oASSQTY = InputBox("Prompt", "Title",iProperties.Value("Custom", "ASSQTY") )
iProperties.Value("Custom", "ASSQTY") = oASSQTY
' Iterate through the contents of the parts list.
Dim i As Long
For i = 1 To oPartList.PartsListRows.Count
oCell = oPartList.PartsListRows.Item(i).Item("AS*") ' Note to Forum, my text has been censored, replace * with "S"
oCell2  = oPartList.PartsListRows.Item(i).Item("LENGTH")
'write to the target cell
oCell.Value = iProperties.Value("Custom", "ASSQTY")
If oCell2.Value = "0" Or oCell2.Value = "" Then
oCell2.Value = "-"
End If
Next 
'Next Sub Routine
'Removed because it has been incorporated above.
'length
End Sub

 

 

Reg
2024.2
Please Accept as a solution / Kudos

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

Post to forums  

Autodesk Design & Make Report