// This Gist contains examples of Aspose.CAD for .NET
Last active
November 1, 2024 19:41
-
-
Save aspose-com-gists/88cdd0899132edaf0afff77d33d11ae5 to your computer and use it in GitHub Desktop.
Aspose.CAD for .NET
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load CF2 in an instance of Image via its Load method | |
using (var image = Aspose.CAD.Image.Load("template.cf2")) | |
{ | |
// create an instance of CadRasterizationOptions and set page height & width | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
{ | |
PageWidth = 1600, | |
PageHeight = 1600 | |
}; | |
// create an instance of TiffOptions | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// export CF2 to TIFF | |
image.Save("output.tiff", options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load DGN in an instance of Image via its Load method | |
using (var image = Aspose.CAD.Image.Load("template.dgn")) | |
{ | |
// create an instance of CadRasterizationOptions and set page height & width | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
{ | |
PageWidth = 1600, | |
PageHeight = 1600 | |
}; | |
// create an instance of TiffOptions | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// export DGN to TIFF | |
image.Save("output.tiff", options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string output = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".tiff"; | |
// load DWF file in an instance of Image | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load("template.dwf")) | |
{ | |
// create an instance of CadRasterizationOptions | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1200; | |
rasterizationOptions.PageHeight = 1200; | |
// create an instance of TiffOptions for the resultant image | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set VectorRasterizationOptions property | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// save DWF as TIFF image | |
image.Save(output, options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load DWFX in an instance of Image via its Load method | |
using (var image = Aspose.CAD.Image.Load("template.dwfx")) | |
{ | |
// create an instance of CadRasterizationOptions and set page height & width | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
{ | |
PageWidth = 1600, | |
PageHeight = 1600 | |
}; | |
// create an instance of TiffOptions | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// export DWFX to TIFF | |
image.Save("output.tiff", options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string output = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".tiff"; | |
// load DWG file in an instance of Image | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load("template.dwg")) | |
{ | |
// create an instance of CadRasterizationOptions | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1200; | |
rasterizationOptions.PageHeight = 1200; | |
// create an instance of TiffOptions for the resultant image | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set VectorRasterizationOptions property | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// save DWG as TIFF image | |
image.Save(output, options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load DWT in an instance of Image via its Load method | |
using (var image = Aspose.CAD.Image.Load("template.dwt")) | |
{ | |
// create an instance of CadRasterizationOptions and set page height & width | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
{ | |
PageWidth = 1600, | |
PageHeight = 1600 | |
}; | |
// create an instance of TiffOptions | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// export DWT to TIFF | |
image.Save("output.tiff", options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string output = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".tiff"; | |
// load DXF file in an instance of Image | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load("template.dxf")) | |
{ | |
// create an instance of CadRasterizationOptions | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1200; | |
rasterizationOptions.PageHeight = 1200; | |
// create an instance of TiffOptions for the resultant image | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set VectorRasterizationOptions property | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// save DXF as TIFF image | |
image.Save(output, options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load FBX in an instance of Image via its Load method | |
using (var image = Aspose.CAD.Image.Load("template.fbx")) | |
{ | |
// create an instance of CadRasterizationOptions and set page height & width | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
{ | |
PageWidth = 1600, | |
PageHeight = 1600 | |
}; | |
// create an instance of TiffOptions | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// export FBX to TIFF | |
image.Save("output.tiff", options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string output = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".tiff"; | |
// load IFC file in an instance of Image | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load("template.ifc")) | |
{ | |
// create an instance of CadRasterizationOptions | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1200; | |
rasterizationOptions.PageHeight = 1200; | |
// create an instance of TiffOptions for the resultant image | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set VectorRasterizationOptions property | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// save IFC as TIFF image | |
image.Save(output, options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load IGEC in an instance of Image via its Load method | |
using (var image = Aspose.CAD.Image.Load("template.iges")) | |
{ | |
// create an instance of CadRasterizationOptions and set page height & width | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
{ | |
PageWidth = 1600, | |
PageHeight = 1600 | |
}; | |
// create an instance of TiffOptions | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// export IGES to TIFF | |
image.Save("output.tiff", options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load OBJ in an instance of Image via its Load method | |
using (var image = Aspose.CAD.Image.Load("template.obj")) | |
{ | |
// create an instance of CadRasterizationOptions and set page height & width | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
{ | |
PageWidth = 1600, | |
PageHeight = 1600 | |
}; | |
// create an instance of TiffOptions | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// export OBJ to TIFF | |
image.Save("output.tiff", options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load PLT in an instance of Image via its Load method | |
using (var image = Aspose.CAD.Image.Load("template.plt")) | |
{ | |
// create an instance of CadRasterizationOptions and set page height & width | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
{ | |
PageWidth = 1600, | |
PageHeight = 1600 | |
}; | |
// create an instance of TiffOptions | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// export PLT to TIFF | |
image.Save("output.tiff", options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string output = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".tiff"; | |
// load STL file in an instance of Image | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load("template.stl")) | |
{ | |
// create an instance of CadRasterizationOptions | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1200; | |
rasterizationOptions.PageHeight = 1200; | |
// create an instance of TiffOptions for the resultant image | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set VectorRasterizationOptions property | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// save STL as TIFF image | |
image.Save(output, options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load SVG in an instance of Image via its Load method | |
using (var image = Aspose.CAD.Image.Load("template.svg")) | |
{ | |
// create an instance of CadRasterizationOptions and set page height & width | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
{ | |
PageWidth = 1600, | |
PageHeight = 1600 | |
}; | |
// create an instance of TiffOptions | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// export SVG to TIFF | |
image.Save("output.tiff", options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string output = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".tiff"; | |
// load DGN file in an instance of Image | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load("template.dgn")) | |
{ | |
// create an instance of CadRasterizationOptions | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1200; | |
rasterizationOptions.PageHeight = 1200; | |
// create an instance of TiffOptions for the resultant image | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set VectorRasterizationOptions property | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// save DGN as TIFF image | |
image.Save(output, options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Gist for Aspose.CAD for .NET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string inputFileName = "robot_handling_cell.dxf"; | |
string watermarkFileName = "Clock-Icon.png"; | |
string embeddedFileName = "robot_handling_cell_embedded.dxf"; | |
// Watermark data | |
var watermarkStream = new MemoryStream(File.ReadAllBytes(watermarkFileName)); | |
// Embed | |
var inputImage = Image.Load(inputFileName); | |
bool embedSuccess = inputImage.WatermarkGuardService.EmbedImage(watermarkStream); | |
inputImage.Save(embeddedFileName, new DxfOptions()); | |
// Validate | |
var embeddedImage = Image.Load(embeddedFileName); | |
bool validateSuccess = embeddedImage.WatermarkGuardService.ValidateImage(watermarkStream); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Text embedding and validation | |
string inputFileName = "Tyrannosaurus.dxf"; | |
string embeddedFileName = "Tyrannosaurus_embedded.dxf"; | |
// Watermark data | |
string watermarkText = "The grass grows and the orioles fly"; | |
// Embed | |
var inputImage = Image.Load(inputFileName); | |
bool embedSuccess = inputImage.WatermarkGuardService.EmbedText(watermarkText); | |
inputImage.Save(embeddedFileName, new DxfOptions()); | |
// Validate | |
var embeddedImage = Image.Load(embeddedFileName); | |
bool validateSuccess = embeddedImage.WatermarkGuardService.ValidateText(watermarkText); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool currentUnitIsMetric = false; | |
double currentUnitCoefficient = 1.0; | |
DefineUnitSystem(cadImage.UnitType, out currentUnitIsMetric, out currentUnitCoefficient); | |
if (currentUnitIsMetric) | |
{ | |
double metersCoeff = 1 / 1000.0; | |
double scaleFactor = metersCoeff / currentUnitCoefficient; | |
rasterizationOptions.PageWidth = (float)(210 * scaleFactor); | |
rasterizationOptions.PageHeight = (float)(297 * scaleFactor); | |
rasterizationOptions.UnitType = UnitType.Millimeter; | |
} | |
else | |
{ | |
rasterizationOptions.PageWidth = (float)(8.27f / currentUnitCoefficient); | |
rasterizationOptions.PageHeight = (float)(11.69f / currentUnitCoefficient); | |
rasterizationOptions.UnitType = UnitType.Inch; | |
} | |
private static void DefineUnitSystem(UnitType unitType, out bool isMetric, out double coefficient) | |
{ | |
isMetric = false; | |
coefficient = 1.0; | |
switch (unitType) | |
{ | |
case UnitType.Parsec: | |
coefficient = 3.0857 * 10000000000000000.0; | |
isMetric = true; | |
break; | |
case UnitType.LightYear: | |
coefficient = 9.4607 * 1000000000000000.0; | |
isMetric = true; | |
break; | |
case UnitType.AstronomicalUnit: | |
coefficient = 1.4960 * 100000000000.0; | |
isMetric = true; | |
break; | |
case UnitType.Gigameter: | |
coefficient = 1000000000.0; | |
isMetric = true; | |
break; | |
case UnitType.Kilometer: | |
coefficient = 1000.0; | |
isMetric = true; | |
break; | |
case UnitType.Decameter: | |
isMetric = true; | |
coefficient = 10.0; | |
break; | |
case UnitType.Hectometer: | |
isMetric = true; | |
coefficient = 100.0; | |
break; | |
case UnitType.Meter: | |
isMetric = true; | |
coefficient = 1.0; | |
break; | |
case UnitType.Centimenter: | |
isMetric = true; | |
coefficient = 0.01; | |
break; | |
case UnitType.Decimeter: | |
isMetric = true; | |
coefficient = 0.1; | |
break; | |
case UnitType.Millimeter: | |
isMetric = true; | |
coefficient = 0.001; | |
break; | |
case UnitType.Micrometer: | |
isMetric = true; | |
coefficient = 0.000001; | |
break; | |
case UnitType.Nanometer: | |
isMetric = true; | |
coefficient = 0.000000001; | |
break; | |
case UnitType.Angstrom: | |
isMetric = true; | |
coefficient = 0.0000000001; | |
break; | |
case UnitType.Inch: | |
coefficient = 1.0; | |
break; | |
case UnitType.MicroInch: | |
coefficient = 0.000001; | |
break; | |
case UnitType.Mil: | |
coefficient = 0.001; | |
break; | |
case UnitType.Foot: | |
coefficient = 12.0; | |
break; | |
case UnitType.Yard: | |
coefficient = 36.0; | |
break; | |
case UnitType.Mile: | |
coefficient = 63360.0; | |
break; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set path of the license file, i.e. c:\temp\ | |
string dataDir = @"c:\temp\"; | |
License license = new License(); | |
license.SetLicense(dataDir + "Aspose.CAD.lic"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set path of the license file, i.e. c:\temp\ | |
string dataDir = @"c:\temp\"; | |
// Load an existing file in the stream | |
FileStream LicStream = new FileStream(dataDir + "Aspose.CAD.lic", FileMode.Open); | |
License license = new License(); | |
license.SetLicense(LicStream); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-.NET | |
// Access the setMeteredKey property and pass public and private keys as parameters | |
Aspose.CAD.Metered.SetMeteredKey("PublicKey", "PrivateKey"); | |
// Get metered data amount before calling API | |
decimal amountbefore = Aspose.CAD.Metered.GetConsumptionQuantity(); | |
// Display information | |
Console.WriteLine("Amount Consumed Before: " + amountbefore.ToString()); | |
// Do processing | |
//Aspose.CAD.FileFormats.Cad.CadImage image = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.load("BlockRefDgn.dwg"); | |
// Get metered data amount After calling API | |
decimal amountafter = Aspose.CAD.Metered.GetConsumptionQuantity(); | |
// Display information | |
Console.WriteLine("Amount Consumed After: " + amountafter.ToString()); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Access the setMeteredKey property and pass public and private keys as parameters | |
Aspose.CAD.Metered.SetMeteredKey("PublicKey", "PrivateKey"); | |
// Get metered data amount before calling API | |
decimal amountbefore = Aspose.CAD.Metered.GetConsumptionQuantity(); | |
// Display information | |
Console.WriteLine("Amount Consumed Before: " + amountbefore.ToString()); | |
// Do processing | |
//Aspose.CAD.FileFormats.Cad.CadImage image = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.load("BlockRefDgn.dwg"); | |
// Get metered data amount After calling API | |
decimal amountafter = Aspose.CAD.Metered.GetConsumptionQuantity(); | |
// Display information | |
Console.WriteLine("Amount Consumed After: " + amountafter.ToString()); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-.NET | |
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "sample.dwg"; | |
// Load a CAD drawing in an instance of Image | |
using (var image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of BmpOptions class | |
Aspose.CAD.ImageOptions.BmpOptions bmpOptions = new Aspose.CAD.ImageOptions.BmpOptions(); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions cadRasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
bmpOptions.VectorRasterizationOptions = cadRasterizationOptions; | |
// Set the UnitType property | |
cadRasterizationOptions.UnitType = Aspose.CAD.ImageOptions.UnitType.Centimenter; | |
// Set the layouts property | |
cadRasterizationOptions.Layouts = new string[] { "Model" }; | |
//Export layout to BMP format | |
string outPath = sourceFilePath + ".bmp"; | |
image.Save(outPath, bmpOptions); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-.NET | |
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "sample.dwg"; | |
// Load a CAD drawing in an instance of Image | |
using (var image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of BmpOptions class | |
Aspose.CAD.ImageOptions.BmpOptions bmpOptions = new Aspose.CAD.ImageOptions.BmpOptions(); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions cadRasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
bmpOptions.VectorRasterizationOptions = cadRasterizationOptions; | |
// Set the layouts property | |
cadRasterizationOptions.Layouts = new string[] { "Model" }; | |
//Export layout to BMP format | |
string outPath = sourceFilePath + ".bmp"; | |
image.Save(outPath, bmpOptions); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-.NET | |
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "sample.dwg"; | |
// Load a CAD drawing in an instance of Image | |
using (var image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of BmpOptions class | |
Aspose.CAD.ImageOptions.BmpOptions bmpOptions = new Aspose.CAD.ImageOptions.BmpOptions(); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions cadRasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
bmpOptions.VectorRasterizationOptions = cadRasterizationOptions; | |
// Set the UnitType property | |
cadRasterizationOptions.UnitType = Aspose.CAD.ImageOptions.UnitType.Centimenter; | |
// Set the layouts property | |
cadRasterizationOptions.Layouts = new string[] { "Model" }; | |
// Export layout to BMP format | |
string outPath = sourceFilePath + ".bmp"; | |
image.Save(outPath, bmpOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-.NET | |
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "sample.dwg"; | |
// Load a CAD drawing in an instance of Image | |
using (var image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of BmpOptions class | |
Aspose.CAD.ImageOptions.BmpOptions bmpOptions = new Aspose.CAD.ImageOptions.BmpOptions(); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions cadRasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
bmpOptions.VectorRasterizationOptions = cadRasterizationOptions; | |
// Set the UnitType property | |
cadRasterizationOptions.UnitType = Aspose.CAD.ImageOptions.UnitType.Centimenter; | |
// Set the layouts property | |
cadRasterizationOptions.Layouts = new string[] { "Model" }; | |
// Export layout to BMP format | |
string outPath = sourceFilePath + ".bmp"; | |
image.Save(outPath, bmpOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
// Load a CAD drawing in an instance of Image | |
using (var image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
// Set image width & height | |
rasterizationOptions.PageWidth = 500; | |
rasterizationOptions.PageHeight = 500; | |
// Set the drawing to render at the center of image | |
//rasterizationOptions.CenterDrawing = true; | |
// Add the layer name to the CadRasterizationOptions's layer list | |
rasterizationOptions.Layers= new string[] { "LayerA" }; | |
// Create an instance of JpegOptions (or any ImageOptions for raster formats) | |
var options = new Aspose.CAD.ImageOptions.JpegOptions(); | |
// Set VectorRasterizationOptions property to the instance of CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions; | |
//Export each layer to Jpeg format | |
MyDir = MyDir + "CADLayersToRasterImageFormats_out.jpg"; | |
image.Save(MyDir, options); | |
} | |
Console.WriteLine("\nCAD layers converted successfully to raster image format.\nFile saved at " + MyDir); | |
} | |
public static void ConvertAllLayersToRasterImageFormats() | |
{ | |
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
// Load a CAD drawing in an instance of CadImage | |
using (var image = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
// Set image width & height | |
rasterizationOptions.PageWidth = 500; | |
rasterizationOptions.PageHeight = 500; | |
// Set the drawing to render at the center of image | |
// rasterizationOptions.CenterDrawing = true; | |
// Get the layers in an instance of CadLayersDictionary | |
var layersList = image.Layers; | |
// Iterate over the layers | |
foreach (var layerName in layersList.GetLayersNames()) | |
{ | |
// Display layer name for tracking | |
Console.WriteLine("Start with " + layerName); | |
// Add the layer name to the CadRasterizationOptions's layer list | |
rasterizationOptions.Layers = new string[] { "LayerA" }; | |
// Create an instance of JpegOptions (or any ImageOptions for raster formats) | |
var options = new Aspose.CAD.ImageOptions.JpegOptions(); | |
// Set VectorRasterizationOptions property to the instance of CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions; | |
//Export each layer to Jpeg format | |
image.Save(layerName + "_out.jpg", options); | |
} | |
} | |
Console.WriteLine("\nCAD all layers converted successfully to raster image format."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-.NET | |
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
// Load a CAD drawing in an instance of CadImage | |
using (var image = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
// Set image width & height | |
rasterizationOptions.PageWidth = 500; | |
rasterizationOptions.PageHeight = 500; | |
// Set the drawing to render at the center of image | |
rasterizationOptions.CenterDrawing = true; | |
// Get the layers in an instance of CadLayersDictionary | |
var layersList = image.Layers; | |
// Iterate over the layers | |
foreach (var layerName in layersList.GetLayersNames()) | |
{ | |
// Display layer name for tracking | |
Console.WriteLine("Start with " + layerName); | |
// Add the layer name to the CadRasterizationOptions's layer list | |
rasterizationOptions.Layers.Add(layerName); | |
// Create an instance of JpegOptions (or any ImageOptions for raster formats) | |
var options = new Aspose.CAD.ImageOptions.JpegOptions(); | |
// Set VectorRasterizationOptions property to the instance of CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions; | |
//Export each layer to Jpeg format | |
image.Save(layerName + "_out.jpg", options); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
// Set page width & height | |
rasterizationOptions.PageWidth = 1200; | |
rasterizationOptions.PageHeight = 1200; | |
// Create an instance of PngOptions for the resultant image | |
ImageOptionsBase options = new Aspose.CAD.ImageOptions.PngOptions(); | |
// Set rasterization options | |
options.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "conic_pyramid_raster_image_out.png"; | |
// Save resultant image | |
image.Save(MyDir, options); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
// Set page width & height | |
rasterizationOptions.PageWidth = 1200; | |
rasterizationOptions.PageHeight = 1200; | |
// Specify a list of layout names | |
rasterizationOptions.Layouts = new string[] { "Model", "Layout1" }; | |
// Create an instance of TiffOptions for the resultant image | |
ImageOptionsBase options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// Set rasterization options | |
options.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "conic_pyramid_layoutstorasterimage_out.tiff"; | |
// Save resultant image | |
image.Save(MyDir, options); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
MemoryStream stream = new MemoryStream(); | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions cadRasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
pdfOptions.VectorRasterizationOptions = cadRasterizationOptions; | |
cadRasterizationOptions.PageWidth = 800; | |
cadRasterizationOptions.PageHeight = 600; | |
image.Save(stream, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string[] sourceFilePaths = new[] | |
{ | |
MyDir + "conic_pyramid.dxf", | |
MyDir + "Bottom_plate.dwg" | |
}; | |
foreach (var sourceFilePath in sourceFilePaths) | |
{ | |
string extension = Path.GetExtension(sourceFilePath); | |
using (CadImage cadImage = (CadImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
List<string> layouts = GetNotEmptyLayouts(cadImage, extension); | |
const double Epsilon = 0.00001; | |
foreach (string layout in layouts) | |
{ | |
System.Console.WriteLine("Layout= " + layout); | |
using (FileStream fs = new FileStream(MyDir + "layout_" + extension + "_" + layout + ".jpg", FileMode.Create)) | |
{ | |
JpegOptions jpegOptions = new JpegOptions(); | |
CadRasterizationOptions options = new CadRasterizationOptions(); | |
options.Layouts = new string[] { layout }; | |
CadLayout l = cadImage.Layouts[layout]; | |
if ((Math.Abs(l.MaxExtents.Y) < Epsilon && Math.Abs(l.MaxExtents.X) < Epsilon) | |
|| (Math.Abs(l.MaxExtents.Y + 1E+20) < Epsilon | |
|| Math.Abs(l.MaxExtents.X + 1E+20) < Epsilon) | |
|| (Math.Abs(l.MinExtents.Y - 1E+20) < Epsilon | |
|| Math.Abs(l.MinExtents.X - 1E+20) < Epsilon)) | |
{ | |
// do nothing, we can automatically detect size | |
// we can not rely on PlotPaperUnits here too because it is PlotInInches by default | |
} | |
else | |
{ | |
double sizeExtX = l.MaxExtents.X - l.MinExtents.X; | |
double sizeExtY = l.MaxExtents.Y - l.MinExtents.Y; | |
if (l.PlotPaperUnits == CadPlotPaperUnits.PlotInInches) | |
{ | |
options.PageHeight = CommonHelper.INtoPixels(sizeExtY, CommonHelper.DPI); | |
options.PageWidth = CommonHelper.INtoPixels(sizeExtX, CommonHelper.DPI); | |
} | |
else | |
{ | |
if (l.PlotPaperUnits == CadPlotPaperUnits.PlotInMillimeters) | |
{ | |
options.PageHeight = CommonHelper.MMtoPixels(sizeExtY, CommonHelper.DPI); | |
options.PageWidth = CommonHelper.MMtoPixels(sizeExtX, CommonHelper.DPI); | |
} | |
else | |
{ | |
options.PageHeight = (float)sizeExtY; | |
options.PageWidth = (float)sizeExtX; | |
} | |
} | |
} | |
//options.CenterDrawing = true; | |
jpegOptions.VectorRasterizationOptions = options; | |
cadImage.Save(fs, jpegOptions); | |
} | |
} | |
} | |
} | |
} | |
private static List<string> GetNotEmptyLayouts(Image cadImage, string extension) | |
{ | |
List<string> nonEmptyLayouts = new List<string>(); | |
if (cadImage == null) | |
return nonEmptyLayouts; | |
switch (extension) | |
{ | |
case ".dwg": | |
nonEmptyLayouts = GetNotEmptyLayoutsForDwg((CadImage)cadImage); | |
break; | |
case ".dxf": | |
nonEmptyLayouts = GetNotEmptyLayoutsForDxf((CadImage)cadImage); | |
break; | |
} | |
return nonEmptyLayouts; | |
} | |
private static List<string> GetNotEmptyLayoutsForDwg(CadImage cadImage) | |
{ | |
List<string> notEmptyLayouts = new List<string>(); | |
foreach (CadLayout layout in cadImage.Layouts.Values) | |
{ | |
foreach (CadBlockTableObject tableObject in cadImage.BlocksTables) | |
{ | |
if (string.Equals(tableObject.HardPointerToLayout.Value, layout.ObjectHandle, StringComparison.InvariantCultureIgnoreCase)) | |
{ | |
if (cadImage.BlockEntities.ContainsKey(tableObject.BlockName)) | |
{ | |
CadBlockEntity cadBlockEntity = cadImage.BlockEntities[tableObject.BlockName]; | |
if (cadBlockEntity.Entities.Length > 0) | |
notEmptyLayouts.Add(layout.LayoutName); | |
} | |
break; | |
} | |
} | |
} | |
return notEmptyLayouts; | |
} | |
private static List<string> GetNotEmptyLayoutsForDxf(CadImage cadImage) | |
{ | |
List<string> notEmptyLayouts = new List<string>(); | |
Dictionary<string, string> layoutBlockHandles = new Dictionary<string, string>(); | |
foreach (CadLayout layout in cadImage.Layouts.Values) | |
{ | |
if (layout.BlockTableRecordHandle != null) | |
layoutBlockHandles.Add(layout.BlockTableRecordHandle, layout.LayoutName); | |
} | |
foreach (CadBaseEntity entity in cadImage.Entities) | |
{ | |
if (layoutBlockHandles.ContainsKey(entity.SoftOwner.Value)) | |
{ | |
string layoutName = layoutBlockHandles[entity.SoftOwner.Value]; | |
if (!notEmptyLayouts.Contains(layoutName)) | |
notEmptyLayouts.Add(layoutName); | |
} | |
} | |
return notEmptyLayouts; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string MyDir = RunExamples.GetDataDir_IGESDrawings(); | |
string sourceFilePath = MyDir + ("figa2.igs"); | |
string outPath = MyDir + ("meshes.pdf"); | |
using (Image igesImage = Image.Load(sourceFilePath)) | |
{ | |
Aspose.CAD.ImageOptions.PdfOptions pdf = new Aspose.CAD.ImageOptions.PdfOptions(); | |
pdf.VectorRasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
pdf.VectorRasterizationOptions.PageHeight = 1000; | |
pdf.VectorRasterizationOptions.PageWidth = 1000; | |
igesImage.Save("figa2.pdf", pdf); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)image; | |
Aspose.CAD.FileFormats.Cad.CadLayoutDictionary layouts = cadImage.Layouts; | |
foreach (Aspose.CAD.FileFormats.Cad.CadObjects.CadLayout layout in layouts.Values) | |
{ | |
Console.WriteLine("Layout " + layout.LayoutName); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir+("meshes.dwg"); | |
string outPath = MyDir+("meshes.pdf"); | |
using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
//rasterizationOptions.TypeOfEntities = TypeOfEntities.Entities3D; | |
rasterizationOptions.Layouts = new string[] { "Model" }; | |
PdfOptions pdfOptions = new PdfOptions | |
{ | |
VectorRasterizationOptions = rasterizationOptions | |
}; | |
{ | |
cadImage.Save(outPath, pdfOptions); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
CadImage cadImage = (CadImage)Image.Load(sourceFilePath); | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Here user can change default start cap and end cap of pens when exporting CadImage object to | |
// image. It can be using for all image formats: pdf, png, bmp, gif, jpeg2000, jpeg, psd, tiff, wmf. | |
// If user doesn't use PenOptions, system will use its own default pens (different in defferent places). | |
rasterizationOptions.PenOptions = new PenOptions | |
{ | |
StartCap = LineCap.Flat, | |
EndCap = LineCap.Flat | |
}; | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(MyDir+"9LHATT-A56_generated.pdf", pdfOptions); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
using (CadImage image = (CadImage)Image.Load(MyDir+"example.dwt")) | |
{ | |
foreach (CadBaseEntity entity in image.Entities) | |
{ | |
//do your work here | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
// Set Auto Layout Scaling | |
rasterizationOptions.AutomaticLayoutsScaling = true; | |
// Create an instance of PdfOptions | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "result_out.pdf"; | |
//Export the CAD to PDF | |
image.Save(MyDir, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
rasterizationOptions.BackgroundColor = Aspose.CAD.Color.Beige; | |
rasterizationOptions.DrawType = Aspose.CAD.FileFormats.Cad.CadDrawTypeMode.UseDrawColor; | |
rasterizationOptions.DrawColor = Aspose.CAD.Color.Blue; | |
// Create an instance of PdfOptions | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
//Export CAD to PDF | |
image.Save(MyDir + "result_out.pdf", pdfOptions); | |
// Create an instance of TiffOptions | |
Aspose.CAD.ImageOptions.TiffOptions tiffOptions = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// Set the VectorRasterizationOptions property | |
tiffOptions.VectorRasterizationOptions = rasterizationOptions; | |
//Export CAD to TIFF | |
image.Save(MyDir + "result_out.tiff", tiffOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
rasterizationOptions.AutomaticLayoutsScaling = true; | |
rasterizationOptions.NoScaling = false; | |
// Create an instance of PdfOptions | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
//Export CAD to PDF | |
image.Save(MyDir + "result_out.pdf", pdfOptions); | |
// Create an instance of TiffOptions | |
Aspose.CAD.ImageOptions.TiffOptions tiffOptions = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// Set the VectorRasterizationOptions property | |
tiffOptions.VectorRasterizationOptions = rasterizationOptions; | |
//Export CAD to TIFF | |
image.Save(MyDir + "result_out.tiff", tiffOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-.NET | |
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
// Load a CAD drawing in an instance of CadImage | |
using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Iterate over the items of CadStyleDictionary | |
foreach (CadStyleTableObject style in cadImage.Styles) | |
{ | |
if (style.StyleName == "Roman") | |
{ | |
// Specify the font for one particular style | |
style.PrimaryFontName = "Arial"; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
// Load a CAD drawing in an instance of CadImage | |
using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Iterate over the items of CadStyleDictionary | |
foreach (CadStyleTableObject style in cadImage.Styles) | |
{ | |
// Set the font name | |
style.PrimaryFontName = "Arial"; | |
} | |
} | |
Console.WriteLine("\nFont changed successfully."); | |
} | |
public static void SubstitutingFontByName() | |
{ | |
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
// Load a CAD drawing in an instance of CadImage | |
using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Iterate over the items of CadStyleDictionary | |
foreach (CadStyleTableObject style in cadImage.Styles) | |
{ | |
if (style.StyleName == "Roman") | |
{ | |
// Specify the font for one particular style | |
style.PrimaryFontName = "Arial"; | |
} | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWFDrawings(); | |
string sourceFilePath = MyDir + "blocks_and_tables.dwf"; | |
string extension = Path.GetExtension(sourceFilePath); | |
using (DwfImage image = (DwfImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
foreach (var page in image.Pages) | |
{ | |
var layout = page.Name; | |
System.Console.WriteLine("Layout= " + layout); | |
using (FileStream fs = new FileStream(MyDir + "layout_" + layout + ".jpg", FileMode.Create)) | |
{ | |
JpegOptions jpegOptions = new JpegOptions(); | |
CadRasterizationOptions options = new CadRasterizationOptions(); | |
options.Layouts = new string[] { layout }; | |
double sizeExtX = page.MaxPoint.X - page.MinPoint.X; | |
double sizeExtY = page.MaxPoint.Y - page.MinPoint.Y; | |
if (page.UnitType == UnitType.Inch) | |
{ | |
options.PageHeight = CommonHelper.INtoPixels(sizeExtY, CommonHelper.DPI); | |
options.PageWidth = CommonHelper.INtoPixels(sizeExtX, CommonHelper.DPI); | |
} | |
else if (page.UnitType == UnitType.Millimeter) | |
{ | |
options.PageHeight = CommonHelper.MMtoPixels(sizeExtY, CommonHelper.DPI); | |
options.PageWidth = CommonHelper.MMtoPixels(sizeExtX, CommonHelper.DPI); | |
} | |
else | |
{ | |
options.PageHeight = (float)sizeExtY; | |
options.PageWidth = (float)sizeExtX; | |
} | |
//options.CenterDrawing = true; | |
jpegOptions.VectorRasterizationOptions = options; | |
image.Save(fs, jpegOptions); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "for_layers_test.dwf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
// Add desired layers | |
rasterizationOptions.Layers= new string[] { "LayerA" }; | |
//rasterizationOptions.CenterDrawing = true; | |
JpegOptions jpegOptions = new JpegOptions(); | |
jpegOptions.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "for_layers_test.jpg"; | |
// Export the DXF to JPG | |
image.Save(MyDir, jpegOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Input file name and path | |
string fileName = "BlockRefDgn.dwg"; | |
// Load an existing DWG file and convert it into CadImage | |
using (Aspose.CAD.FileFormats.Cad.CadImage image = (Aspose.CAD.FileFormats.Cad.CadImage)Image.Load(fileName)) | |
{ | |
// Go through each entity inside the DWG file | |
foreach (Aspose.CAD.FileFormats.Cad.CadObjects.CadBaseEntity entity in image.Entities) | |
{ | |
// Check if entity is of CadDgnUnderlay type | |
if (entity is Aspose.CAD.FileFormats.Cad.CadObjects.CadDgnUnderlay) | |
{ | |
// Access different underlay flags | |
Aspose.CAD.FileFormats.Cad.CadObjects.CadUnderlay underlay = entity as Aspose.CAD.FileFormats.Cad.CadObjects.CadUnderlay; | |
Console.WriteLine(underlay.UnderlayPath); | |
Console.WriteLine(underlay.UnderlayName); | |
Console.WriteLine(underlay.InsertionPoint.X); | |
Console.WriteLine(underlay.InsertionPoint.Y); | |
Console.WriteLine(underlay.RotationAngle); | |
Console.WriteLine(underlay.ScaleX); | |
Console.WriteLine(underlay.ScaleY); | |
Console.WriteLine(underlay.ScaleZ); | |
Console.WriteLine((underlay.Flags & Aspose.CAD.FileFormats.Cad.CadObjects.UnderlayFlags.UnderlayIsOn) == Aspose.CAD.FileFormats.Cad.CadObjects.UnderlayFlags.UnderlayIsOn); | |
Console.WriteLine((underlay.Flags & Aspose.CAD.FileFormats.Cad.CadObjects.UnderlayFlags.ClippingIsOn) == Aspose.CAD.FileFormats.Cad.CadObjects.UnderlayFlags.ClippingIsOn); | |
Console.WriteLine((underlay.Flags & Aspose.CAD.FileFormats.Cad.CadObjects.UnderlayFlags.Monochrome) != Aspose.CAD.FileFormats.Cad.CadObjects.UnderlayFlags.Monochrome); | |
break; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string dwgPathToFile = MyDir + "SimpleEntites.dwg"; | |
using (Image image = Image.Load(dwgPathToFile)) | |
{ | |
CadText cadText = new CadText(); | |
cadText.StyleType = "Standard"; | |
cadText.DefaultValue = "Some custom text"; | |
cadText.ColorId = 256; | |
cadText.LayerName = "0"; | |
cadText.FirstAlignment.X = 47.90; | |
cadText.FirstAlignment.Y = 5.56; | |
cadText.TextHeight = 0.8; | |
cadText.ScaleX = 0.0; | |
CadImage cadImage = (CadImage)image; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(cadText); | |
PdfOptions pdfOptions = new PdfOptions(); | |
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions(); | |
pdfOptions.VectorRasterizationOptions = cadRasterizationOptions; | |
cadRasterizationOptions.DrawType = CadDrawTypeMode.UseObjectColor; | |
cadRasterizationOptions.PageHeight = 1600; | |
cadRasterizationOptions.PageWidth = 1600; | |
cadRasterizationOptions.Layouts = new string[] { "Model" }; | |
image.Save(MyDir+"SimpleEntites_generated.pdf", pdfOptions); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string inputFile = MyDir + "test1.dwg"; | |
string outputFile = MyDir + "test1.png"; | |
using (FileStream fs = new FileStream(inputFile, FileMode.Open)) | |
{ | |
using (FileStream output = new FileStream(outputFile, FileMode.Create)) | |
{ | |
Image document = Image.Load(fs); | |
PngOptions saveOptions = new PngOptions(); | |
CadRasterizationOptions options = new CadRasterizationOptions(); | |
options.NoScaling = false; | |
//options.CenterDrawing = true; | |
options.PageHeight = document.Height * 10; | |
options.PageWidth = document.Width * 10; | |
options.DrawType = Aspose.CAD.FileFormats.Cad.CadDrawTypeMode.UseObjectColor; | |
saveOptions.VectorRasterizationOptions = options; | |
document.Save(output, saveOptions); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var formatTypeDwt = Image.GetFileFormat(GetFileFromDesktop("sample.dwt")); | |
Assert.IsTrue(formatTypeDwt.ToString().ToLower().Contains("dwt")); | |
var formatTypeDwg = Image.GetFileFormat(GetFileFromDesktop("sample.dwg")); | |
Assert.IsTrue(formatTypeDwg.ToString().ToLower().Contains("dwg")); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir + "Bottom_plate.dwg"; | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions | |
{ | |
VectorRasterizationOptions = rasterizationOptions | |
}; | |
pdfOptions.CorePdfOptions = new PdfDocumentOptions(); | |
pdfOptions.CorePdfOptions.Compliance = PdfCompliance.PdfA1a; | |
cadImage.Save(outPath, pdfOptions); | |
pdfOptions.CorePdfOptions.Compliance = PdfCompliance.PdfA1b; | |
cadImage.Save(outPath, pdfOptions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string inputFile = MyDir + "Line.dwg"; | |
string outFile = MyDir + "Line_19.2.dxf"; | |
using (var cadImage = (CadImage)Image.Load(inputFile)) | |
{ | |
cadImage.Save(outFile); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir + "Bottom_plate.dwg"; | |
using (CadImage cadImage = (CadImage)Image.Load(fileName)) | |
{ | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.Layouts = new string[] { "Model" }; | |
bool currentUnitIsMetric = false; | |
double currentUnitCoefficient = 1.0; | |
DefineUnitSystem(cadImage.UnitType, out currentUnitIsMetric, out currentUnitCoefficient); | |
if (currentUnitIsMetric) | |
{ | |
double metersCoeff = 1 / 1000.0; | |
double scaleFactor = metersCoeff / currentUnitCoefficient; | |
rasterizationOptions.PageWidth = (float)(210 * scaleFactor); | |
rasterizationOptions.PageHeight = (float)(297 * scaleFactor); | |
rasterizationOptions.UnitType = UnitType.Millimeter; | |
} | |
else | |
{ | |
rasterizationOptions.PageWidth = (float)(8.27f / currentUnitCoefficient); | |
rasterizationOptions.PageHeight = (float)(11.69f / currentUnitCoefficient); | |
rasterizationOptions.UnitType = UnitType.Inch; | |
} | |
rasterizationOptions.AutomaticLayoutsScaling = true; | |
PdfOptions pdfOptions = new PdfOptions | |
{ | |
VectorRasterizationOptions = rasterizationOptions | |
}; | |
cadImage.Save(outPath, pdfOptions); | |
// export to raster | |
//A4 size at 300 DPI - 2480 x 3508 | |
rasterizationOptions.PageHeight = 3508; | |
rasterizationOptions.PageWidth = 2480; | |
cadImage.Save(outPath.Replace("pdf", "png"), pngOptions); | |
private static void DefineUnitSystem(UnitType unitType, out bool isMetric, out double coefficient) | |
{ | |
isMetric = false; | |
coefficient = 1.0; | |
switch (unitType) | |
{ | |
case UnitType.Parsec: | |
coefficient = 3.0857 * 10000000000000000.0; | |
isMetric = true; | |
break; | |
case UnitType.LightYear: | |
coefficient = 9.4607 * 1000000000000000.0; | |
isMetric = true; | |
break; | |
case UnitType.AstronomicalUnit: | |
coefficient = 1.4960 * 100000000000.0; | |
isMetric = true; | |
break; | |
case UnitType.Gigameter: | |
coefficient = 1000000000.0; | |
isMetric = true; | |
break; | |
case UnitType.Kilometer: | |
coefficient = 1000.0; | |
isMetric = true; | |
break; | |
case UnitType.Decameter: | |
isMetric = true; | |
coefficient = 10.0; | |
break; | |
case UnitType.Hectometer: | |
isMetric = true; | |
coefficient = 100.0; | |
break; | |
case UnitType.Meter: | |
isMetric = true; | |
coefficient = 1.0; | |
break; | |
case UnitType.Centimenter: | |
isMetric = true; | |
coefficient = 0.01; | |
break; | |
case UnitType.Decimeter: | |
isMetric = true; | |
coefficient = 0.1; | |
break; | |
case UnitType.Millimeter: | |
isMetric = true; | |
coefficient = 0.001; | |
break; | |
case UnitType.Micrometer: | |
isMetric = true; | |
coefficient = 0.000001; | |
break; | |
case UnitType.Nanometer: | |
isMetric = true; | |
coefficient = 0.000000001; | |
break; | |
case UnitType.Angstrom: | |
isMetric = true; | |
coefficient = 0.0000000001; | |
break; | |
case UnitType.Inch: | |
coefficient = 1.0; | |
break; | |
case UnitType.MicroInch: | |
coefficient = 0.000001; | |
break; | |
case UnitType.Mil: | |
coefficient = 0.001; | |
break; | |
case UnitType.Foot: | |
coefficient = 12.0; | |
break; | |
case UnitType.Yard: | |
coefficient = 36.0; | |
break; | |
case UnitType.Mile: | |
coefficient = 63360.0; | |
break; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir + "visualization_-_conference_room.dwg"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
// Specify desired layout name | |
rasterizationOptions.Layouts = new string[] { "Layout1" }; | |
// Create an instance of PdfOptions | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "ExportSpecificLayoutToPDF_out.pdf"; | |
//Export the DWG to PDF | |
image.Save(MyDir, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir + "Bottom_plate.dwg"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.BackgroundColor = Aspose.CAD.Color.White; | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
// Create an instance of PdfOptions | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "Bottom_plate_out.pdf"; | |
//Export the DWG to PDF | |
image.Save(MyDir, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
using (Image image = Image.Load(MyDir + "sample.dwg")) | |
{ | |
var options = new SvgOptions(); | |
options.ColorType = Aspose.CAD.ImageOptions.SvgOptionsParameters.SvgColorMode.Grayscale; | |
options.TextAsShapes = true; | |
image.Save(MyDir + "sample.svg"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir + "sample.dwg"; | |
// Load an existing DWG file as CadImage. | |
using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
System.Console.WriteLine(cadImage.BlockEntities["*MODEL_SPACE"].XRefPathName); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string dwgPathToFile = MyDir +"Drawing11.dwg"; | |
CadImage cadImage1 = (CadImage)Image.Load(dwgPathToFile); | |
// using (Image image = ImageLoader.Load(dwgPathToFile)) | |
{ | |
CadRasterImageDef cadRasterImageDef = new CadRasterImageDef(); | |
cadRasterImageDef.ObjectHandle = "A3B4"; | |
cadRasterImageDef.FileName = "road-sign-custom.png"; | |
CadRasterImage cadRasterImage = new CadRasterImage(); | |
cadRasterImage.ImageDefReference = "A3B4"; | |
cadRasterImage.InsertionPoint.X = 26.77; | |
cadRasterImage.InsertionPoint.Y = 22.35; | |
cadRasterImage.DisplayFlags = 7; | |
cadRasterImage.ImageSizeU = 640; | |
cadRasterImage.ImageSizeV = 562; | |
cadRasterImage.UVector.X = 0.0061565450840500831; | |
cadRasterImage.UVector.Y = 0; | |
cadRasterImage.VVector.X = 0; | |
cadRasterImage.VVector.Y = 0.0061565450840500822; | |
cadRasterImage.ClippingState = 0; | |
cadRasterImage.ClipBoundaryVertexList.Add(new Cad2DPoint(-0.5, 0.5)); | |
cadRasterImage.ClipBoundaryVertexList.Add(new Cad2DPoint(639.5, 561.5)); | |
CadImage cadImage = (CadImage)cadImage1; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(cadRasterImage); | |
List<CadBaseObject> list = new List<CadBaseObject>(cadImage.Objects); | |
list.Add(cadRasterImageDef); | |
cadImage.Objects = list.ToArray(); | |
PdfOptions pdfOptions = new PdfOptions(); | |
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions(); | |
pdfOptions.VectorRasterizationOptions = cadRasterizationOptions; | |
cadRasterizationOptions.DrawType = CadDrawTypeMode.UseObjectColor; | |
//cadRasterizationOptions.CenterDrawing = true; | |
cadRasterizationOptions.PageHeight = 1600; | |
cadRasterizationOptions.PageWidth = 1600; | |
cadRasterizationOptions.Layouts = new string[] { "Model" }; | |
cadImage1.Save(MyDir+"export2.pdf", pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir + "meshes.dwg"; | |
// Load an existing DWG file as CadImage. | |
using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
foreach (var entity in cadImage.Entities) | |
{ | |
if (entity is CadPolyFaceMesh) | |
{ | |
CadPolyFaceMesh asFaceMesh = (CadPolyFaceMesh)entity; | |
if (asFaceMesh != null) | |
{ | |
Console.WriteLine("Vetexes count: " + asFaceMesh.MeshMVertexCount); | |
} | |
} | |
else if (entity is CadPolygonMesh) | |
{ | |
CadPolygonMesh asPolygonMesh = (CadPolygonMesh)entity; | |
if (asPolygonMesh != null) | |
{ | |
Console.WriteLine("Vetexes count: " + asPolygonMesh.MeshMVertexCount); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir + "visualization_-_conference_room.dwg"; | |
var cadImage = (CadImage)Aspose.CAD.Image.Load(sourceFilePath); | |
CadBaseEntity[] entities = cadImage.Entities; | |
List<CadBaseEntity> filteredEntities = new List<CadBaseEntity>(); | |
foreach (CadBaseEntity baseEntity in entities) | |
{ | |
// selection or filtration of entities | |
if (baseEntity.TypeName == CadEntityTypeName.TEXT) | |
{ | |
filteredEntities.Add(baseEntity); | |
} | |
} | |
cadImage.Entities = filteredEntities.ToArray(); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = | |
new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
// Set Auto Layout Scaling | |
rasterizationOptions.AutomaticLayoutsScaling = true; | |
// Create an instance of PdfOptions | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
string outFile = MyDir + "result_out_generated.pdf"; | |
// Export the CAD to PDF | |
cadImage.Save(outFile, pdfOptions); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir + "Bottom_plate.dwg"; | |
using (CadImage image = (CadImage)Image.Load(fileName)) | |
{ | |
foreach (CadBaseEntity entity in image.Entities) | |
{ | |
if (entity is CadUnderlay) | |
{ | |
//XREF entity with metadata | |
Cad3DPoint insertionPoint = ((CadUnderlay)entity).InsertionPoint; | |
string path = ((CadUnderlay)entity).UnderlayPath; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir + "Bottom_plate.dwg"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.Layouts = new string[] { "Model" }; | |
rasterizationOptions.NoScaling = true; | |
// note: preserving some empty borders around part of image is the responsibility of customer | |
// top left point of region to draw | |
Point topLeft = new Point(6156, 7053); | |
double width = 3108; | |
double height = 2489; | |
CadVportTableObject newView = new CadVportTableObject(); | |
// note: exactly such table name is required for active view | |
newView.TableName = "*Active"; | |
newView.CenterPoint.X = topLeft.X + width / 2f; | |
newView.CenterPoint.Y = topLeft.Y - height / 2f; | |
newView.ViewHeight.Value = height; | |
newView.ViewAspectRatio.Value = width / height; | |
// search for active viewport and replace it | |
for (int i = 0; i < cadImage.ViewPorts.Count; i++) | |
{ | |
CadVportTableObject currentView = (CadVportTableObject)(cadImage.ViewPorts[i]); | |
if ((currentView.TableName == null && cadImage.ViewPorts.Count == 1) || | |
string.Equals(currentView.TableName.ToLowerInvariant(), "*active")) | |
{ | |
cadImage.ViewPorts[i] = newView; | |
break; | |
} | |
} | |
image.Save(MyDir, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir + "search.dwg"; | |
// Load an existing DWG file as CadImage. | |
using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Search for text in the file | |
foreach (Aspose.CAD.FileFormats.Cad.CadObjects.CadBaseEntity entity in cadImage.Entities) | |
{ | |
// Please, note: we iterate through CadText entities here, but some other entities may contain text also, e.g. CadMText and others | |
IterateCADNodes(entity); | |
} | |
// Search for text on specific layout get all layout names and link each layout with corresponding block with entities | |
Aspose.CAD.FileFormats.Cad.CadLayoutDictionary layouts = cadImage.Layouts; | |
string[] layoutNames = new string[layouts.Count]; | |
int i = 0; | |
foreach (Aspose.CAD.FileFormats.Cad.CadObjects.CadLayout layout in layouts.Values) | |
{ | |
layoutNames[i++] = layout.LayoutName; | |
System.Console.WriteLine("Layout " + layout.LayoutName + " is found"); | |
// Find block, applicable for DWG only | |
Aspose.CAD.FileFormats.Cad.CadTables.CadBlockTableObject blockTableObjectReference = null; | |
foreach (Aspose.CAD.FileFormats.Cad.CadTables.CadBlockTableObject tableObject in cadImage.BlocksTables) | |
{ | |
if (string.Equals(tableObject.HardPointerToLayout, layout.ObjectHandle)) | |
{ | |
blockTableObjectReference = tableObject; | |
break; | |
} | |
} | |
if (blockTableObjectReference !=null) | |
{ | |
// Collection cadBlockEntity.Entities contains information about all entities on specific layout if this collection has no elements it means layout is a copy of Model layout and contains the same entities | |
Aspose.CAD.FileFormats.Cad.CadObjects.CadBlockEntity cadBlockEntity = cadImage.BlockEntities[blockTableObjectReference.BlockName]; | |
} | |
} | |
//Export to pdf | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
rasterizationOptions.AutomaticLayoutsScaling = true; | |
//rasterizationOptions.CenterDrawing = true; | |
// Please, note: if cadBlockEntity collection mentioned above (for dwg) for selected layout or entitiesOnLayouts collection by layout's BlockTableRecordHandle (for dxf) is empty - export result file will be empty and you should draw Model layout instead | |
rasterizationOptions.Layouts = new[] { "Layout1" }; | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(MyDir + "SearchText_out.pdf", pdfOptions); | |
} | |
} | |
public static void SearchTextInDWGAutoCADFile() | |
{ | |
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir + "search.dwg"; | |
// Load an existing DWG file as CadImage. | |
CadImage cadImage = (CadImage) Image.Load(sourceFilePath); | |
// Search for text in the entities section | |
foreach (var entity in cadImage.Entities) { | |
IterateCADNodes(entity); | |
} | |
// Search for text in the block section | |
foreach (CadBlockEntity blockEntity in cadImage.BlockEntities.Values) { | |
foreach (var entity in blockEntity.Entities) { | |
IterateCADNodes(entity); | |
} | |
} | |
} | |
private static void IterateCADNodes(CadBaseEntity obj) | |
{ | |
switch (obj.TypeName) { | |
case CadEntityTypeName.TEXT: | |
CadText childObjectText = (CadText) obj; | |
Console.WriteLine(childObjectText.DefaultValue); | |
break; | |
case CadEntityTypeName.MTEXT: | |
CadMText childObjectMText = (CadMText) obj; | |
Console.WriteLine(childObjectMText.Text); | |
break; | |
case CadEntityTypeName.INSERT: | |
CadInsertObject childInsertObject = (CadInsertObject) obj; | |
foreach (var tempobj in childInsertObject.ChildObjects) { | |
IterateCADNodes(tempobj); | |
} | |
break; | |
case CadEntityTypeName.ATTDEF: | |
CadAttDef attDef = (CadAttDef) obj; | |
Console.WriteLine(attDef.DefaultString); | |
break; | |
case CadEntityTypeName.ATTRIB: | |
CadAttrib attAttrib = (CadAttrib) obj; | |
Console.WriteLine(attAttrib.DefaultText); | |
break; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string file = MyDir + "sample.dwg"; | |
using (Image image = Image.Load(file)) | |
{ | |
// Test | |
FileFormats.Cad.CadImage cadImage = (FileFormats.Cad.CadImage)image; | |
Assert.AreNotEqual(cadImage.Entities.Length, 0); | |
CadMLeader cadMLeader = (CadMLeader)cadImage.Entities[0]; | |
Assert.AreEqual(cadMLeader.StyleDescription, "Standard"); | |
Assert.AreEqual(cadMLeader.LeaderStyleId, "12E"); | |
Assert.AreEqual(cadMLeader.ArrowHeadId1, "639"); | |
Assert.AreEqual(cadMLeader.LeaderLineTypeID, "14"); | |
CadMLeaderContextData context = cadMLeader.ContextData; | |
Assert.AreEqual(context.ArrowHeadSize, 30.0, 0.1); | |
Assert.AreEqual(context.BasePoint.X, 481, 1); | |
Assert.AreEqual(context.ContentScale, 1.0, 0.01); | |
Assert.AreEqual(context.DefaultText.Value, "This is multileader with huge text\\P{\\H1.5x;6666666666666666666666666666\\P}bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); | |
Assert.AreEqual(context.HasMText, true); | |
CadMLeaderNode mleaderNode = context.LeaderNode; | |
Assert.AreEqual(mleaderNode.LastLeaderLinePoint.X, 473, 1); | |
CadMLeaderLine leaderLine = mleaderNode.LeaderLine; | |
Assert.AreEqual(leaderLine.BreakEndPoint, null); | |
Assert.AreEqual(leaderLine.BreakPointIndex.Value, 0); | |
Assert.AreEqual(leaderLine.BreakStartPoint, null); | |
Assert.AreEqual(leaderLine.LeaderLineIndex.Value, 0); | |
Assert.AreEqual(leaderLine.LeaderPoints.Count, 4); | |
Assert.AreEqual(mleaderNode.BranchIndex, 0); | |
Assert.AreEqual(mleaderNode.DogLegLength, 8.0, 0.1); | |
Assert.AreEqual(context.HasMText, true); | |
Assert.AreEqual(context.TextAttachmentType.Value, 1); | |
Assert.AreEqual(context.TextBackgroundColor.Value, 18); | |
Assert.AreEqual(context.TextHeight, 20.0, 0.1); | |
Assert.AreEqual(context.TextStyleID.Value, "11"); | |
Assert.AreEqual(context.TextRotation.Value, 0.0, 0.01); | |
Assert.AreEqual(cadMLeader.ArrowHeadId1, "639"); | |
Assert.AreEqual(cadMLeader.LeaderType, 1); | |
Assert.AreEqual(cadMLeader.BlockContentColor, 0); | |
Assert.AreEqual(cadMLeader.LeaderLineColor, 0); | |
Assert.AreEqual(cadMLeader.TextHeight, 1.0, 0.01); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
List<CadBaseEntity> mtextList = new List<CadBaseEntity>(); | |
List<CadBaseEntity> attribList = new List<CadBaseEntity>(); | |
using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
foreach (var entity in cadImage.Entities) | |
{ | |
if (entity.TypeName == CadEntityTypeName.MTEXT) | |
{ | |
mtextList.Add(entity); | |
} | |
if (entity.TypeName == CadEntityTypeName.INSERT) | |
{ | |
foreach (var childObject in entity.ChildObjects) | |
{ | |
if (childObject.TypeName == CadEntityTypeName.ATTRIB) | |
{ | |
attribList.Add(childObject); | |
} | |
} | |
} | |
} | |
Assert.AreEqual(6, mtextList.Count); | |
Assert.AreEqual(34, attribList.Count); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
using (Image image = Image.Load(MyDir + "conic_pyramid.dxf")) | |
{ | |
using (FileStream stream = new FileStream(MyDir + "output_conic_pyramid.pdf", FileMode.Create)) | |
{ | |
PdfOptions pdfOptions = new PdfOptions(); | |
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions(); | |
pdfOptions.VectorRasterizationOptions = cadRasterizationOptions; | |
cadRasterizationOptions.PageWidth = 800; | |
cadRasterizationOptions.PageHeight = 600; | |
int idxError = 1; | |
cadRasterizationOptions.RenderResult += new CadRasterizationOptions.CadRenderHandler( | |
delegate (CadRenderResult result) | |
{ | |
Console.WriteLine("Tracking results of exporting"); | |
if (result.IsRenderComplete) | |
return; | |
Console.WriteLine("Have some problems:"); | |
foreach (RenderResult rr in result.Failures) | |
Console.WriteLine(string.Format("{0}. {1}, {2}", idxError++, rr.RenderCode.ToString(), | |
rr.Message)); | |
}); | |
Console.WriteLine("Exporting to pdf format"); | |
image.Save(stream, pdfOptions); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
// Add desired layers | |
rasterizationOptions.Layers = new string[] { "LayerA" }; | |
// Create an instance of PdfOptions | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "conic_pyramid_layer_out.pdf"; | |
//Export the DXF to PDF | |
image.Save(MyDir, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
// Specify desired layout name | |
rasterizationOptions.Layouts = new string[] { "Model" }; | |
// Create an instance of PdfOptions | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "conic_pyramid_layout_out.pdf"; | |
//Export the DXF to PDF | |
image.Save(MyDir, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.BackgroundColor = Aspose.CAD.Color.White; | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
// Create an instance of PdfOptions | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "conic_pyramid_out.pdf"; | |
//Export the DXF to PDF | |
image.Save(MyDir, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (var image = Image.Load("NRB-GRID-BLOCK-MD-PROVALVDK-241000-162000-45400.dgn")) | |
{ | |
var vectorOptions = new CadRasterizationOptions(); | |
vectorOptions.AutomaticLayoutsScaling = true; | |
vectorOptions.BackgroundColor = Color.Black; | |
vectorOptions.PageWidth = 500; | |
vectorOptions.PageHeight = 500; | |
WmfOptions wmfOptions = new WmfOptions() | |
{ | |
VectorRasterizationOptions = vectorOptions | |
}; | |
image.Save("NRB-GRID-BLOCK-MD-PROVALVDK-241000-162000-45400.dgn.wmf", vectorOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (CadImage cadImage = (CadImage)Image.Load(fileName)) | |
{ | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.Layouts = new[] { "Model" }; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(outDir + fileName + ".pdf", pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
foreach (var file in new DirectoryInfo(MyDir).EnumerateFiles("*.dxf")) | |
{ | |
// **************************** | |
// Set new font per document | |
// **************************** | |
using (var cadImage = (CadImage)Image.Load(file.FullName)) | |
{ | |
// Iterate over the items of CadStyleTableObject | |
foreach (CadStyleTableObject style in cadImage.Styles) | |
{ | |
// Set font name | |
style.PrimaryFontName = "Broadway"; | |
} | |
cadImage.Save(file.FullName + "_font.dxf"); | |
} | |
// **************************** | |
// Hide all "straight" lines | |
// **************************** | |
using (var cadImage = (CadImage)Image.Load(file.FullName)) | |
{ | |
foreach (var entity in cadImage.Entities) | |
{ | |
// Make lines invisible | |
if (entity.TypeName == CadEntityTypeName.LINE) | |
{ | |
entity.Visible = 0; | |
} | |
} | |
cadImage.Save(file.FullName + "_lines.dxf"); | |
} | |
// **************************** | |
// Manipulations with text | |
// **************************** | |
using (var cadImage = (CadImage)Image.Load(file.FullName)) | |
{ | |
foreach (var entity in cadImage.Entities) | |
{ | |
if (entity.TypeName == CadEntityTypeName.TEXT) | |
{ | |
((CadText)entity).DefaultValue = "New text here!!! :)"; | |
break; | |
} | |
} | |
cadImage.Save(file.FullName + "_text.dxf"); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (CadImage image = (CadImage)Image.Load(fileName); | |
{ | |
ImageOptionsBase options = new JpegOptions(); | |
options.VectorRasterizationOptions = new CadRasterizationOptions() {PdfProductLocation = "C:\PDF" /*path to pdf product and licence*/ }; | |
options.VectorRasterizationOptions.PageHeight = 1000; | |
options.VectorRasterizationOptions.PageWidth = 1000; | |
image.Save(outPath, options); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
// any entities updates | |
cadImage.Save(MyDir+"conic.dxf"); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string inputFile = MyDir + "SLS-CW-CD-CE001-R01_blockClip.dxf"; | |
string outputFile = MyDir + "SLS-CW-CD-CE001-R01_blockClip.pdf"; | |
using (CadImage cadImage = (CadImage)Image.Load(inputFile)) | |
{ | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions | |
{ | |
BackgroundColor = Aspose.CAD.Color.White, | |
DrawType = Aspose.CAD.FileFormats.Cad.CadDrawTypeMode.UseObjectColor, | |
PageWidth = 1200, | |
PageHeight = 1600, | |
BorderX = 30, | |
BorderY = 5, | |
//CenterDrawing = true, | |
Layouts = new string[] { "Model" } | |
}; | |
PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions | |
{ | |
VectorRasterizationOptions = rasterizationOptions | |
}; | |
cadImage.Save(outputFile, pdfOptions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.UnitType = UnitType.Inch; | |
rasterizationOptions.DrawType = CadDrawTypeMode.UseObjectColor; | |
rasterizationOptions.BackgroundColor = Color.Black; | |
rasterizationOptions.Layouts = new string[] { "Model" }; | |
PdfOptions pdfOptions = new PdfOptions | |
{ | |
VectorRasterizationOptions = rasterizationOptions | |
}; | |
cadImage.Save(MyDir+"output.pdf", pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
// Create an instance of CadImage class and load the file. | |
using (Aspose.CAD.Image cadImage = (Aspose.CAD.Image)Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions class | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
// Set the Entities type property to Entities3D. | |
//rasterizationOptions.TypeOfEntities = TypeOfEntities.Entities3D; | |
rasterizationOptions.AutomaticLayoutsScaling = true; | |
rasterizationOptions.NoScaling = false; | |
rasterizationOptions.ContentAsBitmap = true; | |
// Set Layouts | |
rasterizationOptions.Layouts = new string[] { "Model" }; | |
// Create an instance of PDF options class | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "CADLayoutsToPDF_out.pdf"; | |
// Set Graphics options | |
rasterizationOptions.GraphicsOptions.SmoothingMode = SmoothingMode.HighQuality; | |
rasterizationOptions.GraphicsOptions.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; | |
rasterizationOptions.GraphicsOptions.InterpolationMode = InterpolationMode.HighQualityBicubic; | |
//Export to PDF by calling the Save method | |
cadImage.Save(MyDir, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
for (int i = 0; i < cadImage.Entities.Length; i++) | |
{ | |
if (cadImage.Entities[i].TypeName == CadEntityTypeName.INSERT) | |
{ | |
CadBlockEntity block = cadImage.BlockEntities[(cadImage.Entities[i] as CadInsertObject).Name]; | |
foreach (CadBaseEntity baseEntity in block.Entities) | |
{ | |
// processing of entities | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image cadImage = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 500; | |
rasterizationOptions.PageHeight = 500; | |
// rasterizationOptions.TypeOfEntities = TypeOfEntities.Entities3D; | |
rasterizationOptions.Layouts = new string[] { "Model" }; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "Export3DImagestoPDF_out.pdf"; | |
cadImage.Save(MyDir, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string fileName = MyDir + "18-12-11 9644 - site.dwf"; | |
using (Image image = Image.Load(fileName)) | |
{ | |
CadRasterizationOptions dwfRasterizationOptions = new CadRasterizationOptions(); | |
//dwfRasterizationOptions.CenterDrawing = true; | |
dwfRasterizationOptions.PageHeight = 500; | |
dwfRasterizationOptions.PageWidth = 500; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = dwfRasterizationOptions; | |
// export | |
string outPath = MyDir + "18-12-11 9644 - site.pdf"; | |
image.Save(outPath, pdfOptions); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string inputFile = MyDir + "18-12-11 9644 - site.dwf"; | |
using (Image image = Image.Load(inputFile)) | |
{ | |
BmpOptions bmpOptions = new BmpOptions(); | |
var dwfRasterizationOptions = new CadRasterizationOptions(); | |
bmpOptions.VectorRasterizationOptions = dwfRasterizationOptions; | |
//dwfRasterizationOptions.CenterDrawing = true; | |
dwfRasterizationOptions.PageHeight = 500; | |
dwfRasterizationOptions.PageWidth = 500; | |
// export | |
string outPath = MyDir + "18-12-11 9644 - site.bmp"; | |
image.Save(outPath, bmpOptions); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Run() | |
{ | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "themepark.plt"; | |
Image image = Image.Load((sourceFilePath)); | |
ImageOptionsBase imageOptions = new JpegOptions(); | |
CadRasterizationOptions options = new CadRasterizationOptions | |
{ | |
PageHeight = 500, | |
PageWidth = 1000, | |
//CenterDrawing = true | |
}; | |
imageOptions.VectorRasterizationOptions = options; | |
image.Save((MyDir+"themepark.jpg"), imageOptions); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ExportingDGN(); | |
string sourceFilePath = MyDir + "Nikon_D90_Camera.dgn"; | |
// Load an existing DGN file as CadImage. | |
using (DgnImage dgnImage = (DgnImage)Image.Load(file)) | |
{ | |
var options = new PdfOptions | |
{ | |
VectorRasterizationOptions = new CadRasterizationOptions | |
{ | |
PageWidth = 1500, | |
PageHeight = 1500, | |
CenterDrawing = true, | |
AutomaticLayoutsScaling = true, | |
BackgroundColor = Color.Black, | |
Layouts = new string[] { "1", "2", "3", "9" }//only export 4 (1,2,3 and 9) views | |
} | |
}; | |
dgnImage.Save(outFile, options); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Input and Output file paths | |
string fileName = "BlockRefDgn.dwg"; | |
string outPath = fileName + ".pdf"; | |
// Create an instance of PdfOptions class as we are exporting the DWG file to PDF format | |
Aspose.CAD.ImageOptions.PdfOptions exportOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Load any existing DWG file as image and convert it to CadImage type | |
using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Image.Load(fileName)) | |
{ | |
// Go through each entity inside the DWG file | |
foreach (Aspose.CAD.FileFormats.Cad.CadObjects.CadBaseEntity baseEntity in cadImage.Entities) | |
{ | |
// Check if entity is an image definition | |
if (baseEntity.TypeName == Aspose.CAD.FileFormats.Cad.CadConsts.CadEntityTypeName.DGNUNDERLAY) | |
{ | |
Aspose.CAD.FileFormats.Cad.CadObjects.CadDgnUnderlay dgnFile = (Aspose.CAD.FileFormats.Cad.CadObjects.CadDgnUnderlay)baseEntity; | |
// Get external reference to object | |
System.Console.WriteLine(dgnFile.UnderlayPath); | |
} | |
} | |
// Define settings for CadRasterizationOptions object | |
exportOptions.VectorRasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
{ | |
PageWidth = 1600, | |
PageHeight = 1600, | |
//CenterDrawing = true, | |
Layouts = new string[] { "Model" }, | |
AutomaticLayoutsScaling = false, | |
NoScaling = true, | |
BackgroundColor = Color.Black, | |
DrawType = Aspose.CAD.FileFormats.Cad.CadDrawTypeMode.UseObjectColor | |
}; | |
//Export the DWG to PDF by calling Save method | |
cadImage.Save(outPath, exportOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ExportingDGN(); | |
string sourceFilePath = MyDir + "Nikon_D90_Camera.dgn"; | |
// Load an existing DGN file as CadImage. | |
using (Aspose.CAD.FileFormats.Dgn.DgnImage cadImage = (Aspose.CAD.FileFormats.Dgn.DgnImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an object of CadRasterizationOptions class and define/set different properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 600; | |
rasterizationOptions.PageHeight = 300; | |
//rasterizationOptions.CenterDrawing = true; | |
rasterizationOptions.NoScaling = true; | |
rasterizationOptions.AutomaticLayoutsScaling = false; | |
// Create an object of PdfOptions class as we are converting the image to PDF format and assign CadRasterizationOptions object to it. | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
// Call the save method of the CadImage class object. | |
cadImage.Save(MyDir + "ExportDGNToPdf_out.pdf", pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ExportingDGN(); | |
string sourceFilePath = MyDir + "Nikon_D90_Camera.dgn"; | |
// Load an existing DGN file as CadImage. | |
using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an object of DgnRasterizationOptions class and define/set different properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 600; | |
rasterizationOptions.PageHeight = 300; | |
//rasterizationOptions.CenterDrawing = true; | |
rasterizationOptions.NoScaling = true; | |
rasterizationOptions.AutomaticLayoutsScaling = false; | |
// Create an object of JpegOptions class as we are converting the DGN to jpeg and assign DgnRasterizationOptions object to it. | |
Aspose.CAD.ImageOptionsBase options = new Aspose.CAD.ImageOptions.JpegOptions(); | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// Call the save method of the CadImage class object. | |
cadImage.Save(MyDir + "ExportDGNToRasterImage_out.pdf", options); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ExportingDGN(); | |
string sourceFilePath = MyDir + "Nikon_D90_Camera.dgn"; | |
// Load an existing DGN file as CadImage. | |
using (DgnImage dgnImage = (DgnImage)Image.Load(file)) | |
{ | |
foreach (DgnDrawingElementBase element in dgnImage.Elements) | |
{ | |
switch (element.Metadata.Type) | |
{ | |
case DgnElementType.Line: | |
case DgnElementType.Ellipse: | |
case DgnElementType.Curve: | |
case DgnElementType.BSplineCurveHeader: | |
case DgnElementType.Arc: | |
case DgnElementType.Shape: | |
case DgnElementType.PolyLine: | |
case DgnElementType.TextNode: | |
case DgnElementType.Text: | |
case DgnElementType.ComplexShapeHeader: | |
case DgnElementType.ComplexChainHeader: | |
{ | |
//previously supported entities, now supported also for 3D | |
break; | |
} | |
case DgnElementType.SolidHeader3D: | |
case DgnElementType.Cone: | |
case DgnElementType.CellHeader: | |
{ | |
//supported 3D entities | |
break; | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ExportingDGN(); | |
string sourceFilePath = MyDir + "Nikon_D90_Camera.dgn"; | |
// Load an existing DGN file as CadImage. | |
using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an object of DgnRasterizationOptions class and define/set different properties | |
Aspose.CAD.ImageOptions.DgnRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.DgnRasterizationOptions(); | |
rasterizationOptions.PageWidth = 600; | |
rasterizationOptions.PageHeight = 300; | |
rasterizationOptions.CenterDrawing = true; | |
rasterizationOptions.NoScaling = true; | |
rasterizationOptions.AutomaticLayoutsScaling = false; | |
// Create an object of JpegOptions class as we are converting the DGN to jpeg and assign DgnRasterizationOptions object to it. | |
Aspose.CAD.ImageOptionsBase options = new Aspose.CAD.ImageOptions.JpegOptions(); | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// Call the save method of the CadImage class object. | |
cadImage.Save(MyDir + "ExportDGNToRasterImage_out.pdf", options); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Setfile name path as other examples | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "example.ifc"; | |
using (IfcImage cadImage = (IfcImage)Image.Load(sourceFilePath)) | |
{ | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
// rasterizationOptions.CenterDrawing = true; | |
rasterizationOptions.PageWidth = 100; | |
rasterizationOptions.PageHeight = 100; | |
PngOptions pngOptions = new PngOptions(); | |
pngOptions.VectorRasterizationOptions = rasterizationOptions; | |
//Set output path as well | |
string outPath = sourceFilePath + ".png"; | |
cadImage.Save(outPath, pngOptions); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_IGESDrawings(); | |
string sourceFilePath = MyDir + "figa2.igs"; | |
using (Image cadImage = Image.Load(sourceFilePath)) | |
{ | |
CadRasterizationOptions options = new CadRasterizationOptions | |
{ | |
PageHeight = 1000, | |
PageWidth = 1000, | |
//CenterDrawing = true, | |
}; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = options; | |
cadImage.Save(MyDir+ "figa2.pdf", pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_PLTDrawings(); | |
string sourceFilePath = MyDir + "50states.plt"; | |
using (Image cadImage = Image.Load(sourceFilePath)) | |
{ | |
ImageOptionsBase imageOptions = new JpegOptions(); | |
CadRasterizationOptions options = new CadRasterizationOptions | |
{ | |
PageHeight = 500, | |
PageWidth = 1000, | |
//CenterDrawing = true | |
}; | |
imageOptions.VectorRasterizationOptions = options; | |
cadImage.Save(MyDir+ "50states.jpg", imageOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_PLTDrawings(); | |
string sourceFilePath = MyDir + "50states.plt"; | |
using (Image cadImage = Image.Load(sourceFilePath)) | |
{ | |
CadRasterizationOptions options = new CadRasterizationOptions | |
{ | |
PageHeight = 1600, | |
PageWidth = 1600, | |
//CenterDrawing = true, | |
DrawType= CadDrawTypeMode.UseObjectColor, | |
BackgroundColor=Color.White | |
}; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = options; | |
cadImage.Save(MyDir+ "50states.pdf", pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "galeon.stl"; | |
using (var cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
var rasterizationOptions = new CadRasterizationOptions(); | |
//rasterizationOptions.CenterDrawing = true; | |
rasterizationOptions.PageWidth = 100; | |
rasterizationOptions.PageHeight = 100; | |
PngOptions pngOptions = new PngOptions(); | |
pngOptions.VectorRasterizationOptions = rasterizationOptions; | |
string outPath = sourceFilePath + ".png"; | |
cadImage.Save(outPath, pngOptions); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-.NET | |
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir + "visualization_-_conference_room.dwg"; | |
using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.Layouts = new string[] { "Model" }; | |
rasterizationOptions.NoScaling = true; | |
// note: preserving some empty borders around part of image is the responsibility of customer | |
// top left point of region to draw | |
Point topLeft = new Point(500, 1000); | |
double width = 3108; | |
double height = 2489; | |
CadVportTableObject newView = new CadVportTableObject(); | |
newView.Name = new CadStringParameter(); | |
newView.Name.Init("*Active"); | |
newView.CenterPoint.X = topLeft.X + width / 2f; | |
newView.CenterPoint.Y = topLeft.Y - height / 2f; | |
newView.ViewHeight.Value = height; | |
newView.ViewAspectRatio.Value = width / height; | |
for (int i = 0; i < cadImage.ViewPorts.Count; i++) | |
{ | |
CadVportTableObject currentView = (CadVportTableObject)(cadImage.ViewPorts[i]); | |
if (cadImage.ViewPorts.Count == 1 || string.Equals(currentView.Name.Value.ToLowerInvariant(), "*active")) | |
{ | |
cadImage.ViewPorts[i] = newView; | |
break; | |
} | |
} | |
// Create an instance of PdfOptions | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "ConvertDWGToPDFBySupplyingCoordinates_out.pdf"; | |
//Export the DWG to PDF | |
cadImage.Save(MyDir, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-.NET | |
string dwgPathToFile = MyDir + "Drawing11.dwg"; | |
CadImage cadImage1 = (CadImage)Image.Load(dwgPathToFile); | |
CadRasterImageDef cadRasterImageDef = new CadRasterImageDef("road-sign-custom.png", 640, 562); | |
cadRasterImageDef.ObjectHandle = "A3B4"; | |
Cad3DPoint insertionPoint = new Cad3DPoint(26.77, 22.35); | |
Cad3DPoint uVector = new Cad3DPoint(0.0061565450840500831, 0); | |
Cad3DPoint vVector = new Cad3DPoint(0, 0.0061565450840500822); | |
CadRasterImage cadRasterImage = new CadRasterImage(cadRasterImageDef, insertionPoint, uVector, vVector); | |
cadRasterImage.ImageDefReference = "A3B4"; | |
cadRasterImage.DisplayFlags = 7; | |
cadRasterImage.ClippingState = 0; | |
cadRasterImage.ClipBoundaryVertexList.Add(new Cad2DPoint(-0.5, 0.5)); | |
cadRasterImage.ClipBoundaryVertexList.Add(new Cad2DPoint(639.5, 561.5)); | |
CadImage cadImage = (CadImage)cadImage1; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(cadRasterImage); | |
List<CadBaseObject> list = new List<CadBaseObject>(cadImage.Objects); | |
list.Add(cadRasterImageDef); | |
cadImage.Objects = list.ToArray(); | |
PdfOptions pdfOptions = new PdfOptions(); | |
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions(); | |
pdfOptions.VectorRasterizationOptions = cadRasterizationOptions; | |
cadRasterizationOptions.DrawType = CadDrawTypeMode.UseObjectColor; | |
cadRasterizationOptions.PageHeight = 1600; | |
cadRasterizationOptions.PageWidth = 1600; | |
cadRasterizationOptions.Layouts = new string[] { "Model" }; | |
cadImage1.Save(MyDir + "export2.pdf", pdfOptions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-.NET | |
// The path to the documents directory. | |
string WorkingDir = RunExamples.GetDataDir_DXFDrawings(); | |
string fileName = "conic_pyramid.dxf"; | |
string inputFile = WorkingDir + fileName; | |
string outFile = WorkingDir + "AddMetadata_out.dxf"; | |
using (var cadImage = (CadImage)Image.Load(inputFile)) | |
{ | |
cadImage.Header.CustomProperties.Add("CUSTOM_PROPERTY_1", "Custom property test 1"); | |
cadImage.Header.CustomProperties.Add("CUSTOM_PROPERTY_2", "Custom property test 2"); | |
cadImage.Header.CustomProperties.Add("CUSTOM_PROPERTY_3", "Custom property test 3"); | |
cadImage.Save(outFile); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-.NET | |
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string inputFile = MyDir + "SLS-CW-CD-CE001-R01_blockClip.dxf"; | |
string outputFile = MyDir + "SLS-CW-CD-CE001-R01_blockClip.pdf"; | |
using (CadImage cadImage = (CadImage)Image.Load(inputFile)) | |
{ | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions | |
{ | |
BackgroundColor = Aspose.CAD.Color.White, | |
DrawType = Aspose.CAD.FileFormats.Cad.CadDrawTypeMode.UseObjectColor, | |
PageWidth = 1200, | |
PageHeight = 1600, | |
Margins = new Margins | |
{ | |
Top = 5, | |
Right = 30, | |
Bottom = 5, | |
Left = 30 | |
}, | |
Layouts = new string[] { "Model" } | |
}; | |
PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions | |
{ | |
VectorRasterizationOptions = rasterizationOptions | |
}; | |
cadImage.Save(outputFile, pdfOptions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Set path of the license file, i.e. c:\temp\ | |
Dim dataDir As String = "c:\temp\" | |
Dim license As New License() | |
license.SetLicense(dataDir & Convert.ToString("Aspose.CAD.lic")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Set path of the license file, i.e. c:\temp\ | |
Dim dataDir As String = "c:\temp\" | |
' Load an existing file in the stream | |
Dim LicStream As New FileStream(dataDir & Convert.ToString("Aspose.CAD.lic"), FileMode.Open) | |
Dim license As New License() | |
license.SetLicense(LicStream) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Create an instance of CAD Metered class | |
Dim metered As New Aspose.CAD.Metered() | |
' Access the setMeteredKey property and pass public and private keys as parameters | |
metered.SetMeteredKey("*****", "*****") | |
' Get metered data amount before calling API | |
Dim amountbefore As Decimal = Aspose.CAD.Metered.GetConsumptionQuantity() | |
' Display information | |
Console.WriteLine("Amount Consumed Before: " + amountbefore.ToString()) | |
' Do processing | |
'Aspose.CAD.FileFormats.Cad.CadImage image = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.load("BlockRefDgn.dwg"); | |
' Get metered data amount After calling API | |
Dim amountafter As Decimal = Aspose.CAD.Metered.GetConsumptionQuantity() | |
' Display information | |
Console.WriteLine("Amount Consumed After: " + amountafter.ToString()) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-.NET | |
' Create an instance of CAD Metered class | |
Dim metered As New Aspose.CAD.Metered() | |
' Access the setMeteredKey property and pass public and private keys as parameters | |
metered.SetMeteredKey("*****", "*****") | |
' Get metered data amount before calling API | |
Dim amountbefore As Decimal = Aspose.CAD.Metered.GetConsumptionQuantity() | |
' Display information | |
Console.WriteLine("Amount Consumed Before: " + amountbefore.ToString()) | |
' Do processing | |
'Aspose.CAD.FileFormats.Cad.CadImage image = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.load("BlockRefDgn.dwg"); | |
' Get metered data amount After calling API | |
Dim amountafter As Decimal = Aspose.CAD.Metered.GetConsumptionQuantity() | |
' Display information | |
Console.WriteLine("Amount Consumed After: " + amountafter.ToString()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_ConvertingCAD() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("sample.dwg") | |
' Load a CAD drawing in an instance of Image | |
Using image = Aspose.CAD.Image.Load(sourceFilePath) | |
' Create an instance of BmpOptions class | |
Dim bmpOptions As New Aspose.CAD.ImageOptions.BmpOptions() | |
' Create an instance of CadRasterizationOptions and set its various properties | |
Dim cadRasterizationOptions As New Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
bmpOptions.VectorRasterizationOptions = cadRasterizationOptions | |
cadRasterizationOptions.CenterDrawing = True | |
' Set the UnitType property | |
cadRasterizationOptions.UnitType = Aspose.CAD.ImageOptions.UnitType.Centimenter | |
' Set the layouts property | |
cadRasterizationOptions.Layouts = New String() {"Model"} | |
' Export layout to BMP format | |
Dim outPath As String = sourceFilePath + ".bmp" | |
image.Save(outPath, bmpOptions) | |
End Using | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_ConvertingCAD() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("sample.dwg") | |
' Load a CAD drawing in an instance of Image | |
Using image = Aspose.CAD.Image.Load(sourceFilePath) | |
' Create an instance of BmpOptions class | |
Dim bmpOptions As New Aspose.CAD.ImageOptions.BmpOptions() | |
' Create an instance of CadRasterizationOptions and set its various properties | |
Dim cadRasterizationOptions As New Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
bmpOptions.VectorRasterizationOptions = cadRasterizationOptions | |
cadRasterizationOptions.CenterDrawing = True | |
' Set the layouts property | |
cadRasterizationOptions.Layouts = New String() {"Model"} | |
' Export layout to BMP format | |
Dim outPath As String = sourceFilePath + ".bmp" | |
image.Save(outPath, bmpOptions) | |
End Using | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-.NET | |
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_ConvertingCAD() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("sample.dwg") | |
' Load a CAD drawing in an instance of Image | |
Using image = Aspose.CAD.Image.Load(sourceFilePath) | |
' Create an instance of BmpOptions class | |
Dim bmpOptions As New Aspose.CAD.ImageOptions.BmpOptions() | |
' Create an instance of CadRasterizationOptions and set its various properties | |
Dim cadRasterizationOptions As New Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
bmpOptions.VectorRasterizationOptions = cadRasterizationOptions | |
cadRasterizationOptions.CenterDrawing = True | |
' Set the UnitType property | |
cadRasterizationOptions.UnitType = Aspose.CAD.ImageOptions.UnitType.Centimenter | |
' Set the layouts property | |
cadRasterizationOptions.Layouts = New String() {"Model"} | |
' Export layout to BMP format | |
Dim outPath As String = sourceFilePath + ".bmp" | |
image.Save(outPath, bmpOptions) | |
End Using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-.NET | |
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_ConvertingCAD() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("sample.dwg") | |
' Load a CAD drawing in an instance of Image | |
Using image = Aspose.CAD.Image.Load(sourceFilePath) | |
' Create an instance of BmpOptions class | |
Dim bmpOptions As New Aspose.CAD.ImageOptions.BmpOptions() | |
' Create an instance of CadRasterizationOptions and set its various properties | |
Dim cadRasterizationOptions As New Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
bmpOptions.VectorRasterizationOptions = cadRasterizationOptions | |
cadRasterizationOptions.CenterDrawing = True | |
' Set the layouts property | |
cadRasterizationOptions.Layouts = New String() {"Model"} | |
' Export layout to BMP format | |
Dim outPath As String = sourceFilePath + ".bmp" | |
image.Save(outPath, bmpOptions) | |
End Using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_ConvertingCAD() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("conic_pyramid.dxf") | |
' Load a CAD drawing in an instance of Image | |
Using image = Aspose.CAD.Image.Load(sourceFilePath) | |
' Create an instance of CadRasterizationOptions | |
Dim rasterizationOptions = New Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
' Set image width & height | |
rasterizationOptions.PageWidth = 500 | |
rasterizationOptions.PageHeight = 500 | |
' Set the drawing to render at the center of image | |
rasterizationOptions.CenterDrawing = True | |
' Add the layer name to the CadRasterizationOptions's layer list | |
rasterizationOptions.Layers.Add("0") | |
' Most of the CAD drawings have a layer by name 0, you may specify any name | |
' Create an instance of JpegOptions (or any ImageOptions for raster formats) | |
Dim options = New Aspose.CAD.ImageOptions.JpegOptions() | |
' Set VectorRasterizationOptions property to the instance of CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions | |
' Export each layer to Jpeg format | |
MyDir = MyDir & Convert.ToString("CADLayersToRasterImageFormats_out.jpg") | |
image.Save(MyDir, options) | |
End Using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_ConvertingCAD() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("conic_pyramid.dxf") | |
' Load a CAD drawing in an instance of CadImage | |
Using image = DirectCast(Aspose.CAD.Image.Load(sourceFilePath), Aspose.CAD.FileFormats.Cad.CadImage) | |
' Create an instance of CadRasterizationOptions | |
Dim rasterizationOptions = New Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
' Set image width & height | |
rasterizationOptions.PageWidth = 500 | |
rasterizationOptions.PageHeight = 500 | |
' Set the drawing to render at the center of image | |
rasterizationOptions.CenterDrawing = True | |
' Get the layers in an instance of CadLayersDictionary | |
Dim layers = image.Layers | |
' Iterate over the layers | |
For Each layer In layers.ValuesTyped | |
' Display layer name for tracking | |
Console.WriteLine("Start with " + layer.Name) | |
' Add the layer name to the CadRasterizationOptions's layer list | |
rasterizationOptions.Layers.Add(layer.Name) | |
' Create an instance of JpegOptions (or any ImageOptions for raster formats) | |
Dim options = New Aspose.CAD.ImageOptions.JpegOptions() | |
' Set VectorRasterizationOptions property to the instance of CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions | |
' Export each layer to Jpeg format | |
image.Save(layer.Name + "_out.jpg", options) | |
Next | |
End Using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_ConvertingCAD() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("conic_pyramid.dxf") | |
Using image As Aspose.CAD.Image = Aspose.CAD.Image.Load(sourceFilePath) | |
' Create an instance of CadRasterizationOptions | |
Dim rasterizationOptions As New Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
' Set page width & height | |
rasterizationOptions.PageWidth = 1200 | |
rasterizationOptions.PageHeight = 1200 | |
' Create an instance of PngOptions for the resultant image | |
Dim options As ImageOptionsBase = New Aspose.CAD.ImageOptions.PngOptions() | |
' Set rasterization options | |
options.VectorRasterizationOptions = rasterizationOptions | |
MyDir = MyDir & Convert.ToString("conic_pyramid_raster_image_out.png") | |
' Save resultant image | |
image.Save(MyDir, options) | |
End Using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_ConvertingCAD() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("conic_pyramid.dxf") | |
Using image As Aspose.CAD.Image = Aspose.CAD.Image.Load(sourceFilePath) | |
' Create an instance of CadRasterizationOptions | |
Dim rasterizationOptions As New Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
' Set page width & height | |
rasterizationOptions.PageWidth = 1200 | |
rasterizationOptions.PageHeight = 1200 | |
' Specify a list of layout names | |
rasterizationOptions.Layouts = New String() {"Model", "Layout1"} | |
' Create an instance of TiffOptions for the resultant image | |
Dim options As ImageOptionsBase = New Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.[Default]) | |
' Set rasterization options | |
options.VectorRasterizationOptions = rasterizationOptions | |
MyDir = MyDir & Convert.ToString("conic_pyramid_layoutstorasterimage_out.tiff") | |
' Save resultant image | |
image.Save(MyDir, options) | |
End Using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_ConvertingCAD() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("conic_pyramid.dxf") | |
Using image As Aspose.CAD.Image = Aspose.CAD.Image.Load(sourceFilePath) | |
Dim stream As New MemoryStream() | |
Dim pdfOptions As New Aspose.CAD.ImageOptions.PdfOptions() | |
' Create an instance of CadRasterizationOptions and set its various properties | |
Dim cadRasterizationOptions As New Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
pdfOptions.VectorRasterizationOptions = cadRasterizationOptions | |
cadRasterizationOptions.PageWidth = 800 | |
cadRasterizationOptions.PageHeight = 600 | |
image.Save(stream, pdfOptions) | |
End Using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_ConvertingCAD() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("conic_pyramid.dxf") | |
Using image As Aspose.CAD.Image = Aspose.CAD.Image.Load(sourceFilePath) | |
Dim cadImage As Aspose.CAD.FileFormats.Cad.CadImage = DirectCast(image, Aspose.CAD.FileFormats.Cad.CadImage) | |
Dim layouts As Aspose.CAD.FileFormats.Cad.CadLayoutDictionary = cadImage.Layouts | |
For Each layout As Aspose.CAD.FileFormats.Cad.CadObjects.CadLayout In layouts.Values | |
Console.WriteLine("Layout " + layout.LayoutName) | |
Next | |
End Using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_ConvertingCAD() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("conic_pyramid.dxf") | |
Using image As Aspose.CAD.Image = Aspose.CAD.Image.Load(sourceFilePath) | |
' Create an instance of CadRasterizationOptions and set its various properties | |
Dim rasterizationOptions As New Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
rasterizationOptions.PageWidth = 1600 | |
rasterizationOptions.PageHeight = 1600 | |
' Set Auto Layout Scaling | |
rasterizationOptions.AutomaticLayoutsScaling = True | |
' Create an instance of PdfOptions | |
Dim pdfOptions As New Aspose.CAD.ImageOptions.PdfOptions() | |
' Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions | |
MyDir = MyDir & Convert.ToString("result_out.pdf") | |
' Export the CAD to PDF | |
image.Save(MyDir, pdfOptions) | |
End Using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_ConvertingCAD() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("conic_pyramid.dxf") | |
Using image As Aspose.CAD.Image = Aspose.CAD.Image.Load(sourceFilePath) | |
' Create an instance of CadRasterizationOptions and set its various properties | |
Dim rasterizationOptions As New Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
rasterizationOptions.PageWidth = 1600 | |
rasterizationOptions.PageHeight = 1600 | |
rasterizationOptions.BackgroundColor = Aspose.CAD.Color.Beige | |
rasterizationOptions.DrawType = Aspose.CAD.FileFormats.Cad.CadDrawTypeMode.UseDrawColor | |
rasterizationOptions.DrawColor = Aspose.CAD.Color.Blue | |
' Create an instance of PdfOptions | |
Dim pdfOptions As New Aspose.CAD.ImageOptions.PdfOptions() | |
' Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions | |
' Export CAD to PDF | |
image.Save(MyDir & Convert.ToString("result_out.pdf"), pdfOptions) | |
' Create an instance of TiffOptions | |
Dim tiffOptions As New Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.[Default]) | |
' Set the VectorRasterizationOptions property | |
tiffOptions.VectorRasterizationOptions = rasterizationOptions | |
' Export CAD to TIFF | |
image.Save(MyDir & Convert.ToString("result_out.tiff"), tiffOptions) | |
End Using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_ConvertingCAD() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("conic_pyramid.dxf") | |
Using image As Aspose.CAD.Image = Aspose.CAD.Image.Load(sourceFilePath) | |
' Create an instance of CadRasterizationOptions and set its various properties | |
Dim rasterizationOptions As New Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
rasterizationOptions.PageWidth = 1600 | |
rasterizationOptions.PageHeight = 1600 | |
rasterizationOptions.ScaleMethod = Aspose.CAD.FileFormats.Cad.ScaleType.GrowToFit | |
' Create an instance of PdfOptions | |
Dim pdfOptions As New Aspose.CAD.ImageOptions.PdfOptions() | |
' Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions | |
' Export CAD to PDF | |
image.Save(MyDir & Convert.ToString("result_out.pdf"), pdfOptions) | |
' Create an instance of TiffOptions | |
Dim tiffOptions As New Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.[Default]) | |
' Set the VectorRasterizationOptions property | |
tiffOptions.VectorRasterizationOptions = rasterizationOptions | |
' Export CAD to TIFF | |
image.Save(MyDir & Convert.ToString("result_out.tiff"), tiffOptions) | |
End Using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_ConvertingCAD() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("conic_pyramid.dxf") | |
' Load a CAD drawing in an instance of CadImage | |
Using cadImage As Aspose.CAD.FileFormats.Cad.CadImage = DirectCast(Aspose.CAD.Image.Load(sourceFilePath), Aspose.CAD.FileFormats.Cad.CadImage) | |
' Specify the font for one particular style | |
cadImage.Styles("Roman").PrimaryFontName = "Arial" | |
End Using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_ConvertingCAD() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("conic_pyramid.dxf") | |
' Load a CAD drawing in an instance of CadImage | |
Using cadImage As Aspose.CAD.FileFormats.Cad.CadImage = DirectCast(Aspose.CAD.Image.Load(sourceFilePath), Aspose.CAD.FileFormats.Cad.CadImage) | |
' Iterate over the items of CadStyleDictionary | |
For Each style In cadImage.Styles.ValuesTyped | |
' Set the font name | |
style.PrimaryFontName = "Arial" | |
Next style | |
End Using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Input file name and path | |
Dim fileName As String = "BlockRefDgn.dwg" | |
' Load an existing DWG file and convert it into CadImage | |
Using image1 As Aspose.CAD.FileFormats.Cad.CadImage = DirectCast(Image.Load(fileName), Aspose.CAD.FileFormats.Cad.CadImage) | |
' Go through each entity inside the DWG file | |
For Each entity As Aspose.CAD.FileFormats.Cad.CadObjects.CadBaseEntity In image1.Entities | |
' Check if entity is of CadDgnUnderlay type | |
If TypeOf entity Is Aspose.CAD.FileFormats.Cad.CadObjects.CadDgnUnderlay Then | |
' Access different underlay flags | |
Dim underlay As Aspose.CAD.FileFormats.Cad.CadObjects.CadUnderlay = TryCast(entity, Aspose.CAD.FileFormats.Cad.CadObjects.CadUnderlay) | |
Console.WriteLine(underlay.UnderlayPath) | |
Console.WriteLine(underlay.UnderlayName) | |
Console.WriteLine(underlay.InsertionPoint.X) | |
Console.WriteLine(underlay.InsertionPoint.Y) | |
Console.WriteLine(underlay.RotationAngle) | |
Console.WriteLine(underlay.ScaleX) | |
Console.WriteLine(underlay.ScaleY) | |
Console.WriteLine(underlay.ScaleZ) | |
Console.WriteLine((underlay.Flags And Aspose.CAD.FileFormats.Cad.CadObjects.UnderlayFlags.UnderlayIsOn) = Aspose.CAD.FileFormats.Cad.CadObjects.UnderlayFlags.UnderlayIsOn) | |
Console.WriteLine((underlay.Flags And Aspose.CAD.FileFormats.Cad.CadObjects.UnderlayFlags.ClippingIsOn) = Aspose.CAD.FileFormats.Cad.CadObjects.UnderlayFlags.ClippingIsOn) | |
Console.WriteLine((underlay.Flags And Aspose.CAD.FileFormats.Cad.CadObjects.UnderlayFlags.Monochrome) <> Aspose.CAD.FileFormats.Cad.CadObjects.UnderlayFlags.Monochrome) | |
Exit For | |
End If | |
Next | |
End Using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_DWGDrawings() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("visualization_-_conference_room.dwg") | |
Using image As Aspose.CAD.Image = Aspose.CAD.Image.Load(sourceFilePath) | |
' Create an instance of CadRasterizationOptions and set its various properties | |
Dim rasterizationOptions As New Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
rasterizationOptions.PageWidth = 1600 | |
rasterizationOptions.PageHeight = 1600 | |
' Specify desired layout name | |
rasterizationOptions.Layouts = New String() {"Layout1"} | |
' Create an instance of PdfOptions | |
Dim pdfOptions As New Aspose.CAD.ImageOptions.PdfOptions() | |
' Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions | |
MyDir = MyDir & Convert.ToString("ExportSpecificLayoutToPDF_out.pdf") | |
' Export the DWG to PDF | |
image.Save(MyDir, pdfOptions) | |
End Using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_DWGDrawings() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("Bottom_plate.dwg") | |
Using image As Aspose.CAD.Image = Aspose.CAD.Image.Load(sourceFilePath) | |
' Create an instance of CadRasterizationOptions and set its various properties | |
Dim rasterizationOptions As New Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
rasterizationOptions.BackgroundColor = Aspose.CAD.Color.White | |
rasterizationOptions.PageWidth = 1600 | |
rasterizationOptions.PageHeight = 1600 | |
' Create an instance of PdfOptions | |
Dim pdfOptions As New Aspose.CAD.ImageOptions.PdfOptions() | |
' Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions | |
MyDir = MyDir & Convert.ToString("Bottom_plate_out.pdf") | |
' Export the DWG to PDF | |
image.Save(MyDir, pdfOptions) | |
End Using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_DWGDrawings() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("sample.dwg") | |
' Load an existing DWG file as CadImage. | |
Using cadImage As Aspose.CAD.FileFormats.Cad.CadImage = DirectCast(Aspose.CAD.Image.Load(sourceFilePath), Aspose.CAD.FileFormats.Cad.CadImage) | |
System.Console.WriteLine(cadImage.BlockEntities("*MODEL_SPACE").XRefPathName) | |
End Using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_DWGDrawings() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("sample.dwg") | |
' Load an existing DWG file as CadImage. | |
Using cadImage As Aspose.CAD.FileFormats.Cad.CadImage = DirectCast(Aspose.CAD.Image.Load(sourceFilePath), Aspose.CAD.FileFormats.Cad.CadImage) | |
' Search for text in the file | |
For Each entity As Aspose.CAD.FileFormats.Cad.CadObjects.CadBaseEntity In cadImage.Entities | |
' Please, note: we iterate through CadText entities here, but some other entities may contain text also, e.g. CadMText and others | |
If entity.[GetType]() = GetType(Aspose.CAD.FileFormats.Cad.CadObjects.CadText) Then | |
Dim text As Aspose.CAD.FileFormats.Cad.CadObjects.CadText = DirectCast(entity, Aspose.CAD.FileFormats.Cad.CadObjects.CadText) | |
System.Console.WriteLine(text.DefaultValue) | |
End If | |
Next | |
' Search for text on specific layout get all layout names and link each layout with corresponding block with entities | |
Dim layouts As Aspose.CAD.FileFormats.Cad.CadLayoutDictionary = cadImage.Layouts | |
Dim layoutNames As String() = New String(layouts.Count - 1) {} | |
Dim i As Integer = 0 | |
For Each layout As Aspose.CAD.FileFormats.Cad.CadObjects.CadLayout In layouts.Values | |
layoutNames(i) = layout.LayoutName | |
System.Console.WriteLine("Layout " + layout.LayoutName + " is found") | |
' Find block, applicable for DWG only | |
Dim blockTableObjectReference As Aspose.CAD.FileFormats.Cad.CadTables.CadBlockTableObject = Nothing | |
For Each tableObject As Aspose.CAD.FileFormats.Cad.CadTables.CadBlockTableObject In cadImage.BlocksTables | |
If String.Equals(tableObject.HardPointerToLayout, layout.ObjectHandle) Then | |
blockTableObjectReference = tableObject | |
Exit For | |
End If | |
Next | |
' Collection cadBlockEntity.Entities contains information about all entities on specific layout if this collection has no elements it means layout is a copy of Model layout and contains the same entities | |
Dim cadBlockEntity As Aspose.CAD.FileFormats.Cad.CadObjects.CadBlockEntity = cadImage.BlockEntities(blockTableObjectReference.BlockName) | |
Next | |
' Export to pdf | |
Dim rasterizationOptions As New Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
rasterizationOptions.PageWidth = 1600 | |
rasterizationOptions.PageHeight = 1600 | |
rasterizationOptions.AutomaticLayoutsScaling = True | |
rasterizationOptions.CenterDrawing = True | |
' Please, note: if cadBlockEntity collection mentioned above (for dwg) for selected layout or entitiesOnLayouts collection by layout's BlockTableRecordHandle (for dxf) is empty - export result file will be empty and you should draw Model layout instead | |
rasterizationOptions.Layouts = New String() {"Layout1"} | |
Dim pdfOptions As New Aspose.CAD.ImageOptions.PdfOptions() | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions | |
cadImage.Save(MyDir & Convert.ToString("SearchText_out.pdf"), pdfOptions) | |
End Using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_DXFDrawings() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("conic_pyramid.dxf") | |
Using image As Aspose.CAD.Image = Aspose.CAD.Image.Load(sourceFilePath) | |
' Create an instance of CadRasterizationOptions and set its various properties | |
Dim rasterizationOptions As New Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
rasterizationOptions.PageWidth = 1600 | |
rasterizationOptions.PageHeight = 1600 | |
' Add desired layers | |
rasterizationOptions.Layers.Add("0") | |
' Create an instance of PdfOptions | |
Dim pdfOptions As New Aspose.CAD.ImageOptions.PdfOptions() | |
' Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions | |
MyDir = MyDir & Convert.ToString("conic_pyramid_layer_out.pdf") | |
' Export the DXF to PDF | |
image.Save(MyDir, pdfOptions) | |
End Using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_DXFDrawings() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("conic_pyramid.dxf") | |
Using image As Aspose.CAD.Image = Aspose.CAD.Image.Load(sourceFilePath) | |
' Create an instance of CadRasterizationOptions and set its various properties | |
Dim rasterizationOptions As New Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
rasterizationOptions.PageWidth = 1600 | |
rasterizationOptions.PageHeight = 1600 | |
' Specify desired layout name | |
rasterizationOptions.Layouts = New String() {"Model"} | |
' Create an instance of PdfOptions | |
Dim pdfOptions As New Aspose.CAD.ImageOptions.PdfOptions() | |
' Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions | |
MyDir = MyDir & Convert.ToString("conic_pyramid_layout_out.pdf") | |
' Export the DXF to PDF | |
image.Save(MyDir, pdfOptions) | |
End Using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_DXFDrawings() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("conic_pyramid.dxf") | |
Using image As Aspose.CAD.Image = Aspose.CAD.Image.Load(sourceFilePath) | |
' Create an instance of CadRasterizationOptions and set its various properties | |
Dim rasterizationOptions As New Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
rasterizationOptions.BackgroundColor = Aspose.CAD.Color.White | |
rasterizationOptions.PageWidth = 1600 | |
rasterizationOptions.PageHeight = 1600 | |
' Create an instance of PdfOptions | |
Dim pdfOptions As New Aspose.CAD.ImageOptions.PdfOptions() | |
' Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions | |
MyDir = MyDir & Convert.ToString("conic_pyramid_out.pdf") | |
' Export the DXF to PDF | |
image.Save(MyDir, pdfOptions) | |
End Using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_ConvertingCAD() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("conic_pyramid.dxf") | |
' Create an instance of CadImage class and load the file. | |
Using cadImage As Aspose.CAD.Image = DirectCast(Image.Load(sourceFilePath), Aspose.CAD.Image) | |
' Create an instance of CadRasterizationOptions class | |
Dim rasterizationOptions As New CadRasterizationOptions() | |
rasterizationOptions.PageWidth = 1600 | |
rasterizationOptions.PageHeight = 1600 | |
' Set the Entities type property to Entities3D. | |
rasterizationOptions.TypeOfEntities = TypeOfEntities.Entities3D | |
rasterizationOptions.ScaleMethod = ScaleType.GrowToFit | |
rasterizationOptions.ContentAsBitmap = True | |
' Set Layouts | |
rasterizationOptions.Layouts = New String() {"Model"} | |
' Create an instance of PDF options class | |
Dim pdfOptions As New PdfOptions() | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions | |
MyDir = MyDir & Convert.ToString("CADLayoutsToPDF_out.pdf") | |
' Set Graphics options | |
rasterizationOptions.GraphicsOptions.SmoothingMode = SmoothingMode.HighQuality | |
rasterizationOptions.GraphicsOptions.TextRenderingHint = TextRenderingHint.AntiAliasGridFit | |
rasterizationOptions.GraphicsOptions.InterpolationMode = InterpolationMode.HighQualityBicubic | |
' Export to PDF by calling the Save method | |
cadImage.Save(MyDir, pdfOptions) | |
End Using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_ConvertingCAD() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("conic_pyramid.dxf") | |
Using cadImage As Aspose.CAD.Image = Aspose.CAD.Image.Load(sourceFilePath) | |
Dim rasterizationOptions As New Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
rasterizationOptions.PageWidth = 500 | |
rasterizationOptions.PageHeight = 500 | |
rasterizationOptions.TypeOfEntities = TypeOfEntities.Entities3D | |
rasterizationOptions.Layouts = New String() {"Model"} | |
Dim pdfOptions As New PdfOptions() | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions | |
MyDir = MyDir & Convert.ToString("Export3DImagestoPDF_out.pdf") | |
cadImage.Save(MyDir, pdfOptions) | |
End Using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Input and Output file paths | |
Dim fileName As String = "BlockRefDgn.dwg" | |
Dim outPath As String = fileName & Convert.ToString(".pdf") | |
' Create an instance of PdfOptions class as we are exporting the DWG file to PDF format | |
Dim exportOptions As New Aspose.CAD.ImageOptions.PdfOptions() | |
' Load any existing DWG file as image and convert it to CadImage type | |
Using cadImage As Aspose.CAD.FileFormats.Cad.CadImage = DirectCast(Image.Load(fileName), Aspose.CAD.FileFormats.Cad.CadImage) | |
' Go through each entity inside the DWG file | |
For Each baseEntity As Aspose.CAD.FileFormats.Cad.CadObjects.CadBaseEntity In cadImage.Entities | |
' Check if entity is an image definition | |
If baseEntity.TypeName = Aspose.CAD.FileFormats.Cad.CadConsts.CadEntityTypeName.DGNUNDERLAY Then | |
Dim dgnFile As Aspose.CAD.FileFormats.Cad.CadObjects.CadDgnUnderlay = DirectCast(baseEntity, Aspose.CAD.FileFormats.Cad.CadObjects.CadDgnUnderlay) | |
' Get external reference to object | |
System.Console.WriteLine(dgnFile.UnderlayPath) | |
End If | |
Next | |
' Define settings for CadRasterizationOptions object | |
exportOptions.VectorRasterizationOptions = New Aspose.CAD.ImageOptions.CadRasterizationOptions() With { _ | |
Key .PageWidth = 1600, _ | |
Key .PageHeight = 1600, _ | |
Key .CenterDrawing = True, _ | |
Key .Layouts = New String() {"Model"}, _ | |
Key .ScaleMethod = Aspose.CAD.FileFormats.Cad.ScaleType.None, _ | |
Key .BackgroundColor = Color.Black, _ | |
Key .DrawType = Aspose.CAD.FileFormats.Cad.CadDrawTypeMode.UseObjectColor _ | |
} | |
' Export the DWG to PDF by calling Save method | |
cadImage.Save(outPath, exportOptions) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_ExportingDGN() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("Nikon_D90_Camera.dgn") | |
' Load an existing DGN file as CadImage. | |
Using cadImage As Aspose.CAD.FileFormats.Cad.CadImage = DirectCast(Aspose.CAD.Image.Load(sourceFilePath), Aspose.CAD.FileFormats.Cad.CadImage) | |
' Create an object of CadRasterizationOptions class and define/set different properties | |
Dim rasterizationOptions As New Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
rasterizationOptions.PageWidth = 600 | |
rasterizationOptions.PageHeight = 300 | |
rasterizationOptions.CenterDrawing = True | |
rasterizationOptions.ScaleMethod = Aspose.CAD.FileFormats.Cad.ScaleType.None | |
rasterizationOptions.AutomaticLayoutsScaling = True | |
' Create an object of PdfOptions class as we are converting the image to PDF format and assign CadRasterizationOptions object to it. | |
Dim pdfOptions As New Aspose.CAD.ImageOptions.PdfOptions() | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions | |
' Call the save method of the CadImage class object. | |
cadImage.Save(MyDir & Convert.ToString("ExportDGNToPdf_out.pdf"), pdfOptions) | |
End Using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' The path to the documents directory. | |
Dim MyDir As String = RunExamples.GetDataDir_ExportingDGN() | |
Dim sourceFilePath As String = MyDir & Convert.ToString("Nikon_D90_Camera.dgn") | |
' Load an existing DGN file as CadImage. | |
Using cadImage As Aspose.CAD.FileFormats.Cad.CadImage = DirectCast(Aspose.CAD.Image.Load(sourceFilePath), Aspose.CAD.FileFormats.Cad.CadImage) | |
' Create an object of DgnRasterizationOptions class and define/set different properties | |
Dim rasterizationOptions As New Aspose.CAD.ImageOptions.DgnRasterizationOptions() | |
rasterizationOptions.PageWidth = 600 | |
rasterizationOptions.PageHeight = 300 | |
rasterizationOptions.CenterDrawing = True | |
rasterizationOptions.ScaleMethod = Aspose.CAD.FileFormats.Cad.ScaleType.None | |
rasterizationOptions.AutomaticLayoutsScaling = True | |
' Create an object of JpegOptions class as we are converting the DGN to jpeg and assign DgnRasterizationOptions object to it. | |
Dim options As Aspose.CAD.ImageOptionsBase = New Aspose.CAD.ImageOptions.JpegOptions() | |
options.VectorRasterizationOptions = rasterizationOptions | |
' Call the save method of the CadImage class object. | |
cadImage.Save(MyDir & Convert.ToString("ExportDGNToRasterImage_out.pdf"), options) | |
End Using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (CadImage cadImage = (CadImage)Image.Load(fileName)) | |
{ | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
foreach (CadLayout layout in cadImage.Layouts.Values) | |
{ | |
if (layout.LayoutName == "Model") continue; | |
SizeF pageSize = GetPageSizeFromLayout(layout); | |
rasterizationOptions.LayoutPageSizes.Add(layout.LayoutName, pageSize); | |
} | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(outPath, pdfOptions); | |
} | |
private static SizeF GetPageSizeFromLayout(CadLayout layout) | |
{ | |
var isLandscape = IsLayoutLandscape(layout); | |
float pageWidth; | |
float pageHeight; | |
if (layout.PlotPaperUnits == CadPlotPaperUnits.PlotInInches) | |
{ | |
pageWidth = (float)MillimetersToInches(layout.PlotPaperSize.Width); | |
pageHeight = (float)MillimetersToInches(layout.PlotPaperSize.Height); | |
} | |
else | |
{ | |
pageWidth = (float)layout.PlotPaperSize.Width; | |
pageHeight = (float)layout.PlotPaperSize.Height; | |
} | |
if (isLandscape) | |
{ | |
return new SizeF(pageHeight, pageWidth); | |
} | |
else | |
{ | |
return new SizeF(pageWidth, pageHeight); | |
} | |
} | |
private static bool IsLayoutLandscape(CadLayout layout) | |
{ | |
return layout.PlotRotation == CadPlotRotation.Clockwise90Degrees || layout.PlotRotation == CadPlotRotation.Counterclockwise90Degrees; | |
} | |
private static double MillimetersToInches(double millimeters) | |
{ | |
const double MillimetersToInchesFactor = 0.0393701; | |
return millimeters * MillimetersToInchesFactor; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (Image cadImage = Aspose.CAD.Image.Load(inputFileName)) | |
{ | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions() | |
{ | |
PageWidth = 5000, | |
PageHeight = 5000, | |
DrawType = CadDrawTypeMode.UseObjectColor, | |
ObserverPoint = new ObserverPoint(15, 5, 5), | |
}; | |
PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(outputFileName, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (Image cadImage = Aspose.CAD.Image.Load(fileName)) | |
{ | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions() | |
{ | |
PageWidth = 5000, | |
PageHeight = 5000, | |
DrawType = CadDrawTypeMode.UseObjectColor, | |
RenderMode3D = RenderMode3D.Wireframe | |
}; | |
PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(outputFileName, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set path of the license file, i.e. c:\temp\ | |
string dataDir = @"c:\temp\"; | |
License license = new License(); | |
license.SetLicense(dataDir + "Aspose.CAD.lic"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set path of the license file, i.e. c:\temp\ | |
string dataDir = @"c:\temp\"; | |
// Load an existing file in the stream | |
FileStream LicStream = new FileStream(dataDir + "Aspose.CAD.lic", FileMode.Open); | |
License license = new License(); | |
license.SetLicense(LicStream); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Access the setMeteredKey property and pass public and private keys as parameters | |
Aspose.CAD.Metered.SetMeteredKey("PublicKey", "PrivateKey"); | |
// Get metered data amount before calling API | |
decimal amountbefore = Aspose.CAD.Metered.GetConsumptionQuantity(); | |
// Display information | |
Console.WriteLine("Amount Consumed Before: " + amountbefore.ToString()); | |
// Do processing | |
//Aspose.CAD.FileFormats.Cad.CadImage image = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.load("BlockRefDgn.dwg"); | |
// Get metered data amount After calling API | |
decimal amountafter = Aspose.CAD.Metered.GetConsumptionQuantity(); | |
// Display information | |
Console.WriteLine("Amount Consumed After: " + amountafter.ToString()); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
// Load a CAD drawing in an instance of Image | |
using (var image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
// Set image width & height | |
rasterizationOptions.PageWidth = 500; | |
rasterizationOptions.PageHeight = 500; | |
// Add the layer name to the CadRasterizationOptions's layer list | |
rasterizationOptions.Layers= new string[] { "LayerA" }; | |
// Create an instance of JpegOptions (or any ImageOptions for raster formats) | |
var options = new Aspose.CAD.ImageOptions.JpegOptions(); | |
// Set VectorRasterizationOptions property to the instance of CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions; | |
//Export each layer to Jpeg format | |
MyDir = MyDir + "CADLayersToRasterImageFormats_out.jpg"; | |
image.Save(MyDir, options); | |
} | |
Console.WriteLine("\nCAD layers converted successfully to raster image format.\nFile saved at " + MyDir); | |
} | |
public static void ConvertAllLayersToRasterImageFormats() | |
{ | |
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
// Load a CAD drawing in an instance of CadImage | |
using (var image = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
// Set image width & height | |
rasterizationOptions.PageWidth = 500; | |
rasterizationOptions.PageHeight = 500; | |
// Get the layers in an instance of CadLayersDictionary | |
var layersList = image.Layers; | |
// Iterate over the layers | |
foreach (var layerName in layersList.GetLayersNames()) | |
{ | |
// Display layer name for tracking | |
Console.WriteLine("Start with " + layerName); | |
// Add the layer name to the CadRasterizationOptions's layer list | |
rasterizationOptions.Layers = new string[] { "LayerA" }; | |
// Create an instance of JpegOptions (or any ImageOptions for raster formats) | |
var options = new Aspose.CAD.ImageOptions.JpegOptions(); | |
// Set VectorRasterizationOptions property to the instance of CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions; | |
//Export each layer to Jpeg format | |
image.Save(layerName + "_out.jpg", options); | |
} | |
} | |
Console.WriteLine("\nCAD all layers converted successfully to raster image format."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
// Set page width & height | |
rasterizationOptions.PageWidth = 1200; | |
rasterizationOptions.PageHeight = 1200; | |
// Create an instance of PngOptions for the resultant image | |
ImageOptionsBase options = new Aspose.CAD.ImageOptions.PngOptions(); | |
// Set rasterization options | |
options.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "conic_pyramid_raster_image_out.png"; | |
// Save resultant image | |
image.Save(MyDir, options); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
// Set page width & height | |
rasterizationOptions.PageWidth = 1200; | |
rasterizationOptions.PageHeight = 1200; | |
// Specify a list of layout names | |
rasterizationOptions.Layouts = new string[] { "Model", "Layout1" }; | |
// Create an instance of TiffOptions for the resultant image | |
ImageOptionsBase options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// Set rasterization options | |
options.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "conic_pyramid_layoutstorasterimage_out.tiff"; | |
// Save resultant image | |
image.Save(MyDir, options); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
MemoryStream stream = new MemoryStream(); | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions cadRasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
pdfOptions.VectorRasterizationOptions = cadRasterizationOptions; | |
cadRasterizationOptions.PageWidth = 800; | |
cadRasterizationOptions.PageHeight = 600; | |
image.Save(stream, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string[] sourceFilePaths = new[] | |
{ | |
MyDir + "conic_pyramid.dxf", | |
MyDir + "Bottom_plate.dwg" | |
}; | |
foreach (var sourceFilePath in sourceFilePaths) | |
{ | |
string extension = Path.GetExtension(sourceFilePath); | |
using (CadImage cadImage = (CadImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
List<string> layouts = GetNotEmptyLayouts(cadImage, extension); | |
const double Epsilon = 0.00001; | |
foreach (string layout in layouts) | |
{ | |
System.Console.WriteLine("Layout= " + layout); | |
using (FileStream fs = new FileStream(MyDir + "layout_" + extension + "_" + layout + ".jpg", FileMode.Create)) | |
{ | |
JpegOptions jpegOptions = new JpegOptions(); | |
CadRasterizationOptions options = new CadRasterizationOptions(); | |
options.Layouts = new string[] { layout }; | |
CadLayout l = cadImage.Layouts[layout]; | |
if ((Math.Abs(l.MaxExtents.Y) < Epsilon && Math.Abs(l.MaxExtents.X) < Epsilon) | |
|| (Math.Abs(l.MaxExtents.Y + 1E+20) < Epsilon | |
|| Math.Abs(l.MaxExtents.X + 1E+20) < Epsilon) | |
|| (Math.Abs(l.MinExtents.Y - 1E+20) < Epsilon | |
|| Math.Abs(l.MinExtents.X - 1E+20) < Epsilon)) | |
{ | |
// do nothing, we can automatically detect size | |
// we can not rely on PlotPaperUnits here too because it is PlotInInches by default | |
} | |
else | |
{ | |
double sizeExtX = l.MaxExtents.X - l.MinExtents.X; | |
double sizeExtY = l.MaxExtents.Y - l.MinExtents.Y; | |
if (l.PlotPaperUnits == CadPlotPaperUnits.PlotInInches) | |
{ | |
options.PageHeight = CommonHelper.INtoPixels(sizeExtY, CommonHelper.DPI); | |
options.PageWidth = CommonHelper.INtoPixels(sizeExtX, CommonHelper.DPI); | |
} | |
else | |
{ | |
if (l.PlotPaperUnits == CadPlotPaperUnits.PlotInMillimeters) | |
{ | |
options.PageHeight = CommonHelper.MMtoPixels(sizeExtY, CommonHelper.DPI); | |
options.PageWidth = CommonHelper.MMtoPixels(sizeExtX, CommonHelper.DPI); | |
} | |
else | |
{ | |
options.PageHeight = (float)sizeExtY; | |
options.PageWidth = (float)sizeExtX; | |
} | |
} | |
} | |
jpegOptions.VectorRasterizationOptions = options; | |
cadImage.Save(fs, jpegOptions); | |
} | |
} | |
} | |
} | |
} | |
private static List<string> GetNotEmptyLayouts(Image cadImage, string extension) | |
{ | |
List<string> nonEmptyLayouts = new List<string>(); | |
if (cadImage == null) | |
return nonEmptyLayouts; | |
switch (extension) | |
{ | |
case ".dwg": | |
nonEmptyLayouts = GetNotEmptyLayoutsForDwg((CadImage)cadImage); | |
break; | |
case ".dxf": | |
nonEmptyLayouts = GetNotEmptyLayoutsForDxf((CadImage)cadImage); | |
break; | |
} | |
return nonEmptyLayouts; | |
} | |
private static List<string> GetNotEmptyLayoutsForDwg(CadImage cadImage) | |
{ | |
List<string> notEmptyLayouts = new List<string>(); | |
foreach (CadLayout layout in cadImage.Layouts.Values) | |
{ | |
foreach (CadBlockTableObject tableObject in cadImage.BlocksTables) | |
{ | |
if (string.Equals(tableObject.HardPointerToLayout.Value, layout.ObjectHandle, StringComparison.InvariantCultureIgnoreCase)) | |
{ | |
if (cadImage.BlockEntities.ContainsKey(tableObject.BlockName)) | |
{ | |
CadBlockEntity cadBlockEntity = cadImage.BlockEntities[tableObject.BlockName]; | |
if (cadBlockEntity.Entities.Length > 0) | |
notEmptyLayouts.Add(layout.LayoutName); | |
} | |
break; | |
} | |
} | |
} | |
return notEmptyLayouts; | |
} | |
private static List<string> GetNotEmptyLayoutsForDxf(CadImage cadImage) | |
{ | |
List<string> notEmptyLayouts = new List<string>(); | |
Dictionary<string, string> layoutBlockHandles = new Dictionary<string, string>(); | |
foreach (CadLayout layout in cadImage.Layouts.Values) | |
{ | |
if (layout.BlockTableRecordHandle != null) | |
layoutBlockHandles.Add(layout.BlockTableRecordHandle, layout.LayoutName); | |
} | |
foreach (CadBaseEntity entity in cadImage.Entities) | |
{ | |
if (layoutBlockHandles.ContainsKey(entity.SoftOwner.Value)) | |
{ | |
string layoutName = layoutBlockHandles[entity.SoftOwner.Value]; | |
if (!notEmptyLayouts.Contains(layoutName)) | |
notEmptyLayouts.Add(layoutName); | |
} | |
} | |
return notEmptyLayouts; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string MyDir = RunExamples.GetDataDir_IGESDrawings(); | |
string sourceFilePath = MyDir + ("figa2.igs"); | |
string outPath = MyDir + ("meshes.pdf"); | |
using (Image igesImage = Image.Load(sourceFilePath)) | |
{ | |
Aspose.CAD.ImageOptions.PdfOptions pdf = new Aspose.CAD.ImageOptions.PdfOptions(); | |
pdf.VectorRasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
pdf.VectorRasterizationOptions.PageHeight = 1000; | |
pdf.VectorRasterizationOptions.PageWidth = 1000; | |
igesImage.Save("figa2.pdf", pdf); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)image; | |
Aspose.CAD.FileFormats.Cad.CadLayoutDictionary layouts = cadImage.Layouts; | |
foreach (Aspose.CAD.FileFormats.Cad.CadObjects.CadLayout layout in layouts.Values) | |
{ | |
Console.WriteLine("Layout " + layout.LayoutName); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir+("meshes.dwg"); | |
string outPath = MyDir+("meshes.pdf"); | |
using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
//rasterizationOptions.TypeOfEntities = TypeOfEntities.Entities3D; | |
rasterizationOptions.Layouts = new string[] { "Model" }; | |
PdfOptions pdfOptions = new PdfOptions | |
{ | |
VectorRasterizationOptions = rasterizationOptions | |
}; | |
{ | |
cadImage.Save(outPath, pdfOptions); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
CadImage cadImage = (CadImage)Image.Load(sourceFilePath); | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Here user can change default start cap and end cap of pens when exporting CadImage object to | |
// image. It can be using for all image formats: pdf, png, bmp, gif, jpeg2000, jpeg, psd, tiff, wmf. | |
// If user doesn't use PenOptions, system will use its own default pens (different in defferent places). | |
rasterizationOptions.PenOptions = new PenOptions | |
{ | |
StartCap = LineCap.Flat, | |
EndCap = LineCap.Flat | |
}; | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(MyDir+"9LHATT-A56_generated.pdf", pdfOptions); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
using (CadImage image = (CadImage)Image.Load(MyDir+"example.dwt")) | |
{ | |
foreach (CadBaseEntity entity in image.Entities) | |
{ | |
//do your work here | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
// Set Auto Layout Scaling | |
rasterizationOptions.AutomaticLayoutsScaling = true; | |
// Create an instance of PdfOptions | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "result_out.pdf"; | |
//Export the CAD to PDF | |
image.Save(MyDir, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
rasterizationOptions.BackgroundColor = Aspose.CAD.Color.Beige; | |
rasterizationOptions.DrawType = Aspose.CAD.FileFormats.Cad.CadDrawTypeMode.UseDrawColor; | |
rasterizationOptions.DrawColor = Aspose.CAD.Color.Blue; | |
// Create an instance of PdfOptions | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
//Export CAD to PDF | |
image.Save(MyDir + "result_out.pdf", pdfOptions); | |
// Create an instance of TiffOptions | |
Aspose.CAD.ImageOptions.TiffOptions tiffOptions = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// Set the VectorRasterizationOptions property | |
tiffOptions.VectorRasterizationOptions = rasterizationOptions; | |
//Export CAD to TIFF | |
image.Save(MyDir + "result_out.tiff", tiffOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
rasterizationOptions.AutomaticLayoutsScaling = true; | |
rasterizationOptions.NoScaling = false; | |
// Create an instance of PdfOptions | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
//Export CAD to PDF | |
image.Save(MyDir + "result_out.pdf", pdfOptions); | |
// Create an instance of TiffOptions | |
Aspose.CAD.ImageOptions.TiffOptions tiffOptions = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// Set the VectorRasterizationOptions property | |
tiffOptions.VectorRasterizationOptions = rasterizationOptions; | |
//Export CAD to TIFF | |
image.Save(MyDir + "result_out.tiff", tiffOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
// Load a CAD drawing in an instance of CadImage | |
using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Iterate over the items of CadStyleDictionary | |
foreach (CadStyleTableObject style in cadImage.Styles) | |
{ | |
// Set the font name | |
style.PrimaryFontName = "Arial"; | |
} | |
} | |
Console.WriteLine("\nFont changed successfully."); | |
} | |
public static void SubstitutingFontByName() | |
{ | |
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
// Load a CAD drawing in an instance of CadImage | |
using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Iterate over the items of CadStyleDictionary | |
foreach (CadStyleTableObject style in cadImage.Styles) | |
{ | |
if (style.StyleName == "Roman") | |
{ | |
// Specify the font for one particular style | |
style.PrimaryFontName = "Arial"; | |
} | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ExportingDGN(); | |
string sourceFilePath = MyDir + "Nikon_D90_Camera.dgn"; | |
// Load an existing DGN file as CadImage. | |
using (DgnImage dgnImage = (DgnImage)Image.Load(file)) | |
{ | |
var options = new PdfOptions | |
{ | |
VectorRasterizationOptions = new CadRasterizationOptions | |
{ | |
PageWidth = 1500, | |
PageHeight = 1500, | |
CenterDrawing = true, | |
AutomaticLayoutsScaling = true, | |
BackgroundColor = Color.Black, | |
Layouts = new string[] { "1", "2", "3", "9" }//only export 4 (1,2,3 and 9) views | |
} | |
}; | |
dgnImage.Save(outFile, options); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Input and Output file paths | |
string fileName = "BlockRefDgn.dwg"; | |
string outPath = fileName + ".pdf"; | |
// Create an instance of PdfOptions class as we are exporting the DWG file to PDF format | |
Aspose.CAD.ImageOptions.PdfOptions exportOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Load any existing DWG file as image and convert it to CadImage type | |
using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Image.Load(fileName)) | |
{ | |
// Go through each entity inside the DWG file | |
foreach (Aspose.CAD.FileFormats.Cad.CadObjects.CadBaseEntity baseEntity in cadImage.Entities) | |
{ | |
// Check if entity is an image definition | |
if (baseEntity.TypeName == Aspose.CAD.FileFormats.Cad.CadConsts.CadEntityTypeName.DGNUNDERLAY) | |
{ | |
Aspose.CAD.FileFormats.Cad.CadObjects.CadDgnUnderlay dgnFile = (Aspose.CAD.FileFormats.Cad.CadObjects.CadDgnUnderlay)baseEntity; | |
// Get external reference to object | |
System.Console.WriteLine(dgnFile.UnderlayPath); | |
} | |
} | |
// Define settings for CadRasterizationOptions object | |
exportOptions.VectorRasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
{ | |
PageWidth = 1600, | |
PageHeight = 1600, | |
Layouts = new string[] { "Model" }, | |
AutomaticLayoutsScaling = false, | |
NoScaling = true, | |
BackgroundColor = Color.Black, | |
DrawType = Aspose.CAD.FileFormats.Cad.CadDrawTypeMode.UseObjectColor | |
}; | |
//Export the DWG to PDF by calling Save method | |
cadImage.Save(outPath, exportOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ExportingDGN(); | |
string sourceFilePath = MyDir + "Nikon_D90_Camera.dgn"; | |
// Load an existing DGN file as CadImage. | |
using (Aspose.CAD.FileFormats.Dgn.DgnImage cadImage = (Aspose.CAD.FileFormats.Dgn.DgnImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an object of CadRasterizationOptions class and define/set different properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 600; | |
rasterizationOptions.PageHeight = 300; | |
rasterizationOptions.NoScaling = true; | |
rasterizationOptions.AutomaticLayoutsScaling = false; | |
// Create an object of PdfOptions class as we are converting the image to PDF format and assign CadRasterizationOptions object to it. | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
// Call the save method of the CadImage class object. | |
cadImage.Save(MyDir + "ExportDGNToPdf_out.pdf", pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ExportingDGN(); | |
string sourceFilePath = MyDir + "Nikon_D90_Camera.dgn"; | |
// Load an existing DGN file as CadImage. | |
using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an object of DgnRasterizationOptions class and define/set different properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 600; | |
rasterizationOptions.PageHeight = 300; | |
rasterizationOptions.NoScaling = true; | |
rasterizationOptions.AutomaticLayoutsScaling = false; | |
// Create an object of JpegOptions class as we are converting the DGN to jpeg and assign DgnRasterizationOptions object to it. | |
Aspose.CAD.ImageOptionsBase options = new Aspose.CAD.ImageOptions.JpegOptions(); | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// Call the save method of the CadImage class object. | |
cadImage.Save(MyDir + "ExportDGNToRasterImage_out.pdf", options); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ExportingDGN(); | |
string sourceFilePath = MyDir + "Nikon_D90_Camera.dgn"; | |
// Load an existing DGN file as CadImage. | |
using (DgnImage dgnImage = (DgnImage)Image.Load(sourceFilePath)) | |
{ | |
foreach (DgnDrawingElementBase element in dgnImage.Elements) | |
{ | |
switch (element.Metadata.Type) | |
{ | |
case DgnElementType.Line: | |
case DgnElementType.Ellipse: | |
case DgnElementType.Curve: | |
case DgnElementType.BSplineCurveHeader: | |
case DgnElementType.Arc: | |
case DgnElementType.Shape: | |
case DgnElementType.PolyLine: | |
case DgnElementType.TextNode: | |
case DgnElementType.Text: | |
case DgnElementType.ComplexShapeHeader: | |
case DgnElementType.ComplexChainHeader: | |
{ | |
//previously supported entities, now supported also for 3D | |
break; | |
} | |
case DgnElementType.SolidHeader3D: | |
case DgnElementType.Cone: | |
case DgnElementType.CellHeader: | |
{ | |
//supported 3D entities | |
break; | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ExportingDGN(); | |
string sourceFilePath = MyDir + "Nikon_D90_Camera.dgn"; | |
// Load an existing DGN file as CadImage. | |
using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an object of DgnRasterizationOptions class and define/set different properties | |
Aspose.CAD.ImageOptions.DgnRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.DgnRasterizationOptions(); | |
rasterizationOptions.PageWidth = 600; | |
rasterizationOptions.PageHeight = 300; | |
rasterizationOptions.CenterDrawing = true; | |
rasterizationOptions.NoScaling = true; | |
rasterizationOptions.AutomaticLayoutsScaling = false; | |
// Create an object of JpegOptions class as we are converting the DGN to jpeg and assign DgnRasterizationOptions object to it. | |
Aspose.CAD.ImageOptionsBase options = new Aspose.CAD.ImageOptions.JpegOptions(); | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// Call the save method of the CadImage class object. | |
cadImage.Save(MyDir + "ExportDGNToRasterImage_out.pdf", options); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ExportingDGN(); | |
string sourceFilePath = MyDir + "Nikon_D90_Camera.dgn"; | |
// Load an existing DGN file as CadImage. | |
using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an object of DgnRasterizationOptions class and define/set different properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 600; | |
rasterizationOptions.PageHeight = 300; | |
rasterizationOptions.NoScaling = true; | |
rasterizationOptions.AutomaticLayoutsScaling = false; | |
// Create an object of JpegOptions class as we are converting the DGN to jpeg and assign DgnRasterizationOptions object to it. | |
Aspose.CAD.ImageOptionsBase options = new Aspose.CAD.ImageOptions.JpegOptions(); | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// Call the save method of the CadImage class object. | |
cadImage.Save(MyDir + "ExportDGNToRasterImage_out.pdf", options); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ExportingDGN(); | |
string sourceFilePath = MyDir + "Nikon_D90_Camera.dgn"; | |
string outFile = MyDir + "Nikon_D90_Camera.dgn"; | |
// Load an existing DGN file as CadImage. | |
using (DgnImage dgnImage = (DgnImage)Image.Load(sourceFilePath)) | |
{ | |
var options = new PdfOptions | |
{ | |
VectorRasterizationOptions = new CadRasterizationOptions | |
{ | |
PageWidth = 1500, | |
PageHeight = 1500, | |
AutomaticLayoutsScaling = true, | |
BackgroundColor = Color.Black, | |
Layouts = new string[] { "1", "2", "3", "9" }//only export 4 (1,2,3 and 9) views | |
} | |
}; | |
dgnImage.Save(outFile, options); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWFDrawings(); | |
string sourceFilePath = MyDir + "blocks_and_tables.dwf"; | |
string extension = Path.GetExtension(sourceFilePath); | |
using (DwfImage image = (DwfImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
foreach (var page in image.Pages) | |
{ | |
var layout = page.Name; | |
System.Console.WriteLine("Layout= " + layout); | |
using (FileStream fs = new FileStream(MyDir + "layout_" + layout + ".jpg", FileMode.Create)) | |
{ | |
JpegOptions jpegOptions = new JpegOptions(); | |
CadRasterizationOptions options = new CadRasterizationOptions(); | |
options.Layouts = new string[] { layout }; | |
double sizeExtX = page.MaxPoint.X - page.MinPoint.X; | |
double sizeExtY = page.MaxPoint.Y - page.MinPoint.Y; | |
if (page.UnitType == UnitType.Inch) | |
{ | |
options.PageHeight = CommonHelper.INtoPixels(sizeExtY, CommonHelper.DPI); | |
options.PageWidth = CommonHelper.INtoPixels(sizeExtX, CommonHelper.DPI); | |
} | |
else if (page.UnitType == UnitType.Millimeter) | |
{ | |
options.PageHeight = CommonHelper.MMtoPixels(sizeExtY, CommonHelper.DPI); | |
options.PageWidth = CommonHelper.MMtoPixels(sizeExtX, CommonHelper.DPI); | |
} | |
else | |
{ | |
options.PageHeight = (float)sizeExtY; | |
options.PageWidth = (float)sizeExtX; | |
} | |
jpegOptions.VectorRasterizationOptions = options; | |
image.Save(fs, jpegOptions); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "for_layers_test.dwf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
// Add desired layers | |
rasterizationOptions.Layers= new string[] { "LayerA" }; | |
JpegOptions jpegOptions = new JpegOptions(); | |
jpegOptions.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "for_layers_test.jpg"; | |
// Export the DXF to JPG | |
image.Save(MyDir, jpegOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-.NET | |
string SourceDir = RunExamples.GetDataDir_DWFXDrawings(); | |
string OutputDir = RunExamples.GetDataDir_Output(); | |
using (Image cadDrawing = Image.Load(SourceDir + "Tyrannosaurus.dwfx")) | |
{ | |
var rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = cadDrawing.Size.Width; | |
rasterizationOptions.PageHeight = cadDrawing.Size.Height; | |
PdfOptions CADf = new PdfOptions(); | |
CADf.VectorRasterizationOptions = rasterizationOptions; | |
cadDrawing.Save(OutputDir + "OpenDwfxFile_out.pdf", CADf); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
// Input file name and path | |
string fileName = MyDir + "BlockRefDgn.dwg"; | |
// Load an existing DWG file and convert it into CadImage | |
using (Aspose.CAD.FileFormats.Cad.CadImage image = (Aspose.CAD.FileFormats.Cad.CadImage)Image.Load(fileName)) | |
{ | |
// Go through each entity inside the DWG file | |
foreach (Aspose.CAD.FileFormats.Cad.CadObjects.CadBaseEntity entity in image.Entities) | |
{ | |
// Check if entity is of CadDgnUnderlay type | |
if (entity is Aspose.CAD.FileFormats.Cad.CadObjects.CadDgnUnderlay) | |
{ | |
// Access different underlay flags | |
Aspose.CAD.FileFormats.Cad.CadObjects.CadUnderlay underlay = entity as Aspose.CAD.FileFormats.Cad.CadObjects.CadUnderlay; | |
Console.WriteLine(underlay.UnderlayPath); | |
Console.WriteLine(underlay.UnderlayName); | |
Console.WriteLine(underlay.InsertionPoint.X); | |
Console.WriteLine(underlay.InsertionPoint.Y); | |
Console.WriteLine(underlay.RotationAngle); | |
Console.WriteLine(underlay.ScaleX); | |
Console.WriteLine(underlay.ScaleY); | |
Console.WriteLine(underlay.ScaleZ); | |
Console.WriteLine((underlay.Flags & Aspose.CAD.FileFormats.Cad.CadObjects.UnderlayFlags.UnderlayIsOn) == Aspose.CAD.FileFormats.Cad.CadObjects.UnderlayFlags.UnderlayIsOn); | |
Console.WriteLine((underlay.Flags & Aspose.CAD.FileFormats.Cad.CadObjects.UnderlayFlags.ClippingIsOn) == Aspose.CAD.FileFormats.Cad.CadObjects.UnderlayFlags.ClippingIsOn); | |
Console.WriteLine((underlay.Flags & Aspose.CAD.FileFormats.Cad.CadObjects.UnderlayFlags.Monochrome) != Aspose.CAD.FileFormats.Cad.CadObjects.UnderlayFlags.Monochrome); | |
break; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string dwgPathToFile = MyDir + "SimpleEntites.dwg"; | |
using (Image image = Image.Load(dwgPathToFile)) | |
{ | |
CadText cadText = new CadText(); | |
cadText.StyleType = "Standard"; | |
cadText.DefaultValue = "Some custom text"; | |
cadText.ColorId = 256; | |
cadText.LayerName = "0"; | |
cadText.FirstAlignment.X = 47.90; | |
cadText.FirstAlignment.Y = 5.56; | |
cadText.TextHeight = 0.8; | |
cadText.ScaleX = 0.0; | |
CadImage cadImage = (CadImage)image; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(cadText); | |
PdfOptions pdfOptions = new PdfOptions(); | |
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions(); | |
pdfOptions.VectorRasterizationOptions = cadRasterizationOptions; | |
cadRasterizationOptions.DrawType = CadDrawTypeMode.UseObjectColor; | |
cadRasterizationOptions.PageHeight = 1600; | |
cadRasterizationOptions.PageWidth = 1600; | |
cadRasterizationOptions.Layouts = new string[] { "Model" }; | |
image.Save(MyDir+"SimpleEntites_generated.pdf", pdfOptions); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string inputFile = MyDir + "test1.dwg"; | |
string outputFile = MyDir + "test1.png"; | |
using (FileStream fs = new FileStream(inputFile, FileMode.Open)) | |
{ | |
using (FileStream output = new FileStream(outputFile, FileMode.Create)) | |
{ | |
Image document = Image.Load(fs); | |
PngOptions saveOptions = new PngOptions(); | |
CadRasterizationOptions options = new CadRasterizationOptions(); | |
options.NoScaling = false; | |
options.PageHeight = document.Height * 10; | |
options.PageWidth = document.Width * 10; | |
options.DrawType = Aspose.CAD.FileFormats.Cad.CadDrawTypeMode.UseObjectColor; | |
saveOptions.VectorRasterizationOptions = options; | |
document.Save(output, saveOptions); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var formatTypeDwt = Image.GetFileFormat(GetFileFromDesktop("sample.dwt")); | |
Assert.IsTrue(formatTypeDwt.ToString().ToLower().Contains("dwt")); | |
var formatTypeDwg = Image.GetFileFormat(GetFileFromDesktop("sample.dwg")); | |
Assert.IsTrue(formatTypeDwg.ToString().ToLower().Contains("dwg")); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir + "Bottom_plate.dwg"; | |
Aspose.CAD.Image cadImage = Aspose.CAD.Image.Load(sourceFilePath); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.BackgroundColor = Aspose.CAD.Color.White; | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions | |
{ | |
VectorRasterizationOptions = rasterizationOptions | |
}; | |
pdfOptions.CorePdfOptions = new PdfDocumentOptions(); | |
pdfOptions.CorePdfOptions.Compliance = PdfCompliance.PdfA1a; | |
cadImage.Save(MyDir + "PDFA1_A.pdf", pdfOptions); | |
pdfOptions.CorePdfOptions.Compliance = PdfCompliance.PdfA1b; | |
cadImage.Save(MyDir + "PDFA1_B.pdf", pdfOptions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string inputFile = MyDir + "Line.dwg"; | |
string outFile = MyDir + "Line_20.1.dwf"; | |
using (var cadImage = (CadImage)Image.Load(inputFile)) | |
{ | |
cadImage.Save(outFile); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string inputFile = MyDir + "Line.dwg"; | |
string outFile = MyDir + "Line_19.2.dxf"; | |
using (var cadImage = (CadImage)Image.Load(inputFile)) | |
{ | |
cadImage.Save(outFile); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir + "Bottom_plate.dwg"; | |
string outPath = MyDir + "Bottom_plate.pdf"; | |
using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.Layouts = new string[] { "Model" }; | |
bool currentUnitIsMetric = false; | |
double currentUnitCoefficient = 1.0; | |
DefineUnitSystem(cadImage.UnitType, out currentUnitIsMetric, out currentUnitCoefficient); | |
if (currentUnitIsMetric) | |
{ | |
double metersCoeff = 1 / 1000.0; | |
double scaleFactor = metersCoeff / currentUnitCoefficient; | |
rasterizationOptions.PageWidth = (float)(210 * scaleFactor); | |
rasterizationOptions.PageHeight = (float)(297 * scaleFactor); | |
rasterizationOptions.UnitType = UnitType.Millimeter; | |
} | |
else | |
{ | |
rasterizationOptions.PageWidth = (float)(8.27f / currentUnitCoefficient); | |
rasterizationOptions.PageHeight = (float)(11.69f / currentUnitCoefficient); | |
rasterizationOptions.UnitType = UnitType.Inch; | |
} | |
rasterizationOptions.AutomaticLayoutsScaling = true; | |
PdfOptions pdfOptions = new PdfOptions | |
{ | |
VectorRasterizationOptions = rasterizationOptions | |
}; | |
cadImage.Save(outPath, pdfOptions); | |
// export to raster | |
//A4 size at 300 DPI - 2480 x 3508 | |
rasterizationOptions.PageHeight = 3508; | |
rasterizationOptions.PageWidth = 2480; | |
PngOptions pngOptions = new PngOptions | |
{ | |
VectorRasterizationOptions = rasterizationOptions | |
}; | |
cadImage.Save(outPath.Replace("pdf", "png"), pngOptions); | |
} | |
} | |
private static void DefineUnitSystem(UnitType unitType, out bool isMetric, out double coefficient) | |
{ | |
isMetric = false; | |
coefficient = 1.0; | |
switch (unitType) | |
{ | |
case UnitType.Parsec: | |
coefficient = 3.0857 * 10000000000000000.0; | |
isMetric = true; | |
break; | |
case UnitType.LightYear: | |
coefficient = 9.4607 * 1000000000000000.0; | |
isMetric = true; | |
break; | |
case UnitType.AstronomicalUnit: | |
coefficient = 1.4960 * 100000000000.0; | |
isMetric = true; | |
break; | |
case UnitType.Gigameter: | |
coefficient = 1000000000.0; | |
isMetric = true; | |
break; | |
case UnitType.Kilometer: | |
coefficient = 1000.0; | |
isMetric = true; | |
break; | |
case UnitType.Decameter: | |
isMetric = true; | |
coefficient = 10.0; | |
break; | |
case UnitType.Hectometer: | |
isMetric = true; | |
coefficient = 100.0; | |
break; | |
case UnitType.Meter: | |
isMetric = true; | |
coefficient = 1.0; | |
break; | |
case UnitType.Centimenter: | |
isMetric = true; | |
coefficient = 0.01; | |
break; | |
case UnitType.Decimeter: | |
isMetric = true; | |
coefficient = 0.1; | |
break; | |
case UnitType.Millimeter: | |
isMetric = true; | |
coefficient = 0.001; | |
break; | |
case UnitType.Micrometer: | |
isMetric = true; | |
coefficient = 0.000001; | |
break; | |
case UnitType.Nanometer: | |
isMetric = true; | |
coefficient = 0.000000001; | |
break; | |
case UnitType.Angstrom: | |
isMetric = true; | |
coefficient = 0.0000000001; | |
break; | |
case UnitType.Inch: | |
coefficient = 1.0; | |
break; | |
case UnitType.MicroInch: | |
coefficient = 0.000001; | |
break; | |
case UnitType.Mil: | |
coefficient = 0.001; | |
break; | |
case UnitType.Foot: | |
coefficient = 12.0; | |
break; | |
case UnitType.Yard: | |
coefficient = 36.0; | |
break; | |
case UnitType.Mile: | |
coefficient = 63360.0; | |
break; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string[] files = new string[] { "D ZD junior D10m H2m.dwg", "ZD - Senior D6m H2m45.dwg" }; | |
PngOptions pngOptions = new PngOptions { }; | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
pngOptions.VectorRasterizationOptions = rasterizationOptions; | |
rasterizationOptions.Layouts = new string[] { "Layout1" }; | |
foreach (string file in files) | |
{ | |
using (CadImage cadImage = (CadImage)Image.Load(MyDir + file)) | |
{ | |
cadImage.Save(MyDir + file + "_out.png", pngOptions); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir + "visualization_-_conference_room.dwg"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
// Specify desired layout name | |
rasterizationOptions.Layouts = new string[] { "Layout1" }; | |
// Create an instance of PdfOptions | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "ExportSpecificLayoutToPDF_out.pdf"; | |
//Export the DWG to PDF | |
image.Save(MyDir, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir + "Bottom_plate.dwg"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.BackgroundColor = Aspose.CAD.Color.White; | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
// Create an instance of PdfOptions | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "Bottom_plate_out.pdf"; | |
//Export the DWG to PDF | |
image.Save(MyDir, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
using (Image image = Image.Load(MyDir + "sample.dwg")) | |
{ | |
var options = new SvgOptions(); | |
options.ColorType = Aspose.CAD.ImageOptions.SvgOptionsParameters.SvgColorMode.Grayscale; | |
options.TextAsShapes = true; | |
image.Save(MyDir + "sample.svg"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir + "sample.dwg"; | |
// Load an existing DWG file as CadImage. | |
using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
System.Console.WriteLine(cadImage.BlockEntities["*MODEL_SPACE"].XRefPathName); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string dwgPathToFile = MyDir +"Drawing11.dwg"; | |
CadImage cadImage1 = (CadImage)Image.Load(dwgPathToFile); | |
// using (Image image = ImageLoader.Load(dwgPathToFile)) | |
{ | |
CadRasterImageDef cadRasterImageDef = new CadRasterImageDef(); | |
cadRasterImageDef.ObjectHandle = "A3B4"; | |
cadRasterImageDef.FileName = "road-sign-custom.png"; | |
CadRasterImage cadRasterImage = new CadRasterImage(); | |
cadRasterImage.ImageDefReference = "A3B4"; | |
cadRasterImage.InsertionPoint.X = 26.77; | |
cadRasterImage.InsertionPoint.Y = 22.35; | |
cadRasterImage.DisplayFlags = 7; | |
cadRasterImage.ImageSizeU = 640; | |
cadRasterImage.ImageSizeV = 562; | |
cadRasterImage.UVector.X = 0.0061565450840500831; | |
cadRasterImage.UVector.Y = 0; | |
cadRasterImage.VVector.X = 0; | |
cadRasterImage.VVector.Y = 0.0061565450840500822; | |
cadRasterImage.ClippingState = 0; | |
cadRasterImage.ClipBoundaryVertexList.Add(new Cad2DPoint(-0.5, 0.5)); | |
cadRasterImage.ClipBoundaryVertexList.Add(new Cad2DPoint(639.5, 561.5)); | |
CadImage cadImage = (CadImage)cadImage1; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(cadRasterImage); | |
List<CadBaseObject> list = new List<CadBaseObject>(cadImage.Objects); | |
list.Add(cadRasterImageDef); | |
cadImage.Objects = list.ToArray(); | |
PdfOptions pdfOptions = new PdfOptions(); | |
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions(); | |
pdfOptions.VectorRasterizationOptions = cadRasterizationOptions; | |
cadRasterizationOptions.DrawType = CadDrawTypeMode.UseObjectColor; | |
cadRasterizationOptions.PageHeight = 1600; | |
cadRasterizationOptions.PageWidth = 1600; | |
cadRasterizationOptions.Layouts = new string[] { "Model" }; | |
cadImage1.Save(MyDir+"export2.pdf", pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string filePathDWG = MyDir + "TestBigFile.dwg"; | |
string filePathFinish = MyDir+ "TestBigFile.dwg.pdf"; | |
Stopwatch stopWatch = new Stopwatch(); | |
try | |
{ | |
stopWatch.Start(); | |
using (CadImage cadImage = (CadImage)Image.Load(filePathDWG)) | |
{ | |
stopWatch.Stop(); | |
// Get the elapsed time as a TimeSpan value. | |
TimeSpan ts = stopWatch.Elapsed; | |
// Format and display the TimeSpan value. | |
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", | |
ts.Hours, ts.Minutes, ts.Seconds, | |
ts.Milliseconds / 10); | |
Console.WriteLine("RunTime for loading " + elapsedTime); | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
stopWatch = new Stopwatch(); | |
stopWatch.Start(); | |
cadImage.Save(filePathFinish, pdfOptions); | |
stopWatch.Stop(); | |
// Get the elapsed time as a TimeSpan value. | |
ts = stopWatch.Elapsed; | |
// Format and display the TimeSpan value. | |
elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", | |
ts.Hours, ts.Minutes, ts.Seconds, | |
ts.Milliseconds / 10); | |
Console.WriteLine("RunTime for converting " + elapsedTime); | |
} | |
} | |
catch (Exception ex) | |
{ | |
Console.WriteLine(ex.Message); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir + "meshes.dwg"; | |
// Load an existing DWG file as CadImage. | |
using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
foreach (var entity in cadImage.Entities) | |
{ | |
if (entity is CadPolyFaceMesh) | |
{ | |
CadPolyFaceMesh asFaceMesh = (CadPolyFaceMesh)entity; | |
if (asFaceMesh != null) | |
{ | |
Console.WriteLine("Vetexes count: " + asFaceMesh.MeshMVertexCount); | |
} | |
} | |
else if (entity is CadPolygonMesh) | |
{ | |
CadPolygonMesh asPolygonMesh = (CadPolygonMesh)entity; | |
if (asPolygonMesh != null) | |
{ | |
Console.WriteLine("Vetexes count: " + asPolygonMesh.MeshMVertexCount); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-.NET | |
string SourceDir = RunExamples.GetDataDir_DWGDrawings(); | |
using (CadImage cadImage = (CadImage)Image.Load(SourceDir + "SimpleEntites.dwg", | |
new LoadOptions() | |
{ | |
SpecifiedEncoding = CodePages.Japanese, | |
SpecifiedMifEncoding = MifCodePages.Japanese, | |
RecoverMalformedCifMif = false | |
})) | |
{ | |
//do export or something else with cadImage | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir + "visualization_-_conference_room.dwg"; | |
var cadImage = (CadImage)Aspose.CAD.Image.Load(sourceFilePath); | |
CadBaseEntity[] entities = cadImage.Entities; | |
List<CadBaseEntity> filteredEntities = new List<CadBaseEntity>(); | |
foreach (CadBaseEntity baseEntity in entities) | |
{ | |
// selection or filtration of entities | |
if (baseEntity.TypeName == CadEntityTypeName.TEXT) | |
{ | |
filteredEntities.Add(baseEntity); | |
} | |
} | |
cadImage.Entities = filteredEntities.ToArray(); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = | |
new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
// Set Auto Layout Scaling | |
rasterizationOptions.AutomaticLayoutsScaling = true; | |
// Create an instance of PdfOptions | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
string outFile = MyDir + "result_out_generated.pdf"; | |
// Export the CAD to PDF | |
cadImage.Save(outFile, pdfOptions); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir + "Bottom_plate.dwg"; | |
using (CadImage image = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
foreach (CadBaseEntity entity in image.Entities) | |
{ | |
if (entity is CadUnderlay) | |
{ | |
//XREF entity with metadata | |
Cad3DPoint insertionPoint = ((CadUnderlay)entity).InsertionPoint; | |
string path = ((CadUnderlay)entity).UnderlayPath; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir + "Bottom_plate.dwg"; | |
using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.Layouts = new string[] { "Model" }; | |
rasterizationOptions.NoScaling = true; | |
// note: preserving some empty borders around part of image is the responsibility of customer | |
// top left point of region to draw | |
Point topLeft = new Point(6156, 7053); | |
double width = 3108; | |
double height = 2489; | |
CadVportTableObject newView = new CadVportTableObject(); | |
// note: exactly such table name is required for active view | |
newView.Name.Value = "*Active"; | |
newView.CenterPoint.X = topLeft.X + width / 2f; | |
newView.CenterPoint.Y = topLeft.Y - height / 2f; | |
newView.ViewHeight.Value = height; | |
newView.ViewAspectRatio.Value = width / height; | |
// search for active viewport and replace it | |
for (int i = 0; i < cadImage.ViewPorts.Count; i++) | |
{ | |
CadVportTableObject currentView = (CadVportTableObject)(cadImage.ViewPorts[i]); | |
if ((currentView.Name.Value == null && cadImage.ViewPorts.Count == 1) || | |
string.Equals(currentView.Name.Value.ToLowerInvariant(), "*active")) | |
{ | |
cadImage.ViewPorts[i] = newView; | |
break; | |
} | |
} | |
PdfOptions pdfOptions = new PdfOptions(); | |
rasterizationOptions.Layouts = new string[] { "Model" }; | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(MyDir, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir + "search.dwg"; | |
// Load an existing DWG file as CadImage. | |
using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Search for text in the file | |
foreach (Aspose.CAD.FileFormats.Cad.CadObjects.CadBaseEntity entity in cadImage.Entities) | |
{ | |
// Please, note: we iterate through CadText entities here, but some other entities may contain text also, e.g. CadMText and others | |
IterateCADNodes(entity); | |
} | |
// Search for text on specific layout get all layout names and link each layout with corresponding block with entities | |
Aspose.CAD.FileFormats.Cad.CadLayoutDictionary layouts = cadImage.Layouts; | |
string[] layoutNames = new string[layouts.Count]; | |
int i = 0; | |
foreach (Aspose.CAD.FileFormats.Cad.CadObjects.CadLayout layout in layouts.Values) | |
{ | |
layoutNames[i++] = layout.LayoutName; | |
System.Console.WriteLine("Layout " + layout.LayoutName + " is found"); | |
// Find block, applicable for DWG only | |
Aspose.CAD.FileFormats.Cad.CadTables.CadBlockTableObject blockTableObjectReference = null; | |
foreach (Aspose.CAD.FileFormats.Cad.CadTables.CadBlockTableObject tableObject in cadImage.BlocksTables) | |
{ | |
if (string.Equals(tableObject.HardPointerToLayout, layout.ObjectHandle)) | |
{ | |
blockTableObjectReference = tableObject; | |
break; | |
} | |
} | |
if (blockTableObjectReference !=null) | |
{ | |
// Collection cadBlockEntity.Entities contains information about all entities on specific layout if this collection has no elements it means layout is a copy of Model layout and contains the same entities | |
Aspose.CAD.FileFormats.Cad.CadObjects.CadBlockEntity cadBlockEntity = cadImage.BlockEntities[blockTableObjectReference.BlockName]; | |
} | |
} | |
//Export to pdf | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
rasterizationOptions.AutomaticLayoutsScaling = true; | |
// Please, note: if cadBlockEntity collection mentioned above (for dwg) for selected layout or entitiesOnLayouts collection by layout's BlockTableRecordHandle (for dxf) is empty - export result file will be empty and you should draw Model layout instead | |
rasterizationOptions.Layouts = new[] { "Layout1" }; | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(MyDir + "SearchText_out.pdf", pdfOptions); | |
} | |
} | |
public static void SearchTextInDWGAutoCADFile() | |
{ | |
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir + "search.dwg"; | |
// Load an existing DWG file as CadImage. | |
CadImage cadImage = (CadImage) Image.Load(sourceFilePath); | |
// Search for text in the entities section | |
foreach (var entity in cadImage.Entities) { | |
IterateCADNodes(entity); | |
} | |
// Search for text in the block section | |
foreach (CadBlockEntity blockEntity in cadImage.BlockEntities.Values) { | |
foreach (var entity in blockEntity.Entities) { | |
IterateCADNodes(entity); | |
} | |
} | |
} | |
private static void IterateCADNodes(CadBaseEntity obj) | |
{ | |
switch (obj.TypeName) { | |
case CadEntityTypeName.TEXT: | |
CadText childObjectText = (CadText) obj; | |
Console.WriteLine(childObjectText.DefaultValue); | |
break; | |
case CadEntityTypeName.MTEXT: | |
CadMText childObjectMText = (CadMText) obj; | |
Console.WriteLine(childObjectMText.Text); | |
break; | |
case CadEntityTypeName.INSERT: | |
CadInsertObject childInsertObject = (CadInsertObject) obj; | |
foreach (var tempobj in childInsertObject.ChildObjects) { | |
IterateCADNodes(tempobj); | |
} | |
break; | |
case CadEntityTypeName.ATTDEF: | |
CadAttDef attDef = (CadAttDef) obj; | |
Console.WriteLine(attDef.DefaultString); | |
break; | |
case CadEntityTypeName.ATTRIB: | |
CadAttrib attAttrib = (CadAttrib) obj; | |
Console.WriteLine(attAttrib.DefaultText); | |
break; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string file = MyDir + "Multileaders.dwg"; | |
using (Image image = Image.Load(file)) | |
{ | |
// Test | |
FileFormats.Cad.CadImage cadImage = (FileFormats.Cad.CadImage)image; | |
Assert.AreNotEqual(cadImage.Entities.Length, 0); | |
CadMLeader cadMLeader = (CadMLeader)cadImage.Entities[2]; | |
Assert.AreEqual(cadMLeader.StyleDescription, "Standard"); | |
Assert.AreEqual(cadMLeader.LeaderStyleId, "12E"); | |
Assert.AreEqual(cadMLeader.ArrowHeadId1, "639"); | |
Assert.AreEqual(cadMLeader.LeaderLineTypeID, "14"); | |
CadMLeaderContextData context = cadMLeader.ContextData; | |
Assert.AreEqual(context.ArrowHeadSize, 30.0, 0.1); | |
Assert.AreEqual(context.BasePoint.X, 481, 1); | |
Assert.AreEqual(context.ContentScale, 1.0, 0.01); | |
Assert.AreEqual(context.DefaultText.Value, "This is multileader with huge text\\P{\\H1.5x;6666666666666666666666666666\\P}bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); | |
Assert.AreEqual(context.HasMText, true); | |
CadMLeaderNode mleaderNode = context.LeaderNode; | |
Assert.AreEqual(mleaderNode.LastLeaderLinePoint.X, 473, 1); | |
CadMLeaderLine leaderLine = mleaderNode.LeaderLine; | |
Assert.AreEqual(leaderLine.BreakEndPoint, null); | |
Assert.AreEqual(leaderLine.BreakPointIndex.Value, 0); | |
Assert.AreEqual(leaderLine.BreakStartPoint, null); | |
Assert.AreEqual(leaderLine.LeaderLineIndex.Value, 0); | |
Assert.AreEqual(leaderLine.LeaderPoints.Count, 4); | |
Assert.AreEqual(mleaderNode.BranchIndex, 0); | |
Assert.AreEqual(mleaderNode.DogLegLength, 8.0, 0.1); | |
Assert.AreEqual(context.HasMText, true); | |
Assert.AreEqual(context.TextAttachmentType.Value, 1); | |
Assert.AreEqual(context.TextBackgroundColor.Value, 18); | |
Assert.AreEqual(context.TextHeight, 20.0, 0.1); | |
Assert.AreEqual(context.TextStyleID.Value, "11"); | |
Assert.AreEqual(context.TextRotation.Value, 0.0, 0.01); | |
Assert.AreEqual(cadMLeader.ArrowHeadId1, "639"); | |
Assert.AreEqual(cadMLeader.LeaderType, 1); | |
Assert.AreEqual(cadMLeader.BlockContentColor, 0); | |
Assert.AreEqual(cadMLeader.LeaderLineColor, 0); | |
Assert.AreEqual(cadMLeader.TextHeight, 1.0, 0.01); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
List<CadBaseEntity> mtextList = new List<CadBaseEntity>(); | |
List<CadBaseEntity> attribList = new List<CadBaseEntity>(); | |
using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
foreach (var entity in cadImage.Entities) | |
{ | |
if (entity.TypeName == CadEntityTypeName.MTEXT) | |
{ | |
mtextList.Add(entity); | |
} | |
if (entity.TypeName == CadEntityTypeName.INSERT) | |
{ | |
foreach (var childObject in entity.ChildObjects) | |
{ | |
if (childObject.TypeName == CadEntityTypeName.ATTRIB) | |
{ | |
attribList.Add(childObject); | |
} | |
} | |
} | |
} | |
Assert.AreEqual(6, mtextList.Count); | |
Assert.AreEqual(34, attribList.Count); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
using (Image image = Image.Load(MyDir + "conic_pyramid.dxf")) | |
{ | |
using (FileStream stream = new FileStream(MyDir + "output_conic_pyramid.pdf", FileMode.Create)) | |
{ | |
PdfOptions pdfOptions = new PdfOptions(); | |
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions(); | |
pdfOptions.VectorRasterizationOptions = cadRasterizationOptions; | |
cadRasterizationOptions.PageWidth = 800; | |
cadRasterizationOptions.PageHeight = 600; | |
int idxError = 1; | |
cadRasterizationOptions.RenderResult += new CadRasterizationOptions.CadRenderHandler( | |
delegate (CadRenderResult result) | |
{ | |
Console.WriteLine("Tracking results of exporting"); | |
if (result.IsRenderComplete) | |
return; | |
Console.WriteLine("Have some problems:"); | |
foreach (RenderResult rr in result.Failures) | |
Console.WriteLine(string.Format("{0}. {1}, {2}", idxError++, rr.RenderCode.ToString(), | |
rr.Message)); | |
}); | |
Console.WriteLine("Exporting to pdf format"); | |
image.Save(stream, pdfOptions); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
// Add desired layers | |
rasterizationOptions.Layers = new string[] { "LayerA" }; | |
// Create an instance of PdfOptions | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "conic_pyramid_layer_out.pdf"; | |
//Export the DXF to PDF | |
image.Save(MyDir, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
// Specify desired layout name | |
rasterizationOptions.Layouts = new string[] { "Model" }; | |
// Create an instance of PdfOptions | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "conic_pyramid_layout_out.pdf"; | |
//Export the DXF to PDF | |
image.Save(MyDir, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.BackgroundColor = Aspose.CAD.Color.White; | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
// Create an instance of PdfOptions | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "conic_pyramid_out.pdf"; | |
//Export the DXF to PDF | |
image.Save(MyDir, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (var image = Image.Load("NRB-GRID-BLOCK-MD-PROVALVDK-241000-162000-45400.dgn")) | |
{ | |
var vectorOptions = new CadRasterizationOptions(); | |
vectorOptions.AutomaticLayoutsScaling = true; | |
vectorOptions.BackgroundColor = Color.Black; | |
vectorOptions.PageWidth = 500; | |
vectorOptions.PageHeight = 500; | |
WmfOptions wmfOptions = new WmfOptions() | |
{ | |
VectorRasterizationOptions = vectorOptions | |
}; | |
image.Save("NRB-GRID-BLOCK-MD-PROVALVDK-241000-162000-45400.dgn.wmf", wmfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.Layouts = new[] { "Model" }; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(MyDir + "conic_pyramid.pdf", pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
foreach (var file in new DirectoryInfo(MyDir).EnumerateFiles("conic.dxf")) | |
{ | |
// **************************** | |
// Set new font per document | |
// **************************** | |
using (var cadImage = (CadImage)Image.Load(file.FullName)) | |
{ | |
// Iterate over the items of CadStyleTableObject | |
foreach (CadStyleTableObject style in cadImage.Styles) | |
{ | |
// Set font name | |
style.PrimaryFontName = "Broadway"; | |
} | |
cadImage.Save(file.FullName + "_font.dxf"); | |
} | |
// **************************** | |
// Hide all "straight" lines | |
// **************************** | |
using (var cadImage = (CadImage)Image.Load(file.FullName)) | |
{ | |
foreach (var entity in cadImage.Entities) | |
{ | |
// Make lines invisible | |
if (entity.TypeName == CadEntityTypeName.LINE) | |
{ | |
entity.Visible = 0; | |
} | |
} | |
cadImage.Save(file.FullName + "_lines.dxf"); | |
} | |
// **************************** | |
// Manipulations with text | |
// **************************** | |
using (var cadImage = (CadImage)Image.Load(file.FullName)) | |
{ | |
foreach (var entity in cadImage.Entities) | |
{ | |
if (entity.TypeName == CadEntityTypeName.TEXT) | |
{ | |
((CadText)entity).DefaultValue = "New text here!!! :)"; | |
break; | |
} | |
} | |
cadImage.Save(file.FullName + "_text.dxf"); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "for_layers_test.dwf"; | |
using (var image = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
// Set image width & height | |
rasterizationOptions.PageWidth = 500; | |
rasterizationOptions.PageHeight = 500; | |
// Set the drawing to render at the center of image | |
// rasterizationOptions.CenterDrawing = true; | |
// Get the layers in an instance of CadLayersDictionary | |
var layersList = image.Layers; | |
// Iterate over the layers | |
foreach (var layerName in layersList.GetLayersNames()) | |
{ | |
// Display layer name for tracking | |
Console.WriteLine("Start with " + layerName); | |
// Add the layer name to the CadRasterizationOptions's layer list | |
rasterizationOptions.Layers = new string[] { "LayerA" }; | |
// Create an instance of JpegOptions (or any ImageOptions for raster formats) | |
var options = new Aspose.CAD.ImageOptions.JpegOptions(); | |
// Set VectorRasterizationOptions property to the instance of CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions; | |
//Export each layer to Jpeg format | |
image.Save(layerName + "_out.jpg", options); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
string outPath = MyDir + "conic_pyramid.jpg"; | |
using (CadImage image = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
ImageOptionsBase options = new JpegOptions(); | |
options.VectorRasterizationOptions = new CadRasterizationOptions() { PdfProductLocation = MyDir /*path to pdf product and licence*/ }; | |
options.VectorRasterizationOptions.PageHeight = 1000; | |
options.VectorRasterizationOptions.PageWidth = 1000; | |
image.Save(outPath, options); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
// any entities updates | |
cadImage.Save(MyDir+"conic.dxf"); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string inputFile = MyDir + "SLS-CW-CD-CE001-R01_blockClip.dxf"; | |
string outputFile = MyDir + "SLS-CW-CD-CE001-R01_blockClip.pdf"; | |
using (CadImage cadImage = (CadImage)Image.Load(inputFile)) | |
{ | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions | |
{ | |
BackgroundColor = Aspose.CAD.Color.White, | |
DrawType = Aspose.CAD.FileFormats.Cad.CadDrawTypeMode.UseObjectColor, | |
PageWidth = 1200, | |
PageHeight = 1600, | |
BorderX = 30, | |
BorderY = 5, | |
Layouts = new string[] { "Model" } | |
}; | |
PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions | |
{ | |
VectorRasterizationOptions = rasterizationOptions | |
}; | |
cadImage.Save(outputFile, pdfOptions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.UnitType = UnitType.Inch; | |
rasterizationOptions.DrawType = CadDrawTypeMode.UseObjectColor; | |
rasterizationOptions.BackgroundColor = Color.Black; | |
rasterizationOptions.Layouts = new string[] { "Model" }; | |
PdfOptions pdfOptions = new PdfOptions | |
{ | |
VectorRasterizationOptions = rasterizationOptions | |
}; | |
cadImage.Save(MyDir+"output.pdf", pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
// Create an instance of CadImage class and load the file. | |
using (Aspose.CAD.Image cadImage = (Aspose.CAD.Image)Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions class | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
// Set the Entities type property to Entities3D. | |
//rasterizationOptions.TypeOfEntities = TypeOfEntities.Entities3D; | |
rasterizationOptions.AutomaticLayoutsScaling = true; | |
rasterizationOptions.NoScaling = false; | |
rasterizationOptions.ContentAsBitmap = true; | |
// Set Layouts | |
rasterizationOptions.Layouts = new string[] { "Model" }; | |
// Create an instance of PDF options class | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "CADLayoutsToPDF_out.pdf"; | |
// Set Graphics options | |
rasterizationOptions.GraphicsOptions.SmoothingMode = SmoothingMode.HighQuality; | |
rasterizationOptions.GraphicsOptions.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; | |
rasterizationOptions.GraphicsOptions.InterpolationMode = InterpolationMode.HighQualityBicubic; | |
//Export to PDF by calling the Save method | |
cadImage.Save(MyDir, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
for (int i = 0; i < cadImage.Entities.Length; i++) | |
{ | |
if (cadImage.Entities[i].TypeName == CadEntityTypeName.INSERT) | |
{ | |
CadBlockEntity block = cadImage.BlockEntities[(cadImage.Entities[i] as CadInsertObject).Name]; | |
foreach (CadBaseEntity baseEntity in block.Entities) | |
{ | |
// processing of entities | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image cadImage = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 500; | |
rasterizationOptions.PageHeight = 500; | |
// rasterizationOptions.TypeOfEntities = TypeOfEntities.Entities3D; | |
rasterizationOptions.Layouts = new string[] { "Model" }; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "Export3DImagestoPDF_out.pdf"; | |
cadImage.Save(MyDir, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string fileName = MyDir + "18-12-11 9644 - site.dwf"; | |
using (Image image = Image.Load(fileName)) | |
{ | |
CadRasterizationOptions dwfRasterizationOptions = new CadRasterizationOptions(); | |
dwfRasterizationOptions.PageHeight = 500; | |
dwfRasterizationOptions.PageWidth = 500; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = dwfRasterizationOptions; | |
// export | |
string outPath = MyDir + "18-12-11 9644 - site.pdf"; | |
image.Save(outPath, pdfOptions); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string inputFile = MyDir + "18-12-11 9644 - site.dwf"; | |
using (Image image = Image.Load(inputFile)) | |
{ | |
BmpOptions bmpOptions = new BmpOptions(); | |
var dwfRasterizationOptions = new CadRasterizationOptions(); | |
bmpOptions.VectorRasterizationOptions = dwfRasterizationOptions; | |
dwfRasterizationOptions.PageHeight = 500; | |
dwfRasterizationOptions.PageWidth = 500; | |
// export | |
string outPath = MyDir + "18-12-11 9644 - site.bmp"; | |
image.Save(outPath, bmpOptions); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Run() | |
{ | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "themepark.plt"; | |
Image image = Image.Load((sourceFilePath)); | |
ImageOptionsBase imageOptions = new JpegOptions(); | |
CadRasterizationOptions options = new CadRasterizationOptions | |
{ | |
PageHeight = 500, | |
PageWidth = 1000, | |
}; | |
imageOptions.VectorRasterizationOptions = options; | |
image.Save((MyDir+"themepark.jpg"), imageOptions); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
using(CadImage cadImage = (CadImage)Image.Load(MyDir + "Drawing11.dwg")) { | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.Text = "Watermark message"; | |
watermark.InitialTextHeight = 40; | |
watermark.InsertionPoint = new Cad3DPoint(300, 40); | |
watermark.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(watermark); | |
// or add more simple entity like Text | |
CadText text = new CadText(); | |
text.DefaultValue = "Watermark text"; | |
text.TextHeight = 40; | |
text.FirstAlignment = new Cad3DPoint(300, 40); | |
text.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(text); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
rasterizationOptions.Layouts = new[] { "Model" }; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(MyDir + "AddWatermark_out.pdf", pdfOptions); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCFF(); | |
using (Image image = Image.Load(MyDir + "WineBottle_Die.cf2")) | |
{ | |
var options = new PdfOptions(); | |
image.Save(MyDir + "WineBottle_Die_out.pdf",options); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
var outPath = Path.Combine(MyDir, "FreePointOfView_out.jpg"); | |
using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
JpegOptions options = new JpegOptions | |
{ | |
VectorRasterizationOptions = new CadRasterizationOptions | |
{ | |
PageWidth = 1500, PageHeight = 1500 | |
} | |
}; | |
float xAngle = 10; //Angle of rotation along the X axis | |
float yAngle = 30; //Angle of rotation along the Y axis | |
float zAngle = 40; //Angle of rotation along the Z axis | |
((CadRasterizationOptions)(options.VectorRasterizationOptions)).ObserverPoint = new ObserverPoint(xAngle, yAngle, zAngle); | |
cadImage.Save(outPath, options); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-.NET | |
string SourceDir = RunExamples.GetDataDir_DWGDrawings(); | |
string OutputDir = RunExamples.GetDataDir_Output(); | |
using (Image cadDrawing = Image.Load(SourceDir + "Drawing11.dwg")) | |
{ | |
var rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = cadDrawing.Size.Width; | |
rasterizationOptions.PageHeight = cadDrawing.Size.Height; | |
using (var its = new InterruptionTokenSource()) | |
{ | |
PdfOptions CADf = new PdfOptions(); | |
CADf.VectorRasterizationOptions = rasterizationOptions; | |
CADf.InterruptionToken = its.Token; | |
var exportTask = Task.Factory.StartNew(() => | |
{ | |
cadDrawing.Save(OutputDir + "PutTimeoutOnSave_out.pdf", CADf); | |
}); | |
Thread.Sleep(10000); | |
its.Interrupt(); | |
exportTask.Wait(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
using (CadImage cadImage = (CadImage)Image.Load(MyDir + "City skyway map.dwg")) | |
{ | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1000; | |
rasterizationOptions.PageHeight = 1000; | |
//custom sizes for several layouts | |
rasterizationOptions.LayoutPageSizes.Add("ANSI C Plot", new SizeF(500, 1000)); | |
rasterizationOptions.LayoutPageSizes.Add("8.5 x 11 Plot", new SizeF(1000, 100)); | |
PdfOptions pdfOptions = new PdfOptions() { VectorRasterizationOptions = rasterizationOptions }; | |
cadImage.Save(MyDir + "singlePDF_out.pdf", pdfOptions); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string dwgPathToFile = MyDir + "AutoCad_Sample.dwg"; | |
using (CadImage cadImage = (CadImage)Image.Load(dwgPathToFile)) | |
{ | |
foreach (CadBaseEntity entity in cadImage.Entities) | |
{ | |
if (entity is CadInsertObject) | |
{ | |
CadBlockEntity block = cadImage.BlockEntities[((CadInsertObject)entity).Name]; | |
if (!string.IsNullOrEmpty(block.XRefPathName.Value)) | |
{ | |
block.XRefPathName.Value = "new file reference.dwg"; | |
} | |
} | |
if (entity.Hyperlink == "https://products.aspose.com") | |
{ | |
entity.Hyperlink = "https://www.aspose.com"; | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Setfile name path as other examples | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "example.ifc"; | |
using (IfcImage cadImage = (IfcImage)Image.Load(sourceFilePath)) | |
{ | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 100; | |
rasterizationOptions.PageHeight = 100; | |
PngOptions pngOptions = new PngOptions(); | |
pngOptions.VectorRasterizationOptions = rasterizationOptions; | |
//Set output path as well | |
string outPath = sourceFilePath + ".png"; | |
cadImage.Save(outPath, pngOptions); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_IGESDrawings(); | |
string sourceFilePath = MyDir + "figa2.igs"; | |
using (Image cadImage = Image.Load(sourceFilePath)) | |
{ | |
CadRasterizationOptions options = new CadRasterizationOptions | |
{ | |
PageHeight = 1000, | |
PageWidth = 1000, | |
}; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = options; | |
cadImage.Save(MyDir+ "figa2.pdf", pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string MyDir = RunExamples.GetDataDir_OBJDrawings(); | |
using (Aspose.CAD.Image CADDoc = Aspose.CAD.Image.Load(MyDir + "example-580-W.obj")) | |
{ | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = | |
new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = CADDoc.Size.Width; | |
rasterizationOptions.PageHeight = CADDoc.Size.Height; | |
Aspose.CAD.ImageOptions.PdfOptions CADf = new Aspose.CAD.ImageOptions.PdfOptions(); | |
CADf.VectorRasterizationOptions = rasterizationOptions; | |
CADDoc.Save(MyDir + "example-580-W_custom.pdf", CADf); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_PLTDrawings(); | |
string sourceFilePath = MyDir + "50states.plt"; | |
using (Image cadImage = Image.Load(sourceFilePath)) | |
{ | |
ImageOptionsBase imageOptions = new JpegOptions(); | |
CadRasterizationOptions options = new CadRasterizationOptions | |
{ | |
PageHeight = 500, | |
PageWidth = 1000, | |
}; | |
imageOptions.VectorRasterizationOptions = options; | |
cadImage.Save(MyDir+ "50states.jpg", imageOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_PLTDrawings(); | |
string sourceFilePath = MyDir + "50states.plt"; | |
using (Image cadImage = Image.Load(sourceFilePath)) | |
{ | |
CadRasterizationOptions options = new CadRasterizationOptions | |
{ | |
PageHeight = 1600, | |
PageWidth = 1600, | |
DrawType= CadDrawTypeMode.UseObjectColor, | |
BackgroundColor=Color.White | |
}; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = options; | |
cadImage.Save(MyDir+ "50states.pdf", pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "galeon.stl"; | |
using (var cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
var rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 100; | |
rasterizationOptions.PageHeight = 100; | |
PngOptions pngOptions = new PngOptions(); | |
pngOptions.VectorRasterizationOptions = rasterizationOptions; | |
string outPath = sourceFilePath + ".png"; | |
cadImage.Save(outPath, pngOptions); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string fileName = "exampleFile"; | |
string file = string.Format("{0}.plt", fileName); | |
string outFile = string.Format("{0}.svg", fileName); | |
using (FileStream inStream = new FileStream(file, FileMode.Open)) | |
using (Image image = Image.Load(inStream)) | |
using (FileStream stream = new FileStream(outFile, FileMode.Create)) | |
{ | |
ImageOptionsBase options = new SvgOptions(); | |
options.VectorRasterizationOptions = new CadRasterizationOptions | |
{ | |
LineScale = 0.25f | |
}; | |
image.Save(stream, options); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (CadImage cadImage = (CadImage) Image.Load(MyDir + "Drawing.cf2")) | |
{ | |
//string to store extracted text from the CF2 file | |
string TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
foreach (CadBaseEntity CadEntity in cadImage.Entities) | |
{ | |
if (CadEntity.TypeName == CadEntityTypeName.TEXT) | |
{ | |
CadText CadTextObject = (CadText) CadEntity; | |
TextExtractedFromFile += CadTextObject.DefaultValue; | |
} | |
} | |
//Save the text extracted from CF2 file using File Stream | |
FileStream FStream = new FileStream(MyDir + "ExtractTextFromDXFFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.WriteLine(TextExtractedFromFile); | |
SWriter.Flush(); | |
//Close file objects | |
SWriter.Close(); | |
FStream.Close(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (DgnImage cadImage = (DgnImage) Image.Load(MyDir + "Drawing.dgn")) | |
{ | |
//string to store extracted text from the DGN file | |
string TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
foreach (string CadText in cadImage.GetStrings()) | |
{ | |
TextExtractedFromFile += CadText + System.Environment.NewLine; | |
} | |
//Save the text extracted from DGN file using File Stream | |
FileStream FStream = new FileStream(MyDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.WriteLine(TextExtractedFromFile); | |
SWriter.Flush(); | |
//Close file objects | |
SWriter.Close(); | |
FStream.Close(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (CadImage cadImage = (CadImage) Image.Load(MyDir + "Drawing.dwf")) | |
{ | |
//string to store extracted text from the DWF file | |
string TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
foreach (CadBaseEntity CadEntity in cadImage.Entities) | |
{ | |
if (CadEntity.TypeName == CadEntityTypeName.TEXT) | |
{ | |
CadText CadTextObject = (CadText) CadEntity; | |
TextExtractedFromFile += CadTextObject.DefaultValue; | |
} | |
} | |
//Save the text extracted from DWF file using File Stream | |
FileStream FStream = new FileStream(MyDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.WriteLine(TextExtractedFromFile); | |
SWriter.Flush(); | |
//Close file objects | |
SWriter.Close(); | |
FStream.Close(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (CadImage cadImage = (CadImage) Image.Load(MyDir + "Drawing.dwfx")) | |
{ | |
//string to store extracted text from the DWFX file | |
string TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
foreach (CadBaseEntity CadEntity in cadImage.Entities) | |
{ | |
if (CadEntity.TypeName == CadEntityTypeName.TEXT) | |
{ | |
CadText CadTextObject = (CadText) CadEntity; | |
TextExtractedFromFile += CadTextObject.DefaultValue; | |
} | |
} | |
//Save the text extracted from DWFX file using File Stream | |
FileStream FStream = new FileStream(MyDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.WriteLine(TextExtractedFromFile); | |
SWriter.Flush(); | |
//Close file objects | |
SWriter.Close(); | |
FStream.Close(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (CadImage cadImage = (CadImage) Image.Load(MyDir + "Drawing.dwg")) | |
{ | |
//string to store extracted text from the DWG file | |
string TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
foreach (CadBaseEntity CadEntity in cadImage.Entities) | |
{ | |
if (CadEntity.TypeName == CadEntityTypeName.TEXT) | |
{ | |
CadText CadTextObject = (CadText) CadEntity; | |
TextExtractedFromFile += CadTextObject.DefaultValue; | |
} | |
} | |
//Save the text extracted from DWG file using File Stream | |
FileStream FStream = new FileStream(MyDir + "ExtractTextFromDXFFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.WriteLine(TextExtractedFromFile); | |
SWriter.Flush(); | |
//Close file objects | |
SWriter.Close(); | |
FStream.Close(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (CadImage cadImage = (CadImage) Image.Load(MyDir + "Drawing.dwt")) | |
{ | |
//string to store extracted text from the DWT file | |
string TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
foreach (CadBaseEntity CadEntity in cadImage.Entities) | |
{ | |
if (CadEntity.TypeName == CadEntityTypeName.TEXT) | |
{ | |
CadText CadTextObject = (CadText) CadEntity; | |
TextExtractedFromFile += CadTextObject.DefaultValue; | |
} | |
} | |
//Save the text extracted from DWT file using File Stream | |
FileStream FStream = new FileStream(MyDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.WriteLine(TextExtractedFromFile); | |
SWriter.Flush(); | |
//Close file objects | |
SWriter.Close(); | |
FStream.Close(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (CadImage cadImage = (CadImage) Image.Load(MyDir + "Drawing.dxf")) | |
{ | |
//string to store extracted text from the DXF file | |
string TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
foreach (CadBaseEntity CadEntity in cadImage.Entities) | |
{ | |
if (CadEntity.TypeName == CadEntityTypeName.TEXT) | |
{ | |
CadText CadTextObject = (CadText) CadEntity; | |
TextExtractedFromFile += CadTextObject.DefaultValue; | |
} | |
} | |
//Save the text extracted from DXF file using File Stream | |
FileStream FStream = new FileStream(MyDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.WriteLine(TextExtractedFromFile); | |
SWriter.Flush(); | |
//Close file objects | |
SWriter.Close(); | |
FStream.Close(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (CadImage cadImage = (CadImage) Image.Load(MyDir + "Drawing.fbx")) | |
{ | |
//string to store extracted text from the FBX file | |
string TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
foreach (CadBaseEntity CadEntity in cadImage.Entities) | |
{ | |
if (CadEntity.TypeName == CadEntityTypeName.TEXT) | |
{ | |
CadText CadTextObject = (CadText) CadEntity; | |
TextExtractedFromFile += CadTextObject.DefaultValue; | |
} | |
} | |
//Save the text extracted from FBX file using File Stream | |
FileStream FStream = new FileStream(MyDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.WriteLine(TextExtractedFromFile); | |
SWriter.Flush(); | |
//Close file objects | |
SWriter.Close(); | |
FStream.Close(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (IfcImage cadImage = (IfcImage) Image.Load(MyDir + "Drawing.ifc")) | |
{ | |
//string to store extracted text from the IFC file | |
string TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
foreach (string CadText in cadImage.GetStrings()) | |
{ | |
TextExtractedFromFile += CadText + System.Environment.NewLine; | |
} | |
//Save the text extracted from IFC file using File Stream | |
FileStream FStream = new FileStream(MyDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.WriteLine(TextExtractedFromFile); | |
SWriter.Flush(); | |
//Close file objects | |
SWriter.Close(); | |
FStream.Close(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (IgesImage cadImage = (IgesImage) Image.Load(MyDir + "Drawing.iges")) | |
{ | |
//string to store extracted text from the IGES file | |
string TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
foreach (string CadText in cadImage.GetStrings()) | |
{ | |
TextExtractedFromFile += CadText + System.Environment.NewLine; | |
} | |
//Save the text extracted from IGES file using File Stream | |
FileStream FStream = new FileStream(MyDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.WriteLine(TextExtractedFromFile); | |
SWriter.Flush(); | |
//Close file objects | |
SWriter.Close(); | |
FStream.Close(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (ObjImage cadImage = (ObjImage) Image.Load(MyDir + "Drawing.obj")) | |
{ | |
//string to store extracted text from the OBJ file | |
string TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
foreach (string CadText in cadImage.GetStrings()) | |
{ | |
TextExtractedFromFile += CadText + System.Environment.NewLine; | |
} | |
//Save the text extracted from OBJ file using File Stream | |
FileStream FStream = new FileStream(MyDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.WriteLine(TextExtractedFromFile); | |
SWriter.Flush(); | |
//Close file objects | |
SWriter.Close(); | |
FStream.Close(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (PltImage cadImage = (PltImage) Image.Load(MyDir + "Drawing.plt")) | |
{ | |
//string to store extracted text from the PLT file | |
string TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
foreach (string CadText in cadImage.GetStrings()) | |
{ | |
TextExtractedFromFile += CadText + System.Environment.NewLine; | |
} | |
//Save the text extracted from PLT file using File Stream | |
FileStream FStream = new FileStream(MyDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.WriteLine(TextExtractedFromFile); | |
SWriter.Flush(); | |
//Close file objects | |
SWriter.Close(); | |
FStream.Close(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (CadImage cadImage = (CadImage) Image.Load(MyDir + "Drawing.stl")) | |
{ | |
//string to store extracted text from the STL file | |
string TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
foreach (CadBaseEntity CadEntity in cadImage.Entities) | |
{ | |
if (CadEntity.TypeName == CadEntityTypeName.TEXT) | |
{ | |
CadText CadTextObject = (CadText) CadEntity; | |
TextExtractedFromFile += CadTextObject.DefaultValue; | |
} | |
} | |
//Save the text extracted from STL file using File Stream | |
FileStream FStream = new FileStream(MyDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.WriteLine(TextExtractedFromFile); | |
SWriter.Flush(); | |
//Close file objects | |
SWriter.Close(); | |
FStream.Close(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (SvgImage cadImage = (SvgImage) Image.Load(MyDir + "Drawing.svg")) | |
{ | |
//string to store extracted text from the SVG file | |
string TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
foreach (string CadText in cadImage.GetStrings()) | |
{ | |
TextExtractedFromFile += CadText + System.Environment.NewLine; | |
} | |
//Save the text extracted from SVG file using File Stream | |
FileStream FStream = new FileStream(MyDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.WriteLine(TextExtractedFromFile); | |
SWriter.Flush(); | |
//Close file objects | |
SWriter.Close(); | |
FStream.Close(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load CF2 in an instance of Image via its Load method | |
using (var image = Aspose.CAD.Image.Load("template.cf2")) | |
{ | |
// create an instance of CadRasterizationOptions and set page height & width | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
{ | |
PageWidth = 1600, | |
PageHeight = 1600 | |
}; | |
// create an instance of TiffOptions | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// export CF2 to TIFF | |
image.Save("output.tiff", options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string output = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".tiff"; | |
// load DGN file in an instance of Image | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load("template.dgn")) | |
{ | |
// create an instance of CadRasterizationOptions | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1200; | |
rasterizationOptions.PageHeight = 1200; | |
// create an instance of TiffOptions for the resultant image | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set VectorRasterizationOptions property | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// save DGN as TIFF image | |
image.Save(output, options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string output = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".tiff"; | |
// load DWF file in an instance of Image | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load("template.dwf")) | |
{ | |
// create an instance of CadRasterizationOptions | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1200; | |
rasterizationOptions.PageHeight = 1200; | |
// create an instance of TiffOptions for the resultant image | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set VectorRasterizationOptions property | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// save DWF as TIFF image | |
image.Save(output, options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load DWFX in an instance of Image via its Load method | |
using (var image = Aspose.CAD.Image.Load("template.dwfx")) | |
{ | |
// create an instance of CadRasterizationOptions and set page height & width | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
{ | |
PageWidth = 1600, | |
PageHeight = 1600 | |
}; | |
// create an instance of TiffOptions | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// export DWFX to TIFF | |
image.Save("output.tiff", options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string output = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".tiff"; | |
// load DWG file in an instance of Image | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load("template.dwg")) | |
{ | |
// create an instance of CadRasterizationOptions | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1200; | |
rasterizationOptions.PageHeight = 1200; | |
// create an instance of TiffOptions for the resultant image | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set VectorRasterizationOptions property | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// save DWG as TIFF image | |
image.Save(output, options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load DWT in an instance of Image via its Load method | |
using (var image = Aspose.CAD.Image.Load("template.dwt")) | |
{ | |
// create an instance of CadRasterizationOptions and set page height & width | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
{ | |
PageWidth = 1600, | |
PageHeight = 1600 | |
}; | |
// create an instance of TiffOptions | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// export DWT to TIFF | |
image.Save("output.tiff", options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string output = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".tiff"; | |
// load DXF file in an instance of Image | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load("template.dxf")) | |
{ | |
// create an instance of CadRasterizationOptions | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1200; | |
rasterizationOptions.PageHeight = 1200; | |
// create an instance of TiffOptions for the resultant image | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set VectorRasterizationOptions property | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// save DXF as TIFF image | |
image.Save(output, options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load FBX in an instance of Image via its Load method | |
using (var image = Aspose.CAD.Image.Load("template.fbx")) | |
{ | |
// create an instance of CadRasterizationOptions and set page height & width | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
{ | |
PageWidth = 1600, | |
PageHeight = 1600 | |
}; | |
// create an instance of TiffOptions | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// export FBX to TIFF | |
image.Save("output.tiff", options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string output = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".tiff"; | |
// load IFC file in an instance of Image | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load("template.ifc")) | |
{ | |
// create an instance of CadRasterizationOptions | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1200; | |
rasterizationOptions.PageHeight = 1200; | |
// create an instance of TiffOptions for the resultant image | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set VectorRasterizationOptions property | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// save IFC as TIFF image | |
image.Save(output, options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load IGEC in an instance of Image via its Load method | |
using (var image = Aspose.CAD.Image.Load("template.iges")) | |
{ | |
// create an instance of CadRasterizationOptions and set page height & width | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
{ | |
PageWidth = 1600, | |
PageHeight = 1600 | |
}; | |
// create an instance of TiffOptions | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// export IGES to TIFF | |
image.Save("output.tiff", options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load OBJ in an instance of Image via its Load method | |
using (var image = Aspose.CAD.Image.Load("template.obj")) | |
{ | |
// create an instance of CadRasterizationOptions and set page height & width | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
{ | |
PageWidth = 1600, | |
PageHeight = 1600 | |
}; | |
// create an instance of TiffOptions | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// export OBJ to TIFF | |
image.Save("output.tiff", options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load PLT in an instance of Image via its Load method | |
using (var image = Aspose.CAD.Image.Load("template.plt")) | |
{ | |
// create an instance of CadRasterizationOptions and set page height & width | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
{ | |
PageWidth = 1600, | |
PageHeight = 1600 | |
}; | |
// create an instance of TiffOptions | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// export PLT to TIFF | |
image.Save("output.tiff", options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string output = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".tiff"; | |
// load STL file in an instance of Image | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load("template.stl")) | |
{ | |
// create an instance of CadRasterizationOptions | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1200; | |
rasterizationOptions.PageHeight = 1200; | |
// create an instance of TiffOptions for the resultant image | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set VectorRasterizationOptions property | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// save STL as TIFF image | |
image.Save(output, options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load SVG in an instance of Image via its Load method | |
using (var image = Aspose.CAD.Image.Load("template.svg")) | |
{ | |
// create an instance of CadRasterizationOptions and set page height & width | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions() | |
{ | |
PageWidth = 1600, | |
PageHeight = 1600 | |
}; | |
// create an instance of TiffOptions | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// export SVG to TIFF | |
image.Save("output.tiff", options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (CadImage cadImage = (CadImage) Image.Load(MyDir + "Drawing.cf2")) | |
{ | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.Text = "Watermark message"; | |
watermark.InitialTextHeight = 40; | |
watermark.InsertionPoint = new Cad3DPoint(300, 40); | |
watermark.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(watermark); | |
// or add more simple entity like Text | |
CadText text = new CadText(); | |
text.DefaultValue = "Watermark text"; | |
text.TextHeight = 40; | |
text.FirstAlignment = new Cad3DPoint(300, 40); | |
text.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(text); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
rasterizationOptions.Layouts = new[] {"Model"}; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(MyDir + "AddWatermark_out.pdf", pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (CadImage cadImage = (CadImage) Image.Load(MyDir + "Drawing.dgn")) | |
{ | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.Text = "Watermark message"; | |
watermark.InitialTextHeight = 40; | |
watermark.InsertionPoint = new Cad3DPoint(300, 40); | |
watermark.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(watermark); | |
// or add more simple entity like Text | |
CadText text = new CadText(); | |
text.DefaultValue = "Watermark text"; | |
text.TextHeight = 40; | |
text.FirstAlignment = new Cad3DPoint(300, 40); | |
text.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(text); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
rasterizationOptions.Layouts = new[] {"Model"}; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(MyDir + "AddWatermark_out.pdf", pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (CadImage cadImage = (CadImage) Image.Load(MyDir + "Drawing.dwf")) | |
{ | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.Text = "Watermark message"; | |
watermark.InitialTextHeight = 40; | |
watermark.InsertionPoint = new Cad3DPoint(300, 40); | |
watermark.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(watermark); | |
// or add more simple entity like Text | |
CadText text = new CadText(); | |
text.DefaultValue = "Watermark text"; | |
text.TextHeight = 40; | |
text.FirstAlignment = new Cad3DPoint(300, 40); | |
text.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(text); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
rasterizationOptions.Layouts = new[] {"Model"}; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(MyDir + "AddWatermark_out.pdf", pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (CadImage cadImage = (CadImage) Image.Load(MyDir + "Drawing.dwfx")) | |
{ | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.Text = "Watermark message"; | |
watermark.InitialTextHeight = 40; | |
watermark.InsertionPoint = new Cad3DPoint(300, 40); | |
watermark.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(watermark); | |
// or add more simple entity like Text | |
CadText text = new CadText(); | |
text.DefaultValue = "Watermark text"; | |
text.TextHeight = 40; | |
text.FirstAlignment = new Cad3DPoint(300, 40); | |
text.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(text); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
rasterizationOptions.Layouts = new[] {"Model"}; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(MyDir + "AddWatermark_out.pdf", pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (CadImage cadImage = (CadImage) Image.Load(MyDir + "Drawing.dwg")) | |
{ | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.Text = "Watermark message"; | |
watermark.InitialTextHeight = 40; | |
watermark.InsertionPoint = new Cad3DPoint(300, 40); | |
watermark.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(watermark); | |
// or add more simple entity like Text | |
CadText text = new CadText(); | |
text.DefaultValue = "Watermark text"; | |
text.TextHeight = 40; | |
text.FirstAlignment = new Cad3DPoint(300, 40); | |
text.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(text); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
rasterizationOptions.Layouts = new[] {"Model"}; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(MyDir + "AddWatermark_out.pdf", pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (CadImage cadImage = (CadImage) Image.Load(MyDir + "Drawing.dwt")) | |
{ | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.Text = "Watermark message"; | |
watermark.InitialTextHeight = 40; | |
watermark.InsertionPoint = new Cad3DPoint(300, 40); | |
watermark.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(watermark); | |
// or add more simple entity like Text | |
CadText text = new CadText(); | |
text.DefaultValue = "Watermark text"; | |
text.TextHeight = 40; | |
text.FirstAlignment = new Cad3DPoint(300, 40); | |
text.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(text); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
rasterizationOptions.Layouts = new[] {"Model"}; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(MyDir + "AddWatermark_out.pdf", pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (CadImage cadImage = (CadImage) Image.Load(MyDir + "Drawing.dxf")) | |
{ | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.Text = "Watermark message"; | |
watermark.InitialTextHeight = 40; | |
watermark.InsertionPoint = new Cad3DPoint(300, 40); | |
watermark.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(watermark); | |
// or add more simple entity like Text | |
CadText text = new CadText(); | |
text.DefaultValue = "Watermark text"; | |
text.TextHeight = 40; | |
text.FirstAlignment = new Cad3DPoint(300, 40); | |
text.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(text); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
rasterizationOptions.Layouts = new[] {"Model"}; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(MyDir + "AddWatermark_out.pdf", pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (CadImage cadImage = (CadImage) Image.Load(MyDir + "Drawing.fbx")) | |
{ | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.Text = "Watermark message"; | |
watermark.InitialTextHeight = 40; | |
watermark.InsertionPoint = new Cad3DPoint(300, 40); | |
watermark.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(watermark); | |
// or add more simple entity like Text | |
CadText text = new CadText(); | |
text.DefaultValue = "Watermark text"; | |
text.TextHeight = 40; | |
text.FirstAlignment = new Cad3DPoint(300, 40); | |
text.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(text); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
rasterizationOptions.Layouts = new[] {"Model"}; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(MyDir + "AddWatermark_out.pdf", pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (CadImage cadImage = (CadImage) Image.Load(MyDir + "Drawing.ifc")) | |
{ | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.Text = "Watermark message"; | |
watermark.InitialTextHeight = 40; | |
watermark.InsertionPoint = new Cad3DPoint(300, 40); | |
watermark.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(watermark); | |
// or add more simple entity like Text | |
CadText text = new CadText(); | |
text.DefaultValue = "Watermark text"; | |
text.TextHeight = 40; | |
text.FirstAlignment = new Cad3DPoint(300, 40); | |
text.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(text); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
rasterizationOptions.Layouts = new[] {"Model"}; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(MyDir + "AddWatermark_out.pdf", pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (CadImage cadImage = (CadImage) Image.Load(MyDir + "Drawing.iges")) | |
{ | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.Text = "Watermark message"; | |
watermark.InitialTextHeight = 40; | |
watermark.InsertionPoint = new Cad3DPoint(300, 40); | |
watermark.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(watermark); | |
// or add more simple entity like Text | |
CadText text = new CadText(); | |
text.DefaultValue = "Watermark text"; | |
text.TextHeight = 40; | |
text.FirstAlignment = new Cad3DPoint(300, 40); | |
text.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(text); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
rasterizationOptions.Layouts = new[] {"Model"}; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(MyDir + "AddWatermark_out.pdf", pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (CadImage cadImage = (CadImage) Image.Load(MyDir + "Drawing.obj")) | |
{ | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.Text = "Watermark message"; | |
watermark.InitialTextHeight = 40; | |
watermark.InsertionPoint = new Cad3DPoint(300, 40); | |
watermark.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(watermark); | |
// or add more simple entity like Text | |
CadText text = new CadText(); | |
text.DefaultValue = "Watermark text"; | |
text.TextHeight = 40; | |
text.FirstAlignment = new Cad3DPoint(300, 40); | |
text.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(text); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
rasterizationOptions.Layouts = new[] {"Model"}; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(MyDir + "AddWatermark_out.pdf", pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (CadImage cadImage = (CadImage) Image.Load(MyDir + "Drawing.plt")) | |
{ | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.Text = "Watermark message"; | |
watermark.InitialTextHeight = 40; | |
watermark.InsertionPoint = new Cad3DPoint(300, 40); | |
watermark.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(watermark); | |
// or add more simple entity like Text | |
CadText text = new CadText(); | |
text.DefaultValue = "Watermark text"; | |
text.TextHeight = 40; | |
text.FirstAlignment = new Cad3DPoint(300, 40); | |
text.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(text); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
rasterizationOptions.Layouts = new[] {"Model"}; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(MyDir + "AddWatermark_out.pdf", pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (CadImage cadImage = (CadImage) Image.Load(MyDir + "Drawing.stl")) | |
{ | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.Text = "Watermark message"; | |
watermark.InitialTextHeight = 40; | |
watermark.InsertionPoint = new Cad3DPoint(300, 40); | |
watermark.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(watermark); | |
// or add more simple entity like Text | |
CadText text = new CadText(); | |
text.DefaultValue = "Watermark text"; | |
text.TextHeight = 40; | |
text.FirstAlignment = new Cad3DPoint(300, 40); | |
text.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(text); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
rasterizationOptions.Layouts = new[] {"Model"}; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(MyDir + "AddWatermark_out.pdf", pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
using (CadImage cadImage = (CadImage) Image.Load(MyDir + "Drawing.svg")) | |
{ | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.Text = "Watermark message"; | |
watermark.InitialTextHeight = 40; | |
watermark.InsertionPoint = new Cad3DPoint(300, 40); | |
watermark.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(watermark); | |
// or add more simple entity like Text | |
CadText text = new CadText(); | |
text.DefaultValue = "Watermark text"; | |
text.TextHeight = 40; | |
text.FirstAlignment = new Cad3DPoint(300, 40); | |
text.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(text); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
rasterizationOptions.Layouts = new[] {"Model"}; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(MyDir + "AddWatermark_out.pdf", pdfOptions); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment