- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Did some searching and found this thread where someone uses the same "oDerivedCommandDef" definition to execute the "PartDerivedComponentCmd" command. So it looks like you're just trying to derive a component into a Part.
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:
oFileName = "C:\path\file.ipt"
ThisApplication.CommandManager.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, oFileName)
Dim oDerivedCommandDef As ControlDefinition
oDerivedCommandDef = ThisApplication.CommandManager.ControlDefinitions.Item("PartDerivedComponentCmd")
oDerivedCommandDef.ExecuteHowever, 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:
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
Here's a link to the API help for the "DerivedPartUniformScaleDef" object: Inventor API Help: DerivedPartUniformScaleDef Object. 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.
And here's a link to the API help for the "DerivedPartComponent" object: Inventor API Help: DerivedPartComponent Object. You can use the methods and properties shown here to edit the Derive feature even after it's been created.
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.
Hope this helps.