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: 

Initialise Intent object through Stand-alone Application.

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
740 Views, 5 Replies

Initialise Intent object through Stand-alone Application.

Hi,

I am working on Inventor Automation 2010 using vb.net. I have created standalone application .Its opening Intent assembly using Invenor api. Now I want to access Intent API to get and set Parametrs value. I have written code as

Try
Dim_API As Autodesk.Intent.IntentAPI
Dim _IHostAPI As Autodesk.Intent.IntentInventor.Automation.IHostAPI
_API = Autodesk.Intent.IntentAPI.Instance
Catch ex As Exception
Try
_API = Autodesk.Intent.IntentAPI.Create
Catch ex1 As Exception

End Try
End Try
If _IHostAPI Is Nothing Then
_IHostAPI = _API.HostAPI
End If

It gives me error as Invent not Initialise yet after _API = Autodesk.Intent.IntentAPI.Instance
and also File not found exception after _API = Autodesk.Intent.IntentAPI.Create

Could anyone help how to initialise Intent through Standalone appliaction.
Please help! I stuck in it.
Thanks in advance.
5 REPLIES 5
Message 2 of 6
JackGregory
in reply to: Anonymous

You state that you are creating a "Standalone" application. Intent does not support this at the present time. Intent runs in-process in Inventor, and any uses of the API must also be in-process Add-ins to Inventor.

If I am making the wrong interpretation of what you said, please clarify what you mean by "Standalone application".

--Jack Gregory
Autodesk
Message 3 of 6
Anonymous
in reply to: Anonymous

Hello,

Thanks for the reply. Now I have created Inventor AddIn and written function as command for initializing Intent.Now through my standalone application , I am connecting to addin and execute that function but same error is occurring where as through the Addin I am able to connect to Intent by using same code but not through standalone application via connecting addin. Please help me.Is this is of Intent problem?

Thanks & Regards,
Rupali
Message 4 of 6
Anonymous
in reply to: Anonymous

Hi,

Now I am able to connect to Intent by accessing AddIn through Standalone Application but now the problem is that, I am able to get value of parameters but unable to update parameter's value .Its showing error "Error while updating Parameter ". Please help me to solve this issue.

Thanks & Regards,
Rupali
Message 5 of 6
JackGregory
in reply to: Anonymous

Rupali:
I am sorry, but there isn't enough information here to determine what is wrong. If you have a simple demonstration of the problem that you can send to Intent Support, please do so. Otherwise, I would like to see the following:
1. The Add-In code that connects to the Intent API and calls the "update parameter" action.

2. The standalone code that invokes the Add-in code.

3. The exact output of the error you are getting. Is it a message box, an exception in the code, or ?

Note that there is no Intent API call "update parameter", so you need to be specific.


--Jack Gregory

Autodesk

Message 6 of 6
Anonymous
in reply to: Anonymous

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

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

Post to forums  

Autodesk Design & Make Report