style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"jonbrabbs" wrote in messageMorning
href="news:6121098@discussion.autodesk.com">news:6121098@discussion.autodesk.com...
All,
Does anyone know if it is possible to update the weight if
iParts? I've been trying to write some code to scroll through each line of the
iPart table, and generate the weights for each variant (about 30 of them), but
don't seem to be getting anywhere.
Any help would be
appreciated (even if it's "No! You can't do that.")
Many thanks
Jon
' Iterate through the rows
Dim oRow As iPartTableRow
Dim strWeight as String
For Each oRow In oFactory.TableRows
' Make this the active row so the model will recompute.
oFactory.DefaultRow = oRow
' Set the row value for the weight column.
strWeight = oRow.Item(iWeightColumnIndex).Value
' Overwrite the iProperty.
oPartDoc.ComponentDefinition.MassProperties.Mass = strWeight
Next
End Sub
I've not tested this, so you'll have to let me know if it works. If not, I'll have a play with it during the week and re-post. You may need to set your spreadsheet values to those similar to your default iProperty values (eg x.xxx kg).
Good luck, let me know how you get on.
Jon
Jeremy,
Hmmmmmmmm.......
I've spent a bit of time on this, and it seems to not be as straight forward as I thought (somewhat unsuprisingly - very little ever is!)
It seems that whilst it is possible to override the weight (I've got it to do this on save), it only updates the active part. This would mean that you had to save each part individually, thus negating the benefit of iParts. Also when put into an assembly, it reverts back to its calculated weight - irritating.
I'll have a ponder over it, as and when I get chance, and get back to you.
Hmmmmmmmm.......
Jon
Hi Jon,
I'm interested in this too. Did you ever figure it out?
Thanks in advance.
Bob