<?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: Inventor TranslatorAddIn access using python in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-translatoraddin-access-using-python/m-p/11417274#M142610</link>
    <description>This is the tricky one, I don't know how to set this one in python:&lt;BR /&gt;oOptions.Value("Sheet_Range") = kPrintAllSheets&lt;BR /&gt;&lt;BR /&gt;It consider as function and throws an error.</description>
    <pubDate>Tue, 13 Sep 2022 02:36:27 GMT</pubDate>
    <dc:creator>cpadmani95</dc:creator>
    <dc:date>2022-09-13T02:36:27Z</dc:date>
    <item>
      <title>Inventor TranslatorAddIn access using python</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-translatoraddin-access-using-python/m-p/11414854#M142552</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have inventor working properly, and now I want to access TranslatorAddIn Object which is derived from ApplicationAddIn Object. Please let me know what is the best way to do it. End function is to export as PDF from IDW file using python.&lt;/P&gt;&lt;P&gt;VBA is not feasible cause this is the small part on inventor cause I'm doing other PDF work after that using python.&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;win32com.client&lt;BR /&gt;mod = win32com.client.gencache.EnsureModule(&lt;SPAN&gt;'{D98A091D-3A0F-4C3E-B36E-61F62068D488}'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;)&lt;BR /&gt;app = win32com.client.gencache.EnsureDispatch(&lt;SPAN&gt;'Inventor.Application'&lt;/SPAN&gt;)&lt;BR /&gt;app = mod.Application(app)&lt;BR /&gt;app.SilentOperation = &lt;SPAN&gt;True&lt;BR /&gt;&lt;/SPAN&gt;app.Visible = &lt;SPAN&gt;True&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if &lt;/SPAN&gt;app.Ready:&lt;BR /&gt;    &lt;SPAN&gt;print&lt;/SPAN&gt;(&lt;SPAN&gt;"inventor ready"&lt;/SPAN&gt;)&lt;BR /&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;(app.ActiveDocument)&lt;BR /&gt;oDocument = app.ActiveDocument&lt;BR /&gt;PDFAddIn = app.ApplicationAddIns.ItemById(&lt;SPAN&gt;"{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}"&lt;/SPAN&gt;)&lt;BR /&gt;oContext = app.TransientObjects.CreateTranslationContext()&lt;BR /&gt;oContext.Type = &lt;SPAN&gt;13059&lt;BR /&gt;&lt;/SPAN&gt;oOptions = app.TransientObjects.CreateNameValueMap&lt;BR /&gt;oDataMedium = app.TransientObjects.CreateDataMedium&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for &lt;/SPAN&gt;key &lt;SPAN&gt;in &lt;/SPAN&gt;&lt;SPAN&gt;dir&lt;/SPAN&gt;(PDFAddIn):&lt;BR /&gt;    &lt;SPAN&gt;print&lt;/SPAN&gt;(&lt;SPAN&gt;'{}'&lt;/SPAN&gt;.format(key))&lt;BR /&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 04:14:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-translatoraddin-access-using-python/m-p/11414854#M142552</guid>
      <dc:creator>cpadmani95</dc:creator>
      <dc:date>2022-09-12T04:14:51Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor TranslatorAddIn access using python</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-translatoraddin-access-using-python/m-p/11415015#M142555</link>
      <description>&lt;P&gt;I'm not pythonist. But you need to call the same API methods in the same order as described in &lt;A href="https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-0712942A-A330-4779-8AAC-2AD6BCE7245E" target="_blank" rel="noopener"&gt;VBA sample&lt;/A&gt;. Also your variable&amp;nbsp;PDFAddIn can be cast to&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-ED47910B-4849-4FFC-B786-3599ECB67DFD" target="_blank" rel="noopener"&gt;TranslatorAddIn Object&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 06:27:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-translatoraddin-access-using-python/m-p/11415015#M142555</guid>
      <dc:creator>Michael.Navara</dc:creator>
      <dc:date>2022-09-12T06:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor TranslatorAddIn access using python</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-translatoraddin-access-using-python/m-p/11415024#M142556</link>
      <description>&lt;P&gt;At the end of your code should be something like this. Sorry if the syntax is not correct.&lt;/P&gt;&lt;P&gt;Parameters oOptions and oContext is passed by its reference. I don't know how it is declared in python.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;if PDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions):
    # Options for drawings...
    
    oOptions.Value("All_Color_AS_Black") = 0    
    # oOptions.Value("Remove_Line_Weights") = 0
    # oOptions.Value("Vector_Resolution") = 400
    # oOptions.Value("Sheet_Range") = kPrintAllSheets
    # oOptions.Value("Custom_Begin_Sheet") = 2
    # oOptions.Value("Custom_End_Sheet") = 4

# Set the destination file name
oDataMedium.FileName = "c:\temp\test.pdf"

# Publish document.
PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 06:45:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-translatoraddin-access-using-python/m-p/11415024#M142556</guid>
      <dc:creator>Michael.Navara</dc:creator>
      <dc:date>2022-09-12T06:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor TranslatorAddIn access using python</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-translatoraddin-access-using-python/m-p/11417270#M142609</link>
      <description>I was able to see all the object inside once I did Cast.&lt;BR /&gt;PDFAddIn = app.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")&lt;BR /&gt;PDFAddIn = win32com.client.CastTo(PDFAddIn, "TranslatorAddIn")&lt;BR /&gt;oContext = app.TransientObjects.CreateTranslationContext()&lt;BR /&gt;oContext = win32com.client.CastTo(oContext, "TranslationContext")&lt;BR /&gt;oContext.Type = 13059&lt;BR /&gt;oOptions = app.TransientObjects.CreateNameValueMap()&lt;BR /&gt;oOptions = win32com.client.CastTo(oOptions, "NameValueMap")&lt;BR /&gt;oDataMedium = app.TransientObjects.CreateDataMedium()&lt;BR /&gt;oDataMedium = win32com.client.CastTo(oDataMedium, "DataMedium")</description>
      <pubDate>Tue, 13 Sep 2022 02:34:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-translatoraddin-access-using-python/m-p/11417270#M142609</guid>
      <dc:creator>cpadmani95</dc:creator>
      <dc:date>2022-09-13T02:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor TranslatorAddIn access using python</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-translatoraddin-access-using-python/m-p/11417274#M142610</link>
      <description>This is the tricky one, I don't know how to set this one in python:&lt;BR /&gt;oOptions.Value("Sheet_Range") = kPrintAllSheets&lt;BR /&gt;&lt;BR /&gt;It consider as function and throws an error.</description>
      <pubDate>Tue, 13 Sep 2022 02:36:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-translatoraddin-access-using-python/m-p/11417274#M142610</guid>
      <dc:creator>cpadmani95</dc:creator>
      <dc:date>2022-09-13T02:36:27Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor TranslatorAddIn access using python</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-translatoraddin-access-using-python/m-p/11420048#M142644</link>
      <description>&lt;P&gt;This is just &lt;A href="https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-2276DA58-9EB9-4A40-AD9D-FC136E4A7543" target="_blank" rel="noopener"&gt;PrintRangeEnum&lt;/A&gt; value. You can use one of the possible values as integer.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 07:29:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-translatoraddin-access-using-python/m-p/11420048#M142644</guid>
      <dc:creator>Michael.Navara</dc:creator>
      <dc:date>2022-09-14T07:29:46Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor TranslatorAddIn access using python</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-translatoraddin-access-using-python/m-p/11422486#M142693</link>
      <description>&lt;P&gt;After searching for a while I get the idea from one of the blog about how to get oOptions NamevaluMap object to work.&lt;/P&gt;&lt;P&gt;Basically in python it won't let you do like VBA:&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;SPAN&gt;oOptions.Value("Sheet_Range") = kPrintAllSheets&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Instead you have to write like this:&lt;/P&gt;&lt;PRE&gt;oOptions.Remove(oCount)&lt;BR /&gt;oOptions.Insert(&lt;SPAN&gt;"Sheet_Range"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;14082&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;where oCount has to be the index number of Sheet_range that hold inside the NamevalueMap.&lt;/P&gt;&lt;P&gt;In python first you have to remove it, cause it hold the default value then Insert it with new value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the full working function code in python:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;win32com.client&lt;BR /&gt;mod = win32com.client.gencache.EnsureModule(&lt;SPAN&gt;'{D98A091D-3A0F-4C3E-B36E-61F62068D488}'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;)&lt;BR /&gt;app = win32com.client.gencache.EnsureDispatch(&lt;SPAN&gt;'Inventor.Application'&lt;/SPAN&gt;)&lt;BR /&gt;app = mod.Application(app)&lt;BR /&gt;&lt;BR /&gt;inputfile=&lt;SPAN&gt;"C:/Users/adm/Desktop/Cad/Assembly1.idw"&lt;BR /&gt;&lt;/SPAN&gt;exportfile= inputfile[:-&lt;SPAN&gt;3&lt;/SPAN&gt;] +&lt;SPAN&gt;"pdf"&lt;BR /&gt;&lt;/SPAN&gt;app.Documents.Open(inputfile)&lt;BR /&gt;app.SilentOperation = &lt;SPAN&gt;True&lt;BR /&gt;&lt;/SPAN&gt;app.Visible = &lt;SPAN&gt;True&lt;BR /&gt;&lt;/SPAN&gt;oDocument = app.ActiveDocument&lt;BR /&gt;&lt;BR /&gt;PDFAddIn = app.ApplicationAddIns.ItemById(&lt;SPAN&gt;"{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}"&lt;/SPAN&gt;)&lt;BR /&gt;PDFAddIn = win32com.client.CastTo(PDFAddIn&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"TranslatorAddIn"&lt;/SPAN&gt;)&lt;BR /&gt;oContext = app.TransientObjects.CreateTranslationContext()&lt;BR /&gt;oContext = win32com.client.CastTo(oContext&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"TranslationContext"&lt;/SPAN&gt;)&lt;BR /&gt;oContext.Type = &lt;SPAN&gt;13059&lt;BR /&gt;&lt;/SPAN&gt;oOptions = app.TransientObjects.CreateNameValueMap()&lt;BR /&gt;oOptions = win32com.client.CastTo(oOptions&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"NameValueMap"&lt;/SPAN&gt;)&lt;BR /&gt;oDataMedium = app.TransientObjects.CreateDataMedium()&lt;BR /&gt;oDataMedium = win32com.client.CastTo(oDataMedium&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"DataMedium"&lt;/SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;if &lt;/SPAN&gt;PDFAddIn.HasSaveCopyAsOptions(oDocument&lt;SPAN&gt;, &lt;/SPAN&gt;oContext&lt;SPAN&gt;, &lt;/SPAN&gt;oOptions):&lt;BR /&gt;    &lt;SPAN&gt;for &lt;/SPAN&gt;i &lt;SPAN&gt;in &lt;/SPAN&gt;&lt;SPAN&gt;range&lt;/SPAN&gt;(&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;oOptions.Count):&lt;BR /&gt;        &lt;SPAN&gt;if &lt;/SPAN&gt;oOptions.Name(i) == &lt;SPAN&gt;"Sheet_Range"&lt;/SPAN&gt;:&lt;BR /&gt;            oCount = i&lt;BR /&gt;            oOptions.Remove(oCount)&lt;BR /&gt;            oOptions.Insert(&lt;SPAN&gt;"Sheet_Range"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;14082&lt;/SPAN&gt;)&lt;BR /&gt;            oDataMedium.FileName = exportfile&lt;BR /&gt;            PDFAddIn.SaveCopyAs(oDocument&lt;SPAN&gt;, &lt;/SPAN&gt;oContext&lt;SPAN&gt;, &lt;/SPAN&gt;oOptions&lt;SPAN&gt;, &lt;/SPAN&gt;oDataMedium)&lt;BR /&gt;&lt;BR /&gt;oDocument.Close(&lt;SPAN&gt;SkipSave&lt;/SPAN&gt;=&lt;SPAN&gt;True&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 03:15:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-translatoraddin-access-using-python/m-p/11422486#M142693</guid>
      <dc:creator>cpadmani95</dc:creator>
      <dc:date>2022-09-15T03:15:57Z</dc:date>
    </item>
  </channel>
</rss>

