- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I created an iPart factory called Rails.ipt, with some custom parameters in the table. The first one is a parameter called ScalingFactor. All dimensions of the solid are multiplied by ScalingFactor. Initially I only made one row in the table. In that row, ScalingFactor is 1.
I made a member named Adjuster Rail.ipt, by placing the iPart into an assembly. I opened that member, and in the object browser, I right clicked on the Table and chose Activate, clicked the Table tab and then changed ScalingFactor to 1.5. When I clicked OK, the solid immediately increased in size by 50%, as expected.
I wanted to write an external rule to change ScalingFactor in the member, so as a test I decided to try to change it to 0.98 using code. I got some odd results. I basically wanted to duplicate the actions I had just taken manually, but with a different number. I can do it manually, so I should be able to do it by code. But ...
The code below reads the parameter, and the value coming back is 1.5, so it's clearly coming from the table in the member part file - the one I changed to 1.5. The factory still has 1. When I SET the value, though, using the same cell reference, 2 odd things happened. First, the cell reference seems to have been invalidated, so that if I try to use the cell variable again without re-assigning it, I get an error.
When I read the value in the member again, it's unchanged; I was expecting it to be 0.98 afterward, but it was still 1.5. But ... the value in the FACTORY is now 0.98 instead of 1! Checking the table in each part file, I confirmed that although cell.Value returned the value in the member file, it changed the value in the factory file.
I'd appreciate any observations on what might be happening here, and how to accomplish this.
Dim docs As Documents = ThisApplication.Documents Dim doc As PartDocument = docs.Open("C:\Users\Don\Documents\Inventor\Shared\Linear Adjuster\Adjuster Rails.ipt") Dim pcd As PartComponentDefinition = doc.ComponentDefinition Dim member As iPartMember = pcd.iPartMember Dim row As iPartTableRow = member.Row Dim cell As iPartTableCell = row.Item(3) ' Get original value; this will come from table in MEMBER: Dim s As String = "Original: " & cell.Value ' Set new value; this will change value in FACTORY table: cell.Value = 0.98 ' Trying to use cell here causes an error unless you re-assign cell: cell = row.Item(3) ' Get new value; this will come from table in MEMBER: s = s & vbCr & "New: " & cell.Value MsgBox(s)
Solved! Go to Solution.