Forcing an iPart member rebuild, calc/update and save/generate.

Forcing an iPart member rebuild, calc/update and save/generate.

mark_howard2FYWW
Contributor Contributor
243 Views
3 Replies
Message 1 of 4

Forcing an iPart member rebuild, calc/update and save/generate.

mark_howard2FYWW
Contributor
Contributor

I'm a bit stumped and could use some pointers. I'm almost certain this is a case of processes running in parallel, or when they are queued up, but I'm not smart enough to find a way around. I've uploaded a simple sample part to show my issue. We have about 900 iPart/iAssy Factories for standard parts. 600 of those are iParts and many are sheet metal. We pass a parameter "SM_AREA" to our new ERP system to track material usage. It 'reserves' or triggers an order for more if we don't have enough on hand. The real numbers come from our laser workflow but are checked against this as a kind of balance. We discovered at inventory last year we were way off. I added some iLogic and an event trigger to grab the latest sheet metal flat extents and pass it to a unitless parameter called SM_AREA. That is in turn set to export to a custom iProperty as a 3 digit precision number that goes to ERP. Since ipart members don't have iLogic, this throws errors upon opening assemblies using them, with those event triggers set.

 

My solution was to remove the event triggers from any iPart factory. I replaced it with a suppressed rule we run before checking in a factory. it walks through each member, updates the flat extents and SM_AREA, and generates the member so we can check up to date ones in to Vault. I thought I had this nailed, when I started finding parts out of date with erroneous numbers, typically all members would have the default/current members values. I tried a second variation and got closer, but still some errors. I'm on to my third iteration, forcing calcs in between etc. The closest I've gotten updates all rows but the last two, which end up both having the value of the last row. I'm hoping someone can point out some glaring mistake to my code or thought process. Thanks in advance!

 

0 Likes
Accepted solutions (1)
244 Views
3 Replies
Replies (3)
Message 2 of 4

mark_howard2FYWW
Contributor
Contributor
Accepted solution

Well, I answered my own question, what a noob. I forgot the distinction between:

Parameter.UpdateAfterChange = True 'set at top of my code...

 

GSS_RM_AREA = Round(SheetMetal.FlatExtentsArea, 3) 'this updates when next For cycles
parameter("GSS_RM_AREA") = Round(SheetMetal.FlatExtentsArea, 3) 'this updates NOW


Hopefully someone will learn from my mistake. 

Ooof, I'm going back to bed.

0 Likes
Message 3 of 4

mark_howard2FYWW
Contributor
Contributor

Another very helpful user pointed out I could have used "RuleParametersOutput()" on its own line in my code. I can be used in conjunction with InventorVb.DocumentUpdate() to trigger a model regeneration mid-rule. This forces an immediate update/push of changed parameters into the model, regardless of "Parameter.UpdateAfterChange" setting.

0 Likes
Message 4 of 4

mark_howard2FYWW
Contributor
Contributor

Here is my updated code for reference, I know I search for snippets on here all the time.

 

'for sheet metal iPart factories only
Parameter.UpdateAfterChange = True 'updates right away
Dim oDoc As PartDocument = ThisDoc.Document
Dim TempScope As Integer
TempScope = oDoc.ComponentDefinition.ModelStates.MemberEditScope
If TempScope = 57602 Then
	oDoc.ComponentDefinition.ModelStates.MemberEditScope = 57601
Else
	'It was already set to edit member scope
End If
Dim oPartDef As PartComponentDefinition = oDoc.ComponentDefinition
Dim oFactory As iPartFactory = oPartDef.iPartFactory
Dim oRow As iPartTableRow
If oPartDef.IsiPartFactory = True Then
	Dim iNumRows As Integer
	iNumRows = oFactory.TableRows.Count
	Dim iRow As Integer
	For iRow = 0 To iNumRows
		iPart.ChangeRow("", iRow)
		parameter("SM_AREA") = Round(SheetMetal.FlatExtentsArea, 3) 'updates right away
		'SM_AREA = Round(SheetMetal.FlatExtentsArea, 3) 'updates after loop / late
		iProperties.Value("Custom", "SM_AREA") = SM_AREA
		Call oFactory.CreateMember
	Next
End If
iLogicVb.UpdateWhenDone = True
'set back to original edit scope
oDoc.ComponentDefinition.ModelStates.MemberEditScope = TempScope
0 Likes