<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: DesignProject return exception when properties try change. in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/designproject-return-exception-when-properties-try-change/m-p/5995202#M61038</link>
    <description>&lt;P&gt;The edit always blocked if show Project Dialog&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found in a different place that this limitation of API. The AddiIn of ContentCenter use other path (not AI API).&lt;/P&gt;</description>
    <pubDate>Tue, 19 Jan 2016 10:26:22 GMT</pubDate>
    <dc:creator>mikazakov</dc:creator>
    <dc:date>2016-01-19T10:26:22Z</dc:date>
    <item>
      <title>DesignProject return exception when properties try change.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/designproject-return-exception-when-properties-try-change/m-p/5992717#M60981</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I did new option button to Project's Dialog. But when I try&amp;nbsp;change the Properties of ActiveDesignProject in sub of event sink, Inventor API return exception. &lt;SPAN&gt;Inventor API&lt;/SPAN&gt;&amp;nbsp;does not change the &lt;SPAN&gt;Properties of DesignProject&lt;/SPAN&gt;&amp;nbsp;until the &lt;SPAN&gt;Project's&lt;/SPAN&gt;&amp;nbsp;Dialog is opened.&lt;/P&gt;&lt;P&gt;But Content Center AddIn&amp;nbsp;can do changes to&amp;nbsp;&lt;SPAN&gt;DesignProject&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;with&amp;nbsp;open Project's&lt;SPAN&gt;&amp;nbsp;Dialog.&amp;nbsp;How Content Center AddIn does it?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Why do I fails it?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I attached two screenshots and vb.net sample code:&lt;/P&gt;&lt;PRE&gt;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&lt;/PRE&gt;&lt;P&gt;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/212065iB405DD85407013B5/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="ProjectDialog.png" title="ProjectDialog.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/212066i7ED577AB0876E8BF/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Console.png" title="Console.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jan 2016 12:03:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/designproject-return-exception-when-properties-try-change/m-p/5992717#M60981</guid>
      <dc:creator>mikazakov</dc:creator>
      <dc:date>2016-01-17T12:03:30Z</dc:date>
    </item>
    <item>
      <title>Re: DesignProject return exception when properties try change.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/designproject-return-exception-when-properties-try-change/m-p/5994693#M61026</link>
      <description>&lt;P&gt;Hi, you appear to be trying to write to the active design project. I tend to&amp;nbsp;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&amp;nbsp;manager. Below is my code which is a bit messy but works, to get the currently selected project from the Context data&amp;nbsp;passed with the button press..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;Private&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Consolas" size="2"&gt;Sub&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; load_proj_options(Context &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;As&lt;/FONT&gt; &lt;FONT color="#2b91af" face="Consolas" size="2"&gt;NameValueMap&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;Handles&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; ss_OptButton.OnClick&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&amp;nbsp;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt; x &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;Integer&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt; = 1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&amp;nbsp;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt; ds &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;String&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&amp;nbsp;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt; dp &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#2b91af" face="Consolas" size="2"&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;DesignProject&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt; = &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;Nothing&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&amp;nbsp;Do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;Until&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt; x = Context.Count&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&amp;nbsp; If&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt; Context.Name(x) = &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#a31515" face="Consolas" size="2"&gt;&lt;FONT color="#a31515" face="Consolas" size="2"&gt;&lt;FONT color="#a31515" face="Consolas" size="2"&gt;"ProjectFileName"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;Then&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ds = Context.Item(x)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = x + 1&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&amp;nbsp; End&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;If&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&amp;nbsp;Loop&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&amp;nbsp;For&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;Each&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt; design_project &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt; Inventor.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;DesignProject&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;In&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt; GlobalVars.m_inventorApplication.DesignProjectManager.DesignProjects&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&amp;nbsp; If&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt; design_project.FullFileName = ds &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;Then&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dp = design_project&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&amp;nbsp; End&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;If&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&amp;nbsp;Next&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&amp;nbsp;If&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;Not&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt; (IsNothing(dp)) &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;Then&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&amp;nbsp;&amp;nbsp; Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt; n &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;New&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#2b91af" face="Consolas" size="2"&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;Proj_editor&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;(dp)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n.ShowDialog()&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&amp;nbsp;End&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;If&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;End&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;Sub&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 22:39:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/designproject-return-exception-when-properties-try-change/m-p/5994693#M61026</guid>
      <dc:creator>woodstylee3</dc:creator>
      <dc:date>2016-01-18T22:39:31Z</dc:date>
    </item>
    <item>
      <title>Re: DesignProject return exception when properties try change.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/designproject-return-exception-when-properties-try-change/m-p/5995202#M61038</link>
      <description>&lt;P&gt;The edit always blocked if show Project Dialog&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found in a different place that this limitation of API. The AddiIn of ContentCenter use other path (not AI API).&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2016 10:26:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/designproject-return-exception-when-properties-try-change/m-p/5995202#M61038</guid>
      <dc:creator>mikazakov</dc:creator>
      <dc:date>2016-01-19T10:26:22Z</dc:date>
    </item>
  </channel>
</rss>

