Exportation CAD
Exporter des images 3D AutoCAD au format PDF
Aspose.CAD vous permet d’exporter des images 3D AutoCAD au format PDF. Veuillez utiliser les Aspose.CAD.ImageOptions.CadRasterizationOptions pour spécifier que vous souhaitez exporter des entités 3D.
Le code d’exemple suivant charge un fichier AutoCAD 3D et l’exporte au format PDF. Une fois le fichier converti en PDF, vous pouvez l’ouvrir avec votre visualiseur PDF préféré.
// 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); | |
} |
Exporter des mises en page CAD au format PDF
Aspose.CAD pour .NET vous permet d’exporter des mises en page CAD au format PDF. La méthode Save de la classe CadImage peut être utilisée pour exporter la ou les mises en page au format PDF.
Le code d’exemple suivant charge un fichier CAD et exporte sa mise en page “Modèle” au format PDF. Une fois le fichier converti en PDF, vous pouvez l’ouvrir avec votre visualiseur PDF préféré.
// 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); | |
} |
Support pour la configuration de la plume dans l’exportation
Aspose.CAD pour .NET vous permet d’ajouter des options de plume dans les propriétés d’exportation de CAD. En utilisant CadRasterizationOptions, nous pouvons définir les options de propriétés de plume.
Le code ci-dessous est un exemple pour atteindre les exigences spécifiées.
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); | |
Décomposer l’objet d’insertion CAD
Aspose.CAD pour .NET vous permet de décomposer les objets CAD et de traiter des entités séparées à l’intérieur de l’insertion. Le code ci-dessous est un exemple pour atteindre les exigences spécifiées.
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 | |
} | |
} | |
} | |
Support pour les entités ACAD Proxy
Aspose.CAD pour .NET vous permet de lire et d’exporter des entités ACAD_PROXY_ENTITY. Le code ci-dessous est un exemple pour atteindre les exigences spécifiées.
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); | |
} |
Intégrer le format IGES
Aspose.CAD pour .NET vous permet de lire et d’exporter le format IGES. Le code ci-dessous est un exemple pour atteindre les exigences spécifiées.
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); | |
} |
Support pour les modèles de mailles
Aspose.CAD pour .NET vous permet d’implémenter et de compter les modèles de mailles comme les arêtes, les sommets et les faces qui utilisent une représentation polygonale. Le code ci-dessous est un exemple pour atteindre les exigences spécifiées.
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); | |
} | |
} |
Définir un point de vue personnalisé
Aspose.CAD pour .NET vous permet de définir un point de vue personnalisé pour la mise en page du modèle. En utilisant VectorRasterizationOptions, vous pouvez définir un point de vue personnalisé. Exemple de code ci-dessous montrant comment définir un point de vue personnalisé.
// 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); | |
} |