- 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, you appear to be trying to write to the active design project. I tend to find once files have been opened this is locked, and cannot be written to. It is also not always the file selected within the design project manager. Below is my code which is a bit messy but works, to get the currently selected project from the Context data passed with the button press..
Private Sub load_proj_options(Context As NameValueMap) Handles ss_OptButton.OnClick
Dim x As Integer = 1
Dim ds As String
Dim dp As DesignProject = Nothing
Do Until x = Context.Count
If Context.Name(x) = "ProjectFileName" Then
ds = Context.Item(x)
x = x + 1
End If
Loop
For Each design_project As Inventor.DesignProject In GlobalVars.m_inventorApplication.DesignProjectManager.DesignProjects
If design_project.FullFileName = ds Then
dp = design_project
End If
Next
If Not (IsNothing(dp)) Then
Dim n As New Proj_editor(dp)
n.ShowDialog()
End If
End Sub
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The edit always blocked if show Project Dialog
I found in a different place that this limitation of API. The AddiIn of ContentCenter use other path (not AI API).