.NET

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

How to retrieve the Status of attached Image file

329 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: 161
Registered: ‎06-16-2008
Message 2 of 6 (316 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: 85
Registered: ‎02-28-2012
Message 3 of 6 (269 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,566
Registered: ‎10-08-2008
Message 4 of 6 (238 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: 85
Registered: ‎02-28-2012
Message 5 of 6 (228 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,566
Registered: ‎10-08-2008
Message 6 of 6 (222 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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you interested in helping shape the Autodesk Community?
We’re looking at a few different ways to improve the “All Forums” landing page and need your feedback! If interested, please take a few minutes to fill out the following Usability Study. Thank you for your time!

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community