Raster Image not visible when rotated (C# .NET API)
Hello,
I am inserting a raster image with C# .NET API, it works fine, but when I select the raster image in BricsCAD and rotate it, the raster image is not visible, only its frame. Curiously, if the raster image is rotated a multiple of 90 degree ,it works fine, but any other angle does not.
¿Any other thing is needed to make this works or it is a bug in the API? If a raster image is inserted directly with BricsCAD it works fine.
trans.StartAcadTransaction();
ObjectId imageDictId = RasterImageDef.GetImageDictionary(document.Database);
if (imageDictId.IsNull)
{
imageDictId = RasterImageDef.CreateImageDictionary(document.Database);
}
DBDictionary imageDictionary = trans.Transaction.GetObject(imageDictId, OpenMode.ForRead) as DBDictionary;
ObjectId acImgDefId;
RasterImageDef acRasterDef = new RasterImageDef();
acRasterDef.SourceFileName = @C:\test.png;
imageDictionary.UpgradeOpen();
acImgDefId = imageDictionary.SetAt(rasterName, acRasterDef);
imageDictionary.DowngradeOpen();
trans.Transaction.AddNewlyCreatedDBObject(acRasterDef, true);
RasterImage acRaster = new RasterImage();
acRaster.ImageDefId = acImgDefId;
Vector3d width = new Vector3d(1000, 0, 0);
Vector3d height = new Vector3d(0, 1000, 0);
Point3d insPt = new Point3d(0, 0, 0.0);
CoordinateSystem3d coordinateSystem = new CoordinateSystem3d(insPt, width, height);
acRaster.Orientation = coordinateSystem;
acRaster.ShowImage = true;
BlockTable acBlkTbl = trans.Transaction.GetObject(document.Database.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord acBlkTblRec = trans.Transaction.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForRead) as BlockTableRecord;
acBlkTblRec.UpgradeOpen();
acBlkTblRec.AppendEntity(acRaster);
acBlkTblRec.DowngradeOpen();
trans.Transaction.AddNewlyCreatedDBObject(acRaster, true);
acRaster.AssociateRasterDef(acRasterDef);
0
Comments
-
What a mess with the code format, I post it again:AutoCAD.Common.TransactionManager trans = new AutoCAD.Common.TransactionManager(document);trans.StartAcadTransaction();ObjectId imageDictId = RasterImageDef.GetImageDictionary(document.Database);if (imageDictId.IsNull){imageDictId = RasterImageDef.CreateImageDictionary(document.Database);}DBDictionary imageDictionary = trans.Transaction.GetObject(imageDictId, OpenMode.ForRead) as DBDictionary;ObjectId acImgDefId;RasterImageDef acRasterDef = new RasterImageDef();acRasterDef.SourceFileName = @C:\test.png;imageDictionary.UpgradeOpen();acImgDefId = imageDictionary.SetAt(rasterName, acRasterDef);imageDictionary.DowngradeOpen();trans.Transaction.AddNewlyCreatedDBObject(acRasterDef, true);RasterImage acRaster = new RasterImage();acRaster.ImageDefId = acImgDefId;Vector3d width = new Vector3d(1000, 0, 0);Vector3d height = new Vector3d(0, 1000, 0);Point3d insPt = new Point3d(0, 0, 0.0);CoordinateSystem3d coordinateSystem = new CoordinateSystem3d(insPt, width, height);acRaster.Orientation = coordinateSystem;acRaster.ShowImage = true;BlockTable acBlkTbl = trans.Transaction.GetObject(document.Database.BlockTableId, OpenMode.ForRead) as BlockTable;BlockTableRecord acBlkTblRec = trans.Transaction.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForRead) as BlockTableRecord;acBlkTblRec.UpgradeOpen();acBlkTblRec.AppendEntity(acRaster);acBlkTblRec.DowngradeOpen();trans.Transaction.AddNewlyCreatedDBObject(acRaster, true);acRaster.AssociateRasterDef(acRasterDef);trans.Commit();0
This discussion has been closed.