.NET

.NET

Reply
ADN Support Specialist
761 Posts
100 Kudos
Registered: ‎03-21-2011
Post 11 of 18

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*
1,084 Posts
215 Kudos
Registered: ‎04-27-2009
Post 12 of 18

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
18 Posts
0 Kudos
Registered: ‎07-17-2012
Post 13 of 18

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
14 Posts
0 Kudos
Registered: ‎12-11-2013
Post 14 of 18

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
Active Member
7 Posts
0 Kudos
Registered: ‎01-08-2014
Post 15 of 18

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

12-19-2014 02:00 PM in reply to: 01688686718
Is it possible to use that handle to create an object? lets say i saved that value of the handle on a table or xml file. Then use it on a new drawing as a object? if yes, i can't seem to find a way to do it.
Valued Mentor
278 Posts
22 Kudos
Registered: ‎11-29-2008
Post 16 of 18

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

12-19-2014 02:43 PM in reply to: mchan01

mchan01 wrote:
Is it possible to use that handle to create an object? lets say i saved that value of the handle on a table or xml file. Then use it on a new drawing as a object? if yes, i can't seem to find a way to do it.

Not directly. The Handle is is just a number, which could mean anything in isolation.

You would also need to save the document qualified fileName that the object represented by the handle lives in.

 

You can then open the originating file and copy/reproduce the object represented by the handle into your current document.

 

 

//-------------------------------------------------------

Everything will work just as you expect it to, unless your expectations are incorrect.

class keyThumper<T> : Lazy<T>;      another  Swamper

Active Member
7 Posts
0 Kudos
Registered: ‎01-08-2014
Post 17 of 18

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

12-19-2014 02:57 PM in reply to: KerryBrown

What does it mean by document qualified name? Sorry to have asked this question.

 Actually what i am doing is creating a style(any style) 

 

Ex. Created PointCloudStyle


I was told that i only need the handle to do that, i was able to save it on the xml but now i am stuck on how to create an object from it.

 

I want it to be reusable, like if anyone retrieves that entry from our xml, a pointcloudstyle will automatically be created for the user.
 

is that possible? 

*Expert Elite*
1,286 Posts
37 Kudos
Registered: ‎06-21-2004
Post 18 of 18

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

12-19-2014 03:18 PM in reply to: mchan01

Just to clarify the conversation, The handle is a unique number that identifies an entity within the drawing. It has no other meaning to the program.

 

When you insert an object such as a block into a drawing it will receive a new unique handle in that drawing,.

 

You can deep clone a database object from one drawing into another. This will also give it a new unique number.

 

If you wanted to store an objects properties you would need a store all of it's properties such as aline's end and startpoint, Layers etc as text in your excel sheet.

 

Then recreate the object as a new object and fill in each of the properties.

---------------------------



(defun botsbuildbots() (botsbuildbots))
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post