Save drawing pdf in same directory as DXF files.

This commit is contained in:
AJ
2022-06-23 12:44:44 -04:00
parent a0080c8a68
commit 979067db21
2 changed files with 37 additions and 20 deletions

View File

@@ -13,7 +13,7 @@
<FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<TargetFrameworkProfile />
<PublishUrl>\\REMCOSRV1\Data\Software\ExportDXF\</PublishUrl>
<PublishUrl>\\REMCOSRV0\Data\Software\ExportDXF\</PublishUrl>
<Install>true</Install>
<InstallFrom>Unc</InstallFrom>
<UpdateEnabled>true</UpdateEnabled>
@@ -24,8 +24,10 @@
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<PublisherName>Rogers Engineering</PublisherName>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>1.3.0.%2a</ApplicationVersion>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.htm</WebPage>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationVersion>1.5.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>

View File

@@ -236,14 +236,13 @@ namespace ExportDXF.Forms
}
}
private string GetPdfSavePath(DrawingDoc drawingDoc)
private string GetPdfFileName(DrawingDoc drawingDoc)
{
var model = drawingDoc as ModelDoc2;
var pdfPath = model.GetPathName();
var ext = Path.GetExtension(pdfPath);
pdfPath = pdfPath.Remove(pdfPath.Length - ext.Length) + ".pdf";
var modelFilePath = model.GetPathName();
var pdfFileName = Path.GetFileNameWithoutExtension(modelFilePath) + ".pdf";
return pdfPath;
return pdfFileName;
}
private void ExportDrawingToPDF(DrawingDoc drawingDoc, string savePath)
@@ -293,10 +292,19 @@ namespace ExportDXF.Forms
Print($"Found {items.Count} component(s)");
var savePath = GetPdfSavePath(drawing);
var saveDirectory = UserSelectFolder();
ExportDrawingToPDF(drawing, savePath);
ExportToDXF(items);
if (saveDirectory == null)
{
Print("Canceled\n", Color.Red);
return;
}
var pdfName = GetPdfFileName(drawing);
var pdfPath = Path.Combine(saveDirectory, pdfName);
ExportDrawingToPDF(drawing, pdfPath);
ExportToDXF(items, saveDirectory);
}
private List<Item> GetItems(BomTableAnnotation bom)
@@ -355,20 +363,27 @@ namespace ExportDXF.Forms
var items = itemExtractor.GetItems();
Print($"Found {items.Count} item(s).\n");
ExportToDXF(items);
}
private void ExportToDXF(IEnumerable<Item> items)
{
var savePath = UserSelectFolder();
var prefix = prefixTextBox.Text;
var saveDirectory = UserSelectFolder();
if (savePath == null)
if (saveDirectory == null)
{
Print("Canceled\n", Color.Red);
return;
}
ExportToDXF(items, saveDirectory);
}
/// <summary>
///
/// </summary>
/// <param name="items"></param>
/// <param name="saveDirectory">Directory to save the DXF file in.</param>
private void ExportToDXF(IEnumerable<Item> items, string saveDirectory)
{
var prefix = prefixTextBox.Text;
templateDrawing = CreateDrawing();
Print("");
@@ -382,7 +397,7 @@ namespace ExportDXF.Forms
continue;
var fileName = GetFileName(item);
var savepath = Path.Combine(savePath, fileName + ".dxf");
var savepath = Path.Combine(saveDirectory, fileName + ".dxf");
item.Component.SetLightweightToResolved();
@@ -449,7 +464,7 @@ namespace ExportDXF.Forms
{
var drawingInfo = DrawingInfo.Parse(prefix);
var bomName = drawingInfo != null ? $"{drawingInfo.JobNo} {drawingInfo.DrawingNo} BOM" : "BOM";
var bomFile = Path.Combine(savePath, bomName + ".xlsx");
var bomFile = Path.Combine(saveDirectory, bomName + ".xlsx");
var excelReport = new BomToExcel();
excelReport.CreateBOMExcelFile(bomFile, items.ToList());