.NET

Reply
ADN Support Specialist
Balaji_Ram
Posts: 737
Registered: ‎03-21-2011
Message 11 of 14 (233 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,051
Registered: ‎04-27-2009
Message 12 of 14 (229 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 (217 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 (109 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
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!