Search text in DWG and display only that entity in output

Hello,

I just started trying Aspose CAD with .Net. My requirement is that I need to search for text across all entities and display only the entity that matches the search and output it as an image. I reviewed your docs and was able get some code to find all entities in dwg file, but wasn’t sure how I can export only a certain entity with text to an output image.

Please let me know if you need any more details.

Thank you!

@udaychekuru,

I have observed your requirements and regret to share that at present the requested support is unavailable in Aspose.CAD for .NET. An issue with ID CADNET-418 has been created in our issue tracking system to further investigate the requirement. This thread has been linked with the issue so that you may be automatically notified once the issue will be fixed.

@udaychekuru,

I suggest you to please try using following sample code on your end.

Aspose.CAD.Image 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 MyDir =  "result_out.pdf";

// Export the CAD to PDF
cadImage.Save(MyDir, pdfOptions);

@udaychekuru,

Can you please share the feedback if the suggested code snippet in my previous reply has worked on your end. Please share your feedback so that we may close the issue in our issue tracking system.

The issues you have found earlier (filed as CADNET-418) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by mudassir.fayyaz