Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic to drive iPart table update

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
1080 Views, 4 Replies

iLogic to drive iPart table update

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

 

 

 

Tags (2)
4 REPLIES 4
Message 2 of 5
adam.nagy
in reply to: Anonymous

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,



Adam Nagy
Autodesk Platform Services
Message 3 of 5
Anonymous
in reply to: adam.nagy

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?

Message 4 of 5
adam.nagy
in reply to: Anonymous

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? 



Adam Nagy
Autodesk Platform Services
Message 5 of 5
Anonymous
in reply to: adam.nagy

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report