.NET

.NET

Reply
Valued Contributor
RamanSBV
Posts: 88
Registered: ‎02-28-2012
Message 1 of 6 (538 Views)

How to retrieve the Status of attached Image file

538 Views, 5 Replies
08-30-2012 12:58 AM

Hi,

 

Please guide me on

 

How to retrieve the Status of attached Image file

 

Regards,

Raman

Mentor
BrentBurgess1980
Posts: 165
Registered: ‎06-16-2008
Message 2 of 6 (525 Views)

Re: How to retrieve the Status of attached Image file

08-30-2012 06:41 PM 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...

Valued Contributor
RamanSBV
Posts: 88
Registered: ‎02-28-2012
Message 3 of 6 (478 Views)

Re: How to retrieve the Status of attached Image file

09-10-2012 11:45 PM 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

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 4 of 6 (447 Views)

Re: How to retrieve the Status of attached Image file

09-13-2012 04:32 AM 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
Valued Contributor
RamanSBV
Posts: 88
Registered: ‎02-28-2012
Message 5 of 6 (437 Views)

Re: How to retrieve the Status of attached Image file

09-13-2012 10:14 PM 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

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 6 of 6 (431 Views)

Re: How to retrieve the Status of attached Image file

09-14-2012 12:28 AM in reply to: RamanSBV

Good for you

Cheers :smileyhappy:

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.