.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AutoCAD objects equality checking

8 REPLIES 8
Reply
Message 1 of 9
Andrey_Bushman
685 Views, 8 Replies

AutoCAD objects equality checking

Is the Object.GetHashCode virtual method reliable for the equality checking of AutoCAD objects? Is this method overridden for them? How we can check of their equality otherwise?

Tags (2)
8 REPLIES 8
Message 2 of 9
hgasty1001
in reply to: Andrey_Bushman

Hi,

 

Interesting question, I think the answer is not, as the hashcode is valid only in a limited domain, and as the MS documentations says, same hash codes does not implies same object. Anyway, what kind of equality are you testing for, and what kind of objects and last, in what context (same database, side database or something else) are the tests running?

 

Gaston Nunez

 

 

Message 3 of 9
Andrey_Bushman
in reply to: hgasty1001

This method is virtual. Therefore I also ask, whether redefined it Autodesk for own objects (to be guided by standard approach for the solution of this task)?

 

>Anyway, what kind of equality are you testing for, and what kind of objects and last, in what context (same database, side database or something else) are the tests running?

 

For example, I want to compare contents of drawings and to find their distinctions.

Message 4 of 9

For all AutoCAD objects GetHashCode method return memory address (pointer) of unmanaged object/entity:

// Autodesk.AutoCAD.Runtime.DisposableWrapper
public override int GetHashCode()
{
    GC.KeepAlive(this);
    return (int)this.m_imp.ToInt64();
}

 

So this method can not help you.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | 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

Message 5 of 9

>So this method can not help you.

Ok. How can I solve this problem? I need to compare AutoCAD objects.

Message 6 of 9
hgasty1001
in reply to: Andrey_Bushman

Hi,

 

If you are comparing inside a single database, you can test the handle of each entity (the handle is unique and persistent inside a single database), otherwise you have to check the class and properties of each entity. Maybe if you explain in more detail the problem (a drawing compare?) someone can figure out a way to help.

 

Gaston Nunez

 

 

 

 

Message 7 of 9
dgorsman
in reply to: Andrey_Bushman

Is it important to compare identical objects or just visual duplicates?  For example, in a copy of the DWG I could copy a circle in place and erase the original.  For all intents and purposes the two drawings would be the same except the handle/object ID would be different.

 

Maybe reflection could offer some ways to determine properties of one object so they can be compared against against its twin.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 8 of 9
Andrey_Bushman
in reply to: dgorsman

Databases can be different (not the same Database). Yes, the visual duplicates, and XData (optional). Reflection works slowly, as I know. I can write own solution (through reflection), but I have a hope exists "native" decision by Autodesk.

Message 9 of 9

There is no "native" method, but as a idea: http://www.theswamp.org/index.php?topic=39991.msg452785#msg452785

Also you can compare all (or not all) DXF-codes of both entities.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | 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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost