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.
Solved! Go to Solution.
Solved by rhasell. Go to Solution.
Okay, can I give Kudo's to myself?
Anyway, I spent a little more time on the subject, and came across this thread here:
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