.NET

Reply
ADN Support Specialist
Balaji_Ram
Posts: 669
Registered: ‎03-21-2011
Message 11 of 14 (207 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: 970
Registered: ‎04-27-2009
Message 12 of 14 (203 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 (191 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: 12
Registered: ‎12-11-2013
Message 14 of 14 (83 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

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 familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

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

Ask the Community