Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I did new option button to Project's Dialog. But when I try change the Properties of ActiveDesignProject in sub of event sink, Inventor API return exception. Inventor API does not change the Properties of DesignProject until the Project's Dialog is opened.
But Content Center AddIn can do changes to DesignProject with open Project's Dialog. How Content Center AddIn does it?
Why do I fails it?
I attached two screenshots and vb.net sample code:
Imports Inventor Imports System Imports System.Runtime.InteropServices Module Module1 'Идентификатор кнопки Private OptButton As ProjectOptionsButton Private InvApp As Application Sub Main() InvApp = GetInventorApplication() Const ID As String = "123" OptButton = InvApp.DesignProjectManager.AddOptionsButton(ID, "MyButton", "Option") 'Привязка делегата AddHandler OptButton.OnClick, AddressOf OnClick 'Цикл обработки сообщений System.Windows.Forms.Application.Run() End Sub 'Процедура приемник события Private Sub OnClick(Context As NameValueMap) Try InvApp.DesignProjectManager.ActiveDesignProject.OldVersionsToKeep = 5 Catch ex As Exception Console.WriteLine(":(((((((") End Try End Sub 'Функция получения ссылки на Inventor Function GetInventorApplication() As Application Dim InvApp As Application Try 'Попытка присоединится к загруженному в память Inventor InvApp = CType(Marshal.GetActiveObject("Inventor.Application"), Application) Catch ex As Exception 'Загрузка Inventor в память и присоединение к нему Dim InvType As Type = Type.GetTypeFromProgID("Inventor.Application") InvApp = CType(Activator.CreateInstance(InvType), Application) InvApp.Visible = True End Try Return InvApp End Function End Module
Solved! Go to Solution.