Hi Jack,
Sorry for late reply.
Code for Following action as,
1. The Add-In code that connects to the Intent API and calls the "update parameter" action.
Code:
Public _API As Autodesk.Intent.IntentAPI
Public _IHostAPI As Autodesk.Intent.IntentInventor.Automation.IHostAPI
'Connect to Intent
API = Autodesk.Intent.IntentAPI.Instance
If _IHostAPI Is Nothing Then
_IHostAPI = _API.HostAPI
End If
'Update Parameter
ModelEvents = Autodesk.Intent.IntentAPI.Instance.ModelEvents
Dim Model As Autodesk.Intent.Model = _IHostAPI.IntentAPI.ActiveModel
Dim Val as String="123"
For i As Integer = 0 To Model.Root.GetAllRules.Count - 1
Dim ruleName As Autodesk.Intent.Rule = Model.Root.GetAllRules.Item(i)
If ruleName.Name = "CondenserPosition" Then
Model.Root.SetRuleValue(ruleName.Name, Val.Trim)
Model.Render()
End If
Next
' I have taken event to update Parameters
Private Sub ModelEvents_AfterRender(ByVal sender As System.Object, ByVal e As_ System.EventArgs) Handles ModelEvents.AfterRender
If e.ToString = "Ref string: Root, success: True" Then
MsgBox("Parameter updated successfully")
End If
End Sub
Above code works perfectly for AddIn Aplication.
2. The standalone code that invokes the Add-in code.
In Addin Application I have created Interface to execute command through Standalone application as
Code:
'User Defined Interface Exposed through the Add-In Automation property
Public Interface AutomationInterface
Sub ExecuteCreate(ByVal Val As String)
End Interface
'Create command which is going to call through Standalone application
Public Sub ExecuteCreate(ByVal Val As String) Implements AutomationInterface.ExecuteCreate
'Connect to Intent. API and IHostAPI have declared as public
API = Autodesk.Intent.IntentAPI.Instance
If _IHostAPI Is Nothing Then
_IHostAPI = _API.HostAPI
End If
'Update Parameter with value of Val
ModelEvents = Autodesk.Intent.IntentAPI.Instance.ModelEvents
Dim Model As Autodesk.Intent.Model = _IHostAPI.IntentAPI.ActiveModel
For i As Integer = 0 To Model.Root.GetAllRules.Count - 1
Dim ruleName As Autodesk.Intent.Rule = Model.Root.GetAllRules.Item(i)
If ruleName.Name = "CondenserPosition" Then
Model.Root.SetRuleValue(ruleName.Name, Val.Trim)
Model.Render()
End If
Next
End Sub
'This event call after executing Model.Render() line of function ExecuteCreate()
Private Sub ModelEvents_AfterRender(ByVal sender As System.Object, ByVal e As_ System.EventArgs) Handles ModelEvents.AfterRender
If e.ToString = "Ref string: Root, success: True" Then
MsgBox("Parameter updated successfully")
End If
End Sub
I am calling above code through Standalone application as,
Dim oAddInComponent As AutomationInterface
Try
For Each addIn As ApplicationAddIn In g_oInventorApp.ApplicationAddIns
If addIn.ClassIdString = "{FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFF0}" Then
oAddInComponent = CType(addIn.Automation, AutomationInterface)
oAddInComponent.ExecuteCreate("123")
Exit For
End If
Next
Catch ex As Exception
End Try
3. The exact output of the error you are getting. Is it a message box, an exception in the code, or ?
When application execute line of Model.Render() through the Standalone application of AddIn that time it goes to Event of ModelEvents_AfterRender here it gives value of
e.ToString = "Ref string: Root, Failed:
If it is failed that time it will unable to update parameter.
Please suggest your opinion for this.
Thanks & Regards,
Rupali
Edited by: rpb06027 on Oct 27, 2009 10:17 AM