CADImage.Select Method Bug

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
slingblade
Posts: 16
Joined: 31 May 2010, 13:33

CADImage.Select Method Bug

Post by slingblade » 04 Jun 2010, 04:31

Hi,

I am using the CADImage.Select(x, y) method in a mousedown event for a CADPictureBox.

When I do it returns a Null Reference exception, below is the stack trace

at CADImport.FaceModule.CADImportFace.SelectObject(CADEntity ent)
at CADImport.CADSelector.Select(Int32 x, Int32 y)
at CADImport.CADImage.Select(Int32 x, Int32 y)
at frmDxf.cadPictBox_MouseDown(Object sender, MouseEventArgs e)

Error Message: Object reference not set to an instance of an object.

I don't believe it should bubble up an error, or should it?

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: CADImage.Select Method Bug

Post by support » 04 Jun 2010, 16:20

Hello.
Please specify the code you use for selecting entity. Have you tried our EditorDemo application for this task? If the exception occur on specific file then please send it to us for the testing.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

slingblade
Posts: 16
Joined: 31 May 2010, 13:33

Re: CADImage.Select Method Bug

Post by slingblade » 07 Jun 2010, 12:28

Hi Alexander,

I have found the cause for the bug. It seems I didn't have a reference to a PropertyGrid control set to the EntityPropertyGrid property in the CADImportFace class.

i.e. CADImportFace.EntityPropertyGrid = this.propGrid;

Here is the code from the FAQ_Demo.Net example

Code: Select all

 private void InitExtParam()
        {
            Initial3DOrbit();
            #region protect
#if ((! floatprotect) && protect)
				this.miFloatLic.Enabled = false;
#endif
            #endregion
            InitLng();
            InitSettings();
            SetAllFormsSettings();
            this.clipRectangle = new ClipRect(this.cadPictBox);
            this.clipRectangle.MultySelect = false;
            this.miCopyAsBMP.Shortcut = Shortcut.CtrlC;
            CADImportFace.EntityPropertyGrid = this.propGrid; //Here is the reference you MUST have to not crash the CADPictureBox control!
            this.cadPictBox.MouseWheel += new MouseEventHandler(CADPictBoxMouseWheel);
            this.cadPictBox.ScrollEvent += new CADImport.FaceModule.ScrollEventHandlerExt(CADPictBoxScroll);
        }
As soon as I created a propertygrid control on my form and assigned it to the EntityPropertyGrid property then I was able to select (click my mouse) in the CADPictureBox control without generating the Object reference error. Without a propertygrid control set to the EntityPropertyGrid property I was unable to use the CADPictureBox control.

As a work around I made the grid invisible and placed it somewhere out of the way because for that form I don't want a propertygrid control.

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: CADImage.Select Method Bug

Post by support » 07 Jun 2010, 14:06

Hello Scott.
This isn't a bug, the CADImage.Select method constructed for visual selection mostly. It call the FaceModule.CADImportFace.SelectObject that creates and sets an object in EntityPropertyGrid. However the property grid must be initialized. In our demo property grid initialization take place on MainForm initialization. You can realize your own programmatically method if necessary.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply