.NET

Reply
*Expert Elite*
tcorey
Posts: 2,446
Registered: ‎12-18-2002
Message 1 of 10 (317 Views)

Create instance of my object

317 Views, 9 Replies
05-01-2012 04:38 PM

 

 

I have created a class that inherits Polyline. I have added properties to that class.

 

When I try to SetDatabaseDefaults with my object, I get an error "Set database defaults is not a member..."

 

But if I create a new Polyline, SetDatabaseDefaults works for that object.

 

Shouldn't the SetDatabaseDefaults method become a member of my class when I inherit from Polyline?

 

Thanks,

 

Tim

 

 

 

 

 

Tim Corey, Owner
Delta Engineering Systems
Redding, CA
Autodesk Authorized Value-Added Reseller
Moderator
Alexander.Rivilis
Posts: 1,388
Registered: ‎04-09-2008
Message 2 of 10 (306 Views)

Re: Create instance of my object

05-01-2012 09:50 PM in reply to: tcorey

tcorey wrote:

I have created a class that inherits Polyline...


Is it a .NET class?


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

*Expert Elite*
tcorey
Posts: 2,446
Registered: ‎12-18-2002
Message 3 of 10 (286 Views)

Re: Create instance of my object

05-02-2012 08:22 AM in reply to: Alexander.Rivilis

Yes, this is a .Net class.

Tim Corey, Owner
Delta Engineering Systems
Redding, CA
Autodesk Authorized Value-Added Reseller
*Expert Elite*
tcorey
Posts: 2,446
Registered: ‎12-18-2002
Message 4 of 10 (283 Views)

Re: Create instance of my object

05-02-2012 08:30 AM in reply to: tcorey

I figured it out.

 

I had originally inherited from Autodesk.AutoCAD.GraphicsInterface.Polyline, but if I inherit from Autodesk.AutoCAD.DatabaseServices.Polyline instead, the object will setdatabasedefaults.

 

I don't know why one polyline would have different properties than another, but I'm not gonna let myself get hung up on that detail right now!

 

So, advice for other newbies, there might be multiple Autodesk-supplied classes in various Autodesk libraries. Those classes might use the same name but not have the same properties and methods.

 

Thanks, Alexander, for responding. I'm sure you'll be seeing more beginner-level posts from me....

Tim Corey, Owner
Delta Engineering Systems
Redding, CA
Autodesk Authorized Value-Added Reseller
Moderator
Alexander.Rivilis
Posts: 1,388
Registered: ‎04-09-2008
Message 5 of 10 (275 Views)

Re: Create instance of my object

05-02-2012 02:56 PM in reply to: tcorey

As I understand you try to create custom entity with help of .NET API. Am I right? It is impossible to create custom entity with help of .NET API. It is possible only with help of ObjectARX (C++). Therefore no sense to create classes inherited from DBObject / Entity, as an instance of this class will not be able to create and add to the dwg-file.


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

*Expert Elite*
tcorey
Posts: 2,446
Registered: ‎12-18-2002
Message 6 of 10 (255 Views)

Re: Create instance of my object

05-04-2012 01:24 AM in reply to: Alexander.Rivilis

Wow. Thanks, Alexander. You just saved me a bunch of hours.

 

The reason I was going to create my own class was so I could apply properties to a polyline-like object, like you would with Xdata through Visual LISP. Is there a way to apply custom properties to an AutoCAD object using VB.NET, without creating my own class?

 

Or should I just switch to C++?

 

 

 

 

 

Tim Corey, Owner
Delta Engineering Systems
Redding, CA
Autodesk Authorized Value-Added Reseller
Moderator
Alexander.Rivilis
Posts: 1,388
Registered: ‎04-09-2008
Message 7 of 10 (254 Views)

Re: Create instance of my object

05-04-2012 01:46 AM in reply to: tcorey

tcorey wrote:

Is there a way to apply custom properties to an AutoCAD object using VB.NET, without creating my own class?


What do you mean by Custom Property? What do you mean by Custom Property? The property which appears in the Properties pane (OPM)?
Try code of Kean Walmsley: http://through-the-interface.typepad.com/through_the_interface/2009/05/modifying-an-autocad-objects-...


tcorey wrote:

Or should I just switch to C++?


Only if you ready to create own custom entity. This is not the easy way. Good luck!


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

*Expert Elite*
tcorey
Posts: 2,446
Registered: ‎12-18-2002
Message 8 of 10 (237 Views)

Re: Create instance of my object

05-04-2012 02:22 PM in reply to: tcorey

By Custom Properties, I mean my own properties and values assigned to a polyline object. In particular, I want to create a property that holds the View to which my polyline is associated. Using Visual LISP, I would create Xdata to do this.

 

I read through Kean's post and it appears that there is a way to do this with vb.net, so I might continue down that road for now. Or not. Maybe I'll switch to c++, although it's been even longer since I used it than it has been for VB.

 

Decisions, decisions....

Tim Corey, Owner
Delta Engineering Systems
Redding, CA
Autodesk Authorized Value-Added Reseller
*Expert Elite*
_gile
Posts: 2,071
Registered: ‎04-29-2006
Message 9 of 10 (221 Views)

Re: Create instance of my object

05-05-2012 05:13 AM in reply to: tcorey

>> Using Visual LISP, I would create Xdata to do this.

 

Using .NET, you also can create Xdata or ExtensionDictionary/Xrecord,this would certainly be simpler than the objectARX/C++ route...

Gilles Chanteau
*Expert Elite*
tcorey
Posts: 2,446
Registered: ‎12-18-2002
Message 10 of 10 (202 Views)

Re: Create instance of my object

05-08-2012 10:52 AM in reply to: tcorey

Thanks!

Tim Corey, Owner
Delta Engineering Systems
Redding, CA
Autodesk Authorized Value-Added Reseller

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