Hi,
Please guide me on
How to retrieve the Status of attached Image file
Regards,
Raman
A google search netted many results.
This may be more than what you need, but should be a good starting point.
Hi,
Is any property to know the status(file is available / file not found ) of the file(dwg/dng/png/image) which is attached to dwg file.
Regards,
Raman
Try this code
[CommandMethod("imgp", CommandFlags.Modal)] public void SelectRasterImage() { Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; Point3dCollection pts = new Point3dCollection(); using (Transaction tr = db.TransactionManager.StartTransaction()) { ObjectId id = ed.GetEntity("\nSelect an image: ").ObjectId; DBObject obj = tr.GetObject(id, OpenMode.ForRead); if (obj.GetRXClass().DxfName == "IMAGE") { RasterImage image = obj as RasterImage; string imageName = image.Name; Point3d pt = image.Position; pts = image.GetVertices(); ObjectId imageDictId = RasterImageDef.GetImageDictionary(db); DBDictionary imageDict = (DBDictionary)tr.GetObject(imageDictId, OpenMode.ForRead, false); ObjectId imageDefId = imageDict.GetAt(imageName); RasterImageDef imageDef = (RasterImageDef)tr.GetObject(imageDefId, OpenMode.ForRead, false); try { StringBuilder sb = new StringBuilder(); sb.AppendLine("Image Name =" + imageName); sb.AppendLine(string.Format("Position = {0:f3}", pt)); sb.AppendLine("Height = " + (Math.Abs(pts[0].Y - pts[1].Y)).ToString()); sb.AppendLine("Width = " + (Math.Abs(pts[0].X - pts[2].X)).ToString()); string filename = imageDef.ActiveFileName; sb.AppendLine("ActiveFileName =" + filename); string sourcename = imageDef.SourceFileName; sb.AppendLine("SourceFileName =" + sourcename); Vector2d vec = imageDef.Size; sb.AppendLine("Size =" + vec.ToString()); Autodesk.AutoCAD.GraphicsInterface.ImageSource imageSource = (Autodesk.AutoCAD.GraphicsInterface.ImageSource)imageDef.Organization; bool embedded = imageDef.IsEmbedded; sb.AppendLine("Embedded =" + embedded.ToString()); bool loaded = imageDef.IsLoaded; sb.AppendLine("Loaded =" + loaded.ToString()); string ftype = imageDef.FileType; sb.AppendLine("FileType =" + ftype); bool autodel = imageDef.AutoDelete; sb.AppendLine("AutoDelete =" + autodel.ToString()); AnnotativeStates anno = imageDef.Annotative; string annostr = anno.ToString(); sb.AppendLine("Annotative =" + annostr); MessageBox.Show(sb.ToString()); } catch (Autodesk.AutoCAD.Runtime.Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } finally { } } } }
~'J'~
Hi,
Thanks for your post.
I am able to get status of the image file with bellow line of code
bool loaded = imageDef.IsLoaded;
Now i am googling for DWF/DGN/PDF files
Regards,
Raman