.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to retrieve the Status of attached Image file

5 REPLIES 5
Reply
Message 1 of 6
RamanSBV
809 Views, 5 Replies

How to retrieve the Status of attached Image file

Hi,

 

Please guide me on

 

How to retrieve the Status of attached Image file

 

Regards,

Raman

5 REPLIES 5
Message 2 of 6
BrentBurgess1980
in reply to: RamanSBV

A google search netted many results.

 

This may be more than what you need, but should be a good starting point.

 

http://through-the-interface.typepad.com/through_the_interface/2010/08/attaching-an-upright-raster-i...

Message 3 of 6
RamanSBV
in reply to: BrentBurgess1980

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

Message 4 of 6
Hallex
in reply to: RamanSBV

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'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 5 of 6
RamanSBV
in reply to: Hallex

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

Message 6 of 6
Hallex
in reply to: RamanSBV

Good for you

Cheers Smiley Happy

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost