Is it possible to determine the row of an iPart without changing the iPart to that row?
We have many iLogic rules and have noticed that we can improve performance by minimizing the number of commands that we are sending to Inventor. I am looking for a method to change the iPart row only if it is actually going to change. Below is an example of what I want to accomplish.
i = iPart.FindRow("Motor", "MotorHP", "=", "75HP") ' Only return row number, do not udpate
rowNumber = iPart.RowNumber("Motor")
If rowNumber <> i Then
iPart.FindRow("Motor", "MotorHP", "=", "75HP") ' Make update
End If
We have had great success in increasing performance with the "Component.IsActive" command as shown below.
If myPart = "Part1" Then
If Component.IsActive("Part1") = False Then
Component.IsActive("Part1") = True 'Only send command if it is suppressed
End If
Else
If Component.IsActive("Part1") = True Then
Component.IsActive("Part1") = False 'Only send command if it is active
End If
End If
Thanks,
Shawn
Solved! Go to Solution.
Solved by MjDeck. Go to Solution.
Shawn,
A rule like this should help:
rowNumber = iPart.RowNumber("Motor") hpCurrent = iPart.CurrentRowStringValue("MotorHP") hpWanted = "75HP" If (hpCurrent <> hpWanted) Then i = iPart.FindRow("Motor", "MotorHP", "=", hpWanted) End If
You can't search for the row without changing it, but you can read any of the values in the current row and see if it's what you want.
Thanks Mike,
I was thinking of looking that direction next, but was hoping there was a simpler method I was not finding. Your solution will work great for us. Thanks again.
-Shawn
Shawn,
I'm concerned about the Component.IsActive performance. It seesm like it shouldn't require the code you added to speed it up. How much of a performance improvement does that code provide? Can you post a sample assembly that demonstrates the improvement? We might be able to speed up the function internally.
I believe the code itself processes very quickly, the lag was coming from Inventor (2010.) We have several of our larger sub-assemblies and many constraints to them that are controlled by the Component.IsActive command. Watching the Inventor status bar showed the delay if we tried to suppress/unsuppress something that was already suppressed/unsuppressed. It ran faster if it was performing the operation as opposed to sending the command that kept the same state (not sure that made sense, but I can't think of another way to explain it.)
Once I switched the code we saw our full model configuration time drop from 30+ minutes to approx 6 minutes. This was with 2010, I haven't had the opportunity to try this with our 2012 test set-up yet.
Unfortunately the problem is only noticeable with our larger assemblies, small assemblies and individual parts process very quickly (<1sec.) Next week I will move some of our large assemblies into our test environment and see if 2012 handles the situation differently.
-Shawn
Update - I tried to make a simplified assembly but was unable to duplicate the long processing times. Our production models have tube & pipe runs attached to them, so perhaps the time lag has to do with calculations to features other than those that I am directly controlling.
For the test I used our production models which have 10 sub assemblies which I am controlling suppression and one constraint each. I used trace.writeline and DebugView to track the rule progression and to time the operations. I found that our test machine with Inventor 2012 processes significantly faster than our 2010 production machines. Also, the constraints processed much slower than the components. Results are shown below.
Inventor 2010
Not checking current state - 32.4 seconds
Checking state first - 0.03 seconds
Inventor 2012
Not checking current state - 3.6 seconds
Checking state first - 0.03 seconds
I'm encouraged by the quicker processing of Inventor 2012, but will conduct more tests once we make the upgrade and have Vault integration etc.
With Inventor 2010 the 32.4 seconds for a single rule does not seem to bad, but we are running approximately 100 rules in our configuration. Identifying the slower rules and improving efficiencies has made a huge difference in the total configuration time.
-Shawn
Shawn,
Are you changing constraint suppression as well as component suppression within the same block? Something like this:
If Component.IsActive("Part1") = ...
Component.IsActive("Part1") = ...
Constraint.IsActive("Mate:1") = ...
' more constraint changes...
End If
In the slow (as we experience it) scenario; the same If statement that determines if the component is active also contains the constraints.
If Component = "Part1"Then
Component.IsActive("Part1") = True
Constraint.IsActive("Mate:1") = True
' more constraint changes...
End If
In the quicker processing rule I look at the component and the constraint individually
If Component = "Part1" Then
If Component.IsActive("Part1") = False Then
Component.IsActive("Part1") = True
End If
If Constraint.IsActive("Mate1") = False Then
Constraint.IsActive("Mate1") = True
End If
End If