Create instance of my object

Create instance of my object

tcorey
Mentor Mentor
1,691 Views
9 Replies
Message 1 of 10

Create instance of my object

tcorey
Mentor
Mentor

 

 

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
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Platinum Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
1,692 Views
9 Replies
Replies (9)
Message 2 of 10

Alexander.Rivilis
Mentor
Mentor

tcorey wrote:

I have created a class that inherits Polyline...


Is it a .NET class?

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes
Message 3 of 10

tcorey
Mentor
Mentor

Yes, this is a .Net class.



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Platinum Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
Message 4 of 10

tcorey
Mentor
Mentor

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
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Platinum Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
Message 5 of 10

Alexander.Rivilis
Mentor
Mentor

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.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes
Message 6 of 10

tcorey
Mentor
Mentor

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
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Platinum Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
Message 7 of 10

Alexander.Rivilis
Mentor
Mentor

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!

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes
Message 8 of 10

tcorey
Mentor
Mentor

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
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Platinum Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
Message 9 of 10

_gile
Consultant
Consultant

>> 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
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 10 of 10

tcorey
Mentor
Mentor

Thanks!



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Platinum Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes