public static List <string> ExportSheetmetalPartsToDXF(List <SheetmetalPart> sheetmetalPartList, ExportDXFSettings exportDXFSettings)
        {
            List <string> exportLog = new List <string>();

            string exportString = ExportStringGenerator.GenerateExportString(exportDXFSettings.ImportExportDXFLayers.dXFLayerItems);

            foreach (SheetmetalPart sheetmetalPart in sheetmetalPartList)
            {
                string exportFileName = GenerateExportFileName(sheetmetalPart, exportDXFSettings);

                try
                {
                    SheetMetalComponentDefinition sheetMetalCompDef = (SheetMetalComponentDefinition)sheetmetalPart.PartDocument.ComponentDefinition;

                    DataIO dataIO = sheetMetalCompDef.FlatPattern.DataIO;

                    dataIO.WriteDataToFile(exportString, exportFileName);

                    exportLog.Add(sheetmetalPart.Name + " DXF was successfully exported");

                    EventLogger.CreateLogEntry(sheetmetalPart.Name + " DXF was successfully exported");
                }
                catch (Exception e)
                {
                    exportLog.Add(sheetmetalPart.Name + " DXF export encountered an error");
                    exportLog.Add(e.Message + "   " + e.StackTrace);

                    EventLogger.CreateLogEntry(sheetmetalPart.Name + " DXF export encountered an error");
                    EventLogger.CreateLogEntry(e.Message + "   " + e.StackTrace);

                    continue;
                }
            }
            return(exportLog);
        }
        public bool DetermineDocumentType(ValidDocumentType validDocumentType, UpdateProgressBar updateProgressBar)
        {
            DocumentTypeEnum currentDocumentType;

            try
            {
                currentDocumentType = thisApplication.ActiveDocument.DocumentType;

                if (DocumentInfo.IsAssemblyDocument(currentDocumentType))
                {
                    topLevel.TraverseAssembly((AssemblyDocument)thisApplication.ActiveDocument, 0);
                    validDocumentType(true);
                    return(true);
                }

                else if ((DocumentInfo.IsPartDocument(currentDocumentType)))
                {
                    validDocumentType(false);
                    return(false);
                }

                else
                {
                    validDocumentType(false);
                    return(false);
                }
            }
            catch (Exception e)
            {
                validDocumentType(false);
                updateProgressBar(true);
                EventLogger.CreateLogEntry(e.Message + " " + e.StackTrace);
                return(false);
            }
        }
Exemplo n.º 3
0
 public static void Generate()
 {
     EventLogger.CreateLogEntry("***WELCOME TO DXF EXPORT WIZARD :)***");
     EventLogger.CreateLogEntry("This application will allow you to automatically extract DXFs");
     EventLogger.CreateLogEntry("----------------------------------------------------------------------------------------------------------------------");
     EventLogger.CreateLogEntry("**INSTRUCTIONS**:");
     EventLogger.CreateLogEntry("1. Ensure AutoDesk Inventor is running and an Assembly Document is open");
     EventLogger.CreateLogEntry("2. Click 'Import'");
     EventLogger.CreateLogEntry("3. Select the parts you would like to export to DXF");
     EventLogger.CreateLogEntry("4. Click 'Settings' to change your export preferences");
     EventLogger.CreateLogEntry("5. Click 'Export DXF' to automatically generate and save the DXF files");
     EventLogger.CreateLogEntry("----------------------------------------------------------------------------------------------------------------------");
 }
Exemplo n.º 4
0
 private bool CreateFlatPattern()
 {
     try
     {
         sheetMetalCompDef.Unfold();
         return(true);
     }
     catch (Exception e)
     {
         EventLogger.CreateLogEntry(e.Message + " " + e.StackTrace);
         return(false);
     }
 }
Exemplo n.º 5
0
        //Builds the Assembly, Part and Sheetmetal part objects using recursion
        public void TraverseAssembly(AssemblyDocument currentAsmDocument, int parentID)
        {
            int currentID = GetAssemblyID();

            //to stop instantiating a new instance of Assembly with a null AssemblyDocument - should never happen anyway
            if (currentAsmDocument == null)
            {
                return;
            }

            Assembly assembly = NewAssembly(currentAsmDocument, parentID, currentID);

            EventLogger.CreateLogEntry($"Processing assembly document {assembly.AssemblyDocument.DisplayName}");

            AssemblyList.Add(assembly);

            ComponentOccurrences occurrences = currentAsmDocument.ComponentDefinition.Occurrences;

            noOccurrences += occurrences.Count;
            EventLogger.CreateLogEntry($"Current part count {noOccurrences}");

            foreach (ComponentOccurrence occurrence in occurrences)
            {
                //the UI layer is listening for this Event to increment the progress bar
                IncrementProgressBar();

                if (DocumentInfo.IsPartDocument(occurrence.DefinitionDocumentType))
                {
                    PartDocument partDocument = (PartDocument)occurrence.Definition.Document;
                    EventLogger.CreateLogEntry($"processing part document {partDocument.DisplayName}");

                    if (DocumentInfo.IsSheetMetalPart(partDocument.SubType))
                    {
                        assembly.SheetmetalPartList.Add(NewSheetMetalPart(partDocument));
                    }

                    else
                    {
                        assembly.PartList.Add(NewPart(partDocument));
                    }
                }

                if (DocumentInfo.IsAssemblyDocument(occurrence.DefinitionDocumentType))
                {
                    AssemblyDocument subAssemblyDocument = (AssemblyDocument)occurrence.Definition.Document;

                    TraverseAssembly(subAssemblyDocument, assembly.ID);
                }
            }
        }
        public void GetFlatPatternProperties()
        {
            TotalCuttingLength = FlatPattern.TotalLengthFlatPatternLoops();

            if (TotalCuttingLength == 0)
            {
                EventLogger.CreateLogEntry($"ERROR: creating a flat pattern for {PartDocument.DisplayName}");
                ImportStatus   = "Failed";
                HasFlatPattern = false;
            }
            else
            {
                EventLogger.CreateLogEntry($"SUCCESS: creating a flat pattern for {PartDocument.DisplayName}");
                HasFlatPattern = true;
            }
        }