I've been working at automating much of many of our manual process.... one being a Sq Ft calculation of the flat pattern.
I have already created an iLogic rule that creates a Custom Iprop call SQ_FT;
iProperties.Value("Custom", "SQ_FT") = Round(SheetMetal.FlatExtentsArea/144,2)& " FT SQ"
I want to take it another step forward and use this in our iParts.
Using an exsiting iPart, add the custom property into table, which popluates that entire column with the same value.
To have this value update, close the table, activate each member one at a time and click "Yes" to the popup message;
The values in the Active Row of the table do not match the document's current values.
Do you wish to update the table before continuing?
SQ_FT: "0.05 FT SQ"!= "1.12FT SQ"
With an iPart that has less than 10 members this isn't to bad, but when there is 200+ its to much.
So, after scouring the forum and internet, I found some iLogic that will rebuild each member but does not update the table with the new custom property.
Here is the code;
Dim app As Inventor.Application = ThisApplication
Dim oDoc As Inventor.Document = app.ActiveDocument
Dim oCompDef As ComponentDefinition = oDoc.ComponentDefinition
Dim currow As Integer
Dim oFactory As iPartFactory
Dim oRow As iPartTableRow
Dim strSQ_FT As String
InventorVb.DocumentUpdate()
oFactory = ThisApplication.ActiveDocument.ComponentDefinition.iPartFactory
currow = oFactory.DefaultRow.Index
oFactory.DefaultRow = oFactory.TableRows.Item(1)
' Iterate through the rows
For Each oRow In oFactory.TableRows
oFactory.DefaultRow = oRow
' Set the row value for the SQ_FT column.
strSQ_FT = iProperties.Value("Custom", "SQ_FT")
'oRow.Item(iSQ_FTColumnIndex).Value = strSQ_FT
Next
oFactory.DefaultRow = oFactory.TableRows.Item(currow)
When I uncomment the line 'oRow.Item(iSQ_FTColumnIndex).Value = strSQ_FT, I get this error message;
System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Inventor.iPartTableRow.get_Item(Object Index)
at LmiRuleScript.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
I'm at a loss as to why I'm getting this message, let alone what I need to do to correct it.
Plus, I want to be able to generate the files as well.
Help!!
Rich
Hi,
Where is iSQ_FTColumnIndex coming from? Does not seem to be part of the code.
As a test I would try to replace it with its number equivalent.
Cheers,
The iSQ_FTColumnIndex is the column heading for my SQ_FT custom iproperty.
Will that have a number? Where do I look to find that?
Yes, but where is it declared?
The message says Incorrect Parameter and in that line there are only two parameters: one for Item() and the one being assigned to Value.
strSQ_FT is declared as String, so that should be OK - in theory 🙂
If you cannot figure this out on your side, then could you upload a non-confidential sample document that could be used to reproduce the issue?
I'm not sure how to declare or what to declare. I've tried a few things but everything ended up with an error.
So, here is a sample part. Any help is greatly appreciated.
Rich