Inventor Engineer-To-Order (Read-Only)
Welcome to Autodesk’s Inventor ETO Forums. Share your knowledge, ask questions, and explore popular Inventor ETO topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to make a rule update???

4 REPLIES 4
Reply
Message 1 of 5
ludesroc
421 Views, 4 Replies

How to make a rule update???

How to make a rule update when making changes to SQL DB value?

 

I'm using this method...

 

Child IntentDbConnection As :dbConnection
dataProvider = :SQLSERVER
connectionString = "Data Source=" & dataSourceName & ";Initial Catalog=" & initialCatalogName & ";Integrated     Security=True"
onNullReturn = ""
showInModelBrowser? = True
End Child

' Get the design data.
Child DT_cDesign As :dbDataTable
Connection = IntentDbConnection
selectCommandText = "SELECT dbUniqueId, BaseStructureHeight, PanelDepthNumeric, UnitMounting FROM cDesign WHERE Name = '" & designName & "' "
tableName = "cDesign"
showInModelBrowser? = False
End Child

' Get the base height.
Uncached Rule BaseStructureHeight As String
If DT_cDesign.RowCount > 0 Then
Return DT_cDesign.getFieldValue(0, 1)
Else
Return ""
End If
End Rule

 

When making changes to the field (i.e.BaseStructureHeight), the rule doesn't update!!! I tried Uncached but that doesn't work!!!

 

Thanks!

Luc

Ludesroc
4 REPLIES 4
Message 2 of 5
AlexKorzun
in reply to: ludesroc

Hi Luc,

 

Several notes:

1. dbDataTable stores the tabular data in memory. If you know that the data cannot change and access to it is frequent, then it is the right solution. If you need to re-read data from the Server, call DT_cDesign.Fill() Method in your rule BaseStructureHeight

 

2. You may wish to consider another approach: perform the queries on IntentDbConnection child. The Methods of interest would be GetQueryResultsByRow or GetQueryResultsByColumn. The return value will be List of Lists. The translation between database and Intent data types is automatic. The documentation is available on Wiki.

 

Uncached Rule BaseStructureHeight As String

Dim result = IntentDbConnection.GetQueryResultsByRow("SELECT dbUniqueId, BaseStructureHeight, _

                     PanelDepthNumeric, UnitMounting FROM cDesign WHERE Name = '" & designName & "' ")

'.... more logic

 


End Rule

Thank you,




Alex Korzun
Inventor-Revit Interop / Inventor-Fusion Interop / Inventor ETO
Autodesk, Inc.

Message 3 of 5
ludesroc
in reply to: AlexKorzun

Thanks Alex!

 

Using either suggested methods works great. When evaluating the rule in the Immediate window, I get the updated value...

 

However, I need to find a way to trigger the update of the model. Is there a way to accomplish that? Rigth now, the only way I can update the model is by modifying the Intent code. I saw (Root.RenderSelf) but that doesn't seem to work!!!

 

Regards,

Luc

Ludesroc
Message 4 of 5
Jon.Balgley
in reply to: ludesroc

Since rules always have the correct value, there is no built-in way to "update".  Of course, if you change a rule's formula, then all dependent rules will update automatically.  In your situation, the rules no longer have the correct value because they have an external dependency.  So the solution to "fake" changing the rule's formula.  You do this directly thru the Intent API if you have a custom UI, or thru the IDE.  You can either literally change the rule's formula, or you can "unbind" it.  In either case, all dependent rules will also be unbound.  Then when you do an update/render, they will all be recomputed with the new values.  Of course you only have to change something that the DB-related rule depends upon, such as its connection string or whatever, in order to get it to re-read the data from the DB.

 

Hope this helps.

 


Jon Balgley
Message 5 of 5
ludesroc
in reply to: Jon.Balgley

Ok thanks John!

 

Will live with that for now! I guess we could had this to ETO Idea Station...Re-compute button!!!

 

Regards,

Luc

Ludesroc

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

Post to forums  

Autodesk Design & Make Report