Hi, I need to get a preview for each block. I managed to get image for every block. But the block is not in the center of the image. How to place each block in the center of image? And Hoe to fit block to image?
private void BlocksToImages()
{
string FILE_PATH = “ATT file 2.dwg”;
using (CadImage cadImage = (CadImage)Aspose.CAD.Image.Load(FILE_PATH))
{
List filteredEntities = new List();
foreach (var entity in cadImage.Entities)
{
if (entity is CadInsertObject)
{
CadInsertObject cadinsentity = (CadInsertObject)entity;
filteredEntities.Add(entity);
}
}
foreach (var entity in filteredEntities)
{
#region Generate Image
List oneEntiy = new List();
entity.ChildObjects.RemoveAll(x => x is CadAttrib);
CadInsertObject cadobj = (CadInsertObject)entity;
oneEntiy.Add(entity);
cadImage.Entities = oneEntiy.ToArray();
BmpOptions bmpOptions = new BmpOptions();
var dwfRasterizationOptions = new CadRasterizationOptions();
bmpOptions.VectorRasterizationOptions = dwfRasterizationOptions;
dwfRasterizationOptions.AutomaticLayoutsScaling = true;
dwfRasterizationOptions.PageHeight = 400;
dwfRasterizationOptions.PageWidth = 400;
dwfRasterizationOptions.ScaleMethod = ScaleType.GrowToFit;
Margins margins = new Margins();
margins.Top = 5;
margins.Left = 5;
margins.Bottom = 5;
margins.Right = 5;
dwfRasterizationOptions.Margins = margins;
string outImage = ((CadInsertObject)entity).Name.Replace("*", "") + ".bmp";
cadImage.Save(outImage, bmpOptions);
#endregion
}
}
}
ATT file 2.7z (38.4 KB)