Save drawing pdf in same directory as DXF files.
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
<TargetFrameworkProfile />
|
<TargetFrameworkProfile />
|
||||||
<PublishUrl>\\REMCOSRV1\Data\Software\ExportDXF\</PublishUrl>
|
<PublishUrl>\\REMCOSRV0\Data\Software\ExportDXF\</PublishUrl>
|
||||||
<Install>true</Install>
|
<Install>true</Install>
|
||||||
<InstallFrom>Unc</InstallFrom>
|
<InstallFrom>Unc</InstallFrom>
|
||||||
<UpdateEnabled>true</UpdateEnabled>
|
<UpdateEnabled>true</UpdateEnabled>
|
||||||
@@ -24,8 +24,10 @@
|
|||||||
<UpdateRequired>false</UpdateRequired>
|
<UpdateRequired>false</UpdateRequired>
|
||||||
<MapFileExtensions>true</MapFileExtensions>
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
<PublisherName>Rogers Engineering</PublisherName>
|
<PublisherName>Rogers Engineering</PublisherName>
|
||||||
<ApplicationRevision>1</ApplicationRevision>
|
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
|
||||||
<ApplicationVersion>1.3.0.%2a</ApplicationVersion>
|
<WebPage>publish.htm</WebPage>
|
||||||
|
<ApplicationRevision>2</ApplicationRevision>
|
||||||
|
<ApplicationVersion>1.5.0.%2a</ApplicationVersion>
|
||||||
<UseApplicationTrust>false</UseApplicationTrust>
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
<PublishWizardCompleted>true</PublishWizardCompleted>
|
<PublishWizardCompleted>true</PublishWizardCompleted>
|
||||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
|
|||||||
@@ -236,14 +236,13 @@ namespace ExportDXF.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetPdfSavePath(DrawingDoc drawingDoc)
|
private string GetPdfFileName(DrawingDoc drawingDoc)
|
||||||
{
|
{
|
||||||
var model = drawingDoc as ModelDoc2;
|
var model = drawingDoc as ModelDoc2;
|
||||||
var pdfPath = model.GetPathName();
|
var modelFilePath = model.GetPathName();
|
||||||
var ext = Path.GetExtension(pdfPath);
|
var pdfFileName = Path.GetFileNameWithoutExtension(modelFilePath) + ".pdf";
|
||||||
pdfPath = pdfPath.Remove(pdfPath.Length - ext.Length) + ".pdf";
|
|
||||||
|
|
||||||
return pdfPath;
|
return pdfFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExportDrawingToPDF(DrawingDoc drawingDoc, string savePath)
|
private void ExportDrawingToPDF(DrawingDoc drawingDoc, string savePath)
|
||||||
@@ -293,10 +292,19 @@ namespace ExportDXF.Forms
|
|||||||
|
|
||||||
Print($"Found {items.Count} component(s)");
|
Print($"Found {items.Count} component(s)");
|
||||||
|
|
||||||
var savePath = GetPdfSavePath(drawing);
|
var saveDirectory = UserSelectFolder();
|
||||||
|
|
||||||
ExportDrawingToPDF(drawing, savePath);
|
if (saveDirectory == null)
|
||||||
ExportToDXF(items);
|
{
|
||||||
|
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)
|
private List<Item> GetItems(BomTableAnnotation bom)
|
||||||
@@ -355,20 +363,27 @@ namespace ExportDXF.Forms
|
|||||||
var items = itemExtractor.GetItems();
|
var items = itemExtractor.GetItems();
|
||||||
|
|
||||||
Print($"Found {items.Count} item(s).\n");
|
Print($"Found {items.Count} item(s).\n");
|
||||||
ExportToDXF(items);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ExportToDXF(IEnumerable<Item> items)
|
var saveDirectory = UserSelectFolder();
|
||||||
{
|
|
||||||
var savePath = UserSelectFolder();
|
|
||||||
var prefix = prefixTextBox.Text;
|
|
||||||
|
|
||||||
if (savePath == null)
|
if (saveDirectory == null)
|
||||||
{
|
{
|
||||||
Print("Canceled\n", Color.Red);
|
Print("Canceled\n", Color.Red);
|
||||||
return;
|
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();
|
templateDrawing = CreateDrawing();
|
||||||
|
|
||||||
Print("");
|
Print("");
|
||||||
@@ -382,7 +397,7 @@ namespace ExportDXF.Forms
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
var fileName = GetFileName(item);
|
var fileName = GetFileName(item);
|
||||||
var savepath = Path.Combine(savePath, fileName + ".dxf");
|
var savepath = Path.Combine(saveDirectory, fileName + ".dxf");
|
||||||
|
|
||||||
item.Component.SetLightweightToResolved();
|
item.Component.SetLightweightToResolved();
|
||||||
|
|
||||||
@@ -449,7 +464,7 @@ namespace ExportDXF.Forms
|
|||||||
{
|
{
|
||||||
var drawingInfo = DrawingInfo.Parse(prefix);
|
var drawingInfo = DrawingInfo.Parse(prefix);
|
||||||
var bomName = drawingInfo != null ? $"{drawingInfo.JobNo} {drawingInfo.DrawingNo} BOM" : "BOM";
|
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();
|
var excelReport = new BomToExcel();
|
||||||
excelReport.CreateBOMExcelFile(bomFile, items.ToList());
|
excelReport.CreateBOMExcelFile(bomFile, items.ToList());
|
||||||
|
|||||||
Reference in New Issue
Block a user