- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Forum,
I have been trying to make a plugin for my web application in C# that simplifies an assembly into a part then exports it as .stp. So far, I have been able to do the .stp stuff just fine.
However, the simplification part is eluding me. I have been using Inventor 2025 Help | Derived Parts and Assemblies | Autodesk as a reference, but cannot add the uniformDef as a derived part as the input is an assembly. The following is the top part of my ExportSTP method, before the working STP logic:
public void ExportSTP(Document doc)
{
var inventorApp = _inventorApplication;
var startDir = System.IO.Directory.GetCurrentDirectory();
var fileName = System.IO.Path.Combine(startDir, "Output.stp");
PartDocument derivedPartDoc = null;
try
{
if (doc.DocumentType == DocumentTypeEnum.kAssemblyDocumentObject)
{
LogTrace($"Attempt to create derived part from assembly {doc.File.FullFileName}");
var tempPartPath = System.IO.Path.Combine(startDir, "DerivedPart.ipt");
derivedPartDoc = (PartDocument)inventorApp.Documents.Add(DocumentTypeEnum.kPartDocumentObject, inventorApp.FileManager.GetTemplateFile(DocumentTypeEnum.kPartDocumentObject), true);
// create uniform scale definition
var uniformDef = derivedPartDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.CreateUniformScaleDef(doc.FullFileName);
uniformDef.ScaleFactor = 1.0;
// cast type for DerivedPartComponents.Add()
DerivedPartDefinition derivedDef = (DerivedPartDefinition)uniformDef;
derivedPartDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Add(derivedDef);
derivedPartDoc.SaveAs(tempPartPath, false);
LogTrace($"Successfully created derived part {derivedPartDoc.DisplayName}");
}
}
catch (Exception ex)
{
LogError($"Failed to derive part: {ex.Message}");
return;
}It doesn't necessarily have to be a derived part - just as long as there is no way to split the .stp output back into assembly components. With just my .stp logic, I have been able to download an assembly as .stp then open it in Inventor and get all the components back, which is what I need to prevent.
The target workflow for the above snippet is: Input .iam -> simplify to .ipt -> convert and export .stp
Any help on reaching my goal would be greatly appreciated, thank you!
Solved! Go to Solution.