.NET

.NET

Reply
ADN Support Specialist
Balaji_Ram
Posts: 746
Registered: ‎03-21-2011
Message 11 of 14 (239 Views)

Re: How to select a drawing object which is in AutoCAD File from a .Net Applicat

07-25-2012 05:55 AM in reply to: CodeBug

Hi,

 

The issue sound similar to what is discussed in this post :

http://adndevblog.typepad.com/autocad/2012/05/how-to-pass-com-optional-parameter-in-c.html

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

*Expert Elite*
norman.yuan
Posts: 1,063
Registered: ‎04-27-2009
Message 12 of 14 (235 Views)

Re: How to select a drawing object which is in AutoCAD File from a .Net Applicat

07-25-2012 07:01 AM in reply to: CodeBug

I believe the error you got is compiling error, not runtime error. That is, your code does not compile.

 

1. The first compiling error:

 

Not like VB, in C#, you need to pass parameteres for the optional argument:

 

SelectOnScreen(Type.Missing, Type.Missing);

 

2. The second compiling error: that is because C# is strong type language, ab "object" natually does not have property that from an specific class instance. YOu need to cast the "object" into a correct specific type before to access the property. In your case, you need:

 

foreach (object item in sset)

{

    AcadEntity ent=item as AcadEntity;

    if (ent!=null)

    {

        MessageBox.Show(string.Format("Entity Handle={0}", ent.Handle));

    }

}

 

It looks like more .NET programming (not AutoCAD specific) learning is due.

Contributor
CodeBug
Posts: 18
Registered: ‎07-17-2012
Message 13 of 14 (223 Views)

Re: How to select a drawing object which is in AutoCAD File from a .Net Applicat

07-27-2012 05:51 AM in reply to: Balaji_Ram

Hi Balaji_Ram,

 

Yes I had already found this solution and this line of the code is working.

Thanks for your pointer !

Contributor
01688686718
Posts: 14
Registered: ‎12-11-2013
Message 14 of 14 (115 Views)

Re: How to select a drawing object which is in AutoCAD File from a .Net Applicat

12-16-2013 06:32 AM in reply to: VB_Autocad_guy

coud you show me event DatabaseObjectSelected.please!!!

ko0ls
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.