<?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 oDerivedCommandDef.Execute without dialog box in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/oderivedcommanddef-execute-without-dialog-box/m-p/8404954#M91462</link>
    <description>&lt;P&gt;When I use the oDerivedCommandDef.Execute code in my vba how do I get past the dialog box.&amp;nbsp;&amp;nbsp;I would be fine if the dialog box didn't come up at all because I need to do things after the derive.&lt;/P&gt;</description>
    <pubDate>Thu, 15 Nov 2018 19:38:29 GMT</pubDate>
    <dc:creator>shastu</dc:creator>
    <dc:date>2018-11-15T19:38:29Z</dc:date>
    <item>
      <title>oDerivedCommandDef.Execute without dialog box</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/oderivedcommanddef-execute-without-dialog-box/m-p/8404954#M91462</link>
      <description>&lt;P&gt;When I use the oDerivedCommandDef.Execute code in my vba how do I get past the dialog box.&amp;nbsp;&amp;nbsp;I would be fine if the dialog box didn't come up at all because I need to do things after the derive.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 19:38:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/oderivedcommanddef-execute-without-dialog-box/m-p/8404954#M91462</guid>
      <dc:creator>shastu</dc:creator>
      <dc:date>2018-11-15T19:38:29Z</dc:date>
    </item>
    <item>
      <title>Re: oDerivedCommandDef.Execute without dialog box</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/oderivedcommanddef-execute-without-dialog-box/m-p/8404981#M91463</link>
      <description>&lt;P&gt;Which control definition are you executing? "oDerivedCommandDef" is just an instance of a ControlDefinition object that was probably created using something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Dim oDerivedCommandDef As ControlDefinition
oDerivedCommandDef = ThisApplication.CommandManager.ControlDefinitions.Item("&amp;lt;Control Definition Name&amp;gt;")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There's no way to know what you're trying to do from the arbitrary name (in this case "oDerivedCommandDef") that was given to the Control Definition object. So what is the actual &amp;lt;Control Definition Name&amp;gt; in your case?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I ask because I would guess (and hope) that whatever derive operation you're doing could be done directly via the API, rather than by executing a user command.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Most Control Definitions execute some kind of user command which by it nature requires user input to complete, and in some case there's no way to provide those inputs automatically. But there's no way to say without knowing what exactly you're trying to do.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 19:53:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/oderivedcommanddef-execute-without-dialog-box/m-p/8404981#M91463</guid>
      <dc:creator>DRoam</dc:creator>
      <dc:date>2018-11-15T19:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: oDerivedCommandDef.Execute without dialog box</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/oderivedcommanddef-execute-without-dialog-box/m-p/8405052#M91464</link>
      <description>&lt;P&gt;Did some searching and found this thread where someone uses the same "oDerivedCommandDef" definition to execute the "&lt;SPAN&gt;PartDerivedComponentCmd" command. So it looks like you're just trying to derive a component into a Part.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To do this via the command manager, you just need to post a "private event" before executing the command to let Inventor know which file to Derive in. You can do so like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;oFileName = "C:\path\file.ipt"

ThisApplication.CommandManager.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, oFileName)

Dim oDerivedCommandDef As ControlDefinition
oDerivedCommandDef = ThisApplication.CommandManager.ControlDefinitions.Item("PartDerivedComponentCmd")
oDerivedCommandDef.Execute&lt;/PRE&gt;&lt;P&gt;However, this can also be done directly via the API instead, and I would strongly recommend doing so. It's more stable and will give you better control as well. Here's the code for that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;oFileName = "C:\path\file.ipt"

Dim oPartDoc As Inventor.PartDocument = ThisDoc.Document
Dim oPartDef As Inventor.PartComponentDefinition = oPartDoc.ComponentDefinition

Dim oDerivedPartDef As Inventor.DerivedPartUniformScaleDef
oDerivedPartDef = oPartDef.ReferenceComponents.DerivedPartComponents.CreateUniformScaleDef(oFileName)
'See API help for how to set additional options for the DerivedPartUniformScaleDef

Dim oDerivedPartComponent As Inventor.DerivedPartComponent
oDerivedPartComponent = oPartDef.ReferenceComponents.DerivedPartComponents.Add(oDerivedPartDef)
'See API help for how to perform additional edits to the DerivedPartComponent after it's been created&lt;/PRE&gt;&lt;P&gt;Here's a link to the API help for the "DerivedPartUniformScaleDef" object:&amp;nbsp;&lt;A href="http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-1ADC19ED-E539-4CED-ACFB-1BC8EE526385" target="_blank"&gt;Inventor API Help: DerivedPartUniformScaleDef Object&lt;/A&gt;. You can use the methods and properties shown here to have much more control over the Derive operation than using the Command Manager would give you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And here's a link to the API help for the "DerivedPartComponent" object:&amp;nbsp;&lt;A href="http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-16471463-8017-454E-9AB4-B9E9DA541ABF" target="_blank"&gt;Inventor API Help: DerivedPartComponent Object&lt;/A&gt;. You can use the methods and properties shown here to edit the Derive feature even after it's been created.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both ways give you about the same options, but I would guess that editing the "DerivedPartComponent" after-the-fact would allow you to access specific features within the Derived component, while the DerivedPartUniformScaleDef would not, as it doesn't have any details about the specific component yet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 20:30:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/oderivedcommanddef-execute-without-dialog-box/m-p/8405052#M91464</guid>
      <dc:creator>DRoam</dc:creator>
      <dc:date>2018-11-15T20:30:13Z</dc:date>
    </item>
    <item>
      <title>Re: oDerivedCommandDef.Execute without dialog box</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/oderivedcommanddef-execute-without-dialog-box/m-p/8416197#M91617</link>
      <description>&lt;P&gt;Dim oApp As Application&lt;BR /&gt;&amp;nbsp;Dim oCurrentDoc As Document&lt;BR /&gt;&amp;nbsp;Dim oNewDoc As Document&lt;BR /&gt;&amp;nbsp;Dim UseDefaultTemplate As Boolean&lt;BR /&gt;&amp;nbsp;Dim sCurrentFileName As String&lt;BR /&gt;&amp;nbsp;Dim sTemplatePart As String&lt;BR /&gt;&amp;nbsp;Set oApp = ThisApplication&lt;BR /&gt;&amp;nbsp;Set oCurrentDoc = oApp.ActiveDocument&lt;BR /&gt;&amp;nbsp;Select Case oApp.ActiveDocumentType&lt;BR /&gt;&amp;nbsp;Case kAssemblyDocumentObject, kPartDocumentObject&lt;BR /&gt;sCurrentFileName = ThisApplication.ActiveDocument.FullFileName&lt;BR /&gt;If sCurrentFileName = "" Then&lt;BR /&gt;MsgBox "The active file must first be saved"&lt;BR /&gt;Exit Sub&lt;BR /&gt;End If&lt;BR /&gt;'if you want to use the default template then set UseDefaultTemaplte = True&lt;BR /&gt;'if you want to use a custom template set the path and filename of sTemplatePart and UseDefaultTemaplte = False&lt;BR /&gt;UseDefaultTemplate = False&lt;BR /&gt;sTemplatePart = "Q:\Inventor\Templates_v2017\part.ipt"&lt;BR /&gt;Select Case UseDefaultTemplate&lt;BR /&gt;Case True&lt;BR /&gt;Set oNewDoc = oApp.Documents.Add(kPartDocumentObject)&lt;BR /&gt;Case False&lt;BR /&gt;Set oNewDoc = oApp.Documents.Add(kPartDocumentObject, sTemplatePart, True)&lt;BR /&gt;End Select&lt;BR /&gt;&amp;nbsp;'******START UPDATED CODE **************&lt;BR /&gt;&amp;nbsp;'If your template has an active sketch you need to close it.&lt;BR /&gt;Dim oSketch As Sketch&lt;BR /&gt;On Error Resume Next&lt;BR /&gt;Set oSketch = oNewDoc.ComponentDefinition.Sketches.Item(1)&lt;BR /&gt;oSketch.ExitEdit&lt;BR /&gt;On Error GoTo 0&lt;BR /&gt;&amp;nbsp;'******END UPDATED CODE **************&lt;BR /&gt;'Get the control definition that represents the derived part command.&lt;BR /&gt;Dim oDerivedCommandDef As ControlDefinition&lt;BR /&gt;Set oDerivedCommandDef = ThisApplication.CommandManager.ControlDefinitions.Item("PartDerivedComponentCmd")&lt;BR /&gt;'Post the filename to the private event queue.&lt;BR /&gt;Call ThisApplication.CommandManager.PostPrivateEvent(kFileNameEvent, sCurrentFileName)&lt;BR /&gt;'Start the derived part command.&lt;BR /&gt;oDerivedCommandDef.Execute&lt;BR /&gt;&amp;nbsp;Case Else&lt;BR /&gt;MsgBox "You must first have a Part or Assembly document open"&lt;BR /&gt;&amp;nbsp;End Select&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2018 13:05:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/oderivedcommanddef-execute-without-dialog-box/m-p/8416197#M91617</guid>
      <dc:creator>shastu</dc:creator>
      <dc:date>2018-11-21T13:05:17Z</dc:date>
    </item>
  </channel>
</rss>

