feat: publish app bundle test

This commit is contained in:
2025-06-11 16:51:33 +02:00
parent 5a9085b0be
commit af408b44aa
2 changed files with 53 additions and 31 deletions

View File

@ -65,8 +65,8 @@ namespace DebugPluginLocally
// create a copy // create a copy
System.IO.File.Copy(boxPath, boxPathCopy); System.IO.File.Copy(boxPath, boxPathCopy);
// open box.ipt by Inventor // open boxcopy.ipt by Inventor
Document doc = app.Documents.Open(boxPathCopy); Document doc = app.Documents.Open(boxPathCopy);;
// get params.json absolute path // get params.json absolute path
string paramsPath = System.IO.Path.Combine(projectdir, @"inputFiles\", "params.json"); string paramsPath = System.IO.Path.Combine(projectdir, @"inputFiles\", "params.json");
@ -78,10 +78,8 @@ namespace DebugPluginLocally
map.Add("_1", paramsPath); map.Add("_1", paramsPath);
// add extra parameters to showcase newly supported parsing and new helper class NameValueMapHelper // add extra parameters to showcase newly supported parsing and new helper class NameValueMapHelper
map.Add("intIndex", "1"); map.Add("height", "5.0");
map.Add("stringIndex", "test"); map.Add("width", "10.0");
map.Add("stringCollectionIndex", "str1, str2, str3");
map.Add("intCollectionIndex", "34, 256, 9999, 500, 43");
// create an instance of MachinePlannerExportPlugin // create an instance of MachinePlannerExportPlugin

View File

@ -17,10 +17,8 @@
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Autodesk.Forge.DesignAutomation.Inventor.Utils;
using Autodesk.Forge.DesignAutomation.Inventor.Utils.Helpers; using Autodesk.Forge.DesignAutomation.Inventor.Utils.Helpers;
using Inventor; using Inventor;
@ -47,37 +45,63 @@ namespace MachinePlannerExportPlugin
try try
{ {
// Using NameValueMapExtension // Parameter aus der Config lesen
if (map.HasKey("intIndex")) double height = 1.0;
if (map.HasKey("height"))
{ {
int intValue = map.AsInt("intIndex"); height = map.AsDouble("height");
LogTrace($"Value of intIndex is: {intValue}");
} }
if (map.HasKey("stringCollectionIndex")) double width = 1.0;
if (map.HasKey("width"))
{ {
IEnumerable<string> strCollection = map.AsStringCollection("stringCollectionIndex"); width = map.AsDouble("width");
foreach (string strValue in strCollection)
{
LogTrace($"String value is: {strValue}");
}
} }
if (doc.DocumentType == DocumentTypeEnum.kPartDocumentObject) string name = "Box";
if (map.HasKey("name"))
{ {
using (new HeartBeat()) name = map.AsString("name");
{
// TODO: handle the Inventor part here
}
}
else if (doc.DocumentType == DocumentTypeEnum.kAssemblyDocumentObject) // Assembly.
{
using (new HeartBeat())
{
// TODO: handle the Inventor assembly here
}
} }
// Neues Part-Dokument anlegen
PartDocument partDoc = (PartDocument)inventorApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject,
inventorApplication.FileManager.GetTemplateFile(DocumentTypeEnum.kPartDocumentObject), true);
PartComponentDefinition compDef = partDoc.ComponentDefinition;
compDef.Document.Name = name; // Set the document name
// 2D-Skizze auf XY-Ebene anlegen
PlanarSketch sketch = compDef.Sketches.Add(compDef.WorkPlanes[3]); // 3 = XY Plane
// Rechteck zeichnen
sketch.SketchLines.AddAsTwoPointRectangle(
inventorApplication.TransientGeometry.CreatePoint2d(0, 0),
inventorApplication.TransientGeometry.CreatePoint2d(width, height)
);
// Rechteck extrudieren (Würfel)
Profile profile = sketch.Profiles.AddForSolid();
ExtrudeDefinition extrudeDef = compDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(
profile, PartFeatureOperationEnum.kJoinOperation);
extrudeDef.SetDistanceExtent(width, PartFeatureExtentDirectionEnum.kPositiveExtentDirection);
ExtrudeFeature boxFeature = compDef.Features.ExtrudeFeatures.Add(extrudeDef);
// Speicherort für das temporäre IPT
string tempDir = System.IO.Path.GetTempPath();
string partPath = System.IO.Path.Combine(tempDir, "CubeExport.ipt");
partDoc.SaveAs(partPath, false);
// Jetzt ist FullFileName gesetzt und du kannst das Verzeichnis verwenden
string stepPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(partDoc.FullFileName), "CubeExport.step");
// STEP-Export
partDoc.SaveAs(stepPath, true); // true für STEP-Export, wenn als .step angegeben
// Optional: Log-Ausgabe
LogTrace($"Würfel mit Breite={width} und Höhe={height} und Text '{name}' als STEP exportiert: {stepPath}");
} }
catch (Exception e) catch (Exception e)
{ {