Hi
I am asking user for scale factor and insertion point. but the actual image alway display width and height as the scale value, if i insert value of 5 for scale factor width and height will be 5 but not according to coordinates system.
but if i insert the same image manualy width and height are calculated by autocad according to scale factor before insertion.
double scale = promptDoubleResult.Value; var xAxis = new Vector3d(scale, 0, 0); var yAxis = new Vector3d(0, scale, 0); var ucs = document.Editor.CurrentUserCoordinateSystem; using (Transaction trans = database.TransactionManager.StartTransaction()) { RasterImageDef rasterImageDef = new RasterImageDef(); rasterImageDef.SourceFileName = imagePath; rasterImageDef.Load(); ObjectId imgDicId = RasterImageDef.GetImageDictionary(database); if(imgDicId.OldIdPtr == new IntPtr(0)) imgDicId = RasterImageDef.CreateImageDictionary(database); DBDictionary imgDict = trans.GetObject(imgDicId, OpenMode.ForWrite, false, true) as DBDictionary; if (imgDict.Contains(BlockName)) { return false; } else { imgDict.SetAt(BlockName, rasterImageDef); trans.AddNewlyCreatedDBObject(rasterImageDef, true); // now add the REAL raster image reference RasterImage rasterImg = new RasterImage(); rasterImg.ImageDefId = rasterImageDef.ObjectId; rasterImg.Orientation = new CoordinateSystem3d(insertionPoint.TransformBy(ucs),xAxis.TransformBy(ucs),yAxis.TransformBy(ucs)); rasterImg.Rotation = rotationAngle; BlockTable bt = (BlockTable)trans.GetObject(database.BlockTableId, OpenMode.ForRead, false, true); BlockTableRecord btr = (BlockTableRecord)trans.GetObject(database.CurrentSpaceId, OpenMode.ForWrite, false, true); ObjectId rasterImgId = btr.AppendEntity(rasterImg); trans.AddNewlyCreatedDBObject(rasterImg, true); rasterImg.AssociateRasterDef(rasterImageDef); trans.Commit(); } }
Thanks for your help.
I have seen the same issues in VBA some years ago.
Currently no C# sample available but have a look at the next code might help
Notice i had to set the scale twice.
With imageRef ' On Error Resume Next ' .ImageFile = ".\" & fs.GetFileName(tifPathname) ' On Error GoTo EndOfProc .Origin = imagePos .ScaleFactor = imageScale .Rotation = imageAngle .ScaleFactor = 1 acadDoc.Layers.Add "Raster" .layer = "Raster" .Transparency = True On Error Resume Next .name = fs.GetBaseName(tifPathname) On Error GoTo EndOfProc End With
Also compare the DPI for both the manual and youre program result.
Drawing Units may influence the behaviour as well.
And besure to have the xDPI==yDPI otherwise youre raster may not be editable in RasterDesign.