Is a square similar to a rectangle? Or is it similar to another square of a different scale? What if the object is a triangle? It would be classified in Autocad as a polyline, unless it was created with the polygon command (where I'm not quite sure what the resulting object would be).
Sorry, I doubt anyone here has enough information about your question in order to answer it properly.
In the code you are most likely going to have to define your own terms of what is "similar" and what is "not similar", in order to get the results you want.
For example in the attached drawing I had some entities that has similar shapes with diffrent scales. How can I know Using C# that they are similar?
what I want to do is to create a block reference with attributes for each entity.. the code is as follow:
ArrayList definedEnts=new ArrayList();
foreach (ObjectId id in btr)///btr-->block table record
Entity ent = (Entity)trans.GetObject(id, OpenMode.ForWrite, false);
foreach(Entity e in definedEnts)
if(e is similar to ent)/// this means the entity that i am reading has been defined with previous similar entity
//define ent as e
// here a form will appear to the user to classify the entity.
//and a new block definition will be created
in this code I don't know how to write (If Condition) to compare the entities. Please, Can anybody help??
You are going to have to write your own custom code to do this.
Objects in AutoCAD are only exactly equal if they are entities with exactly the same properties, (ex: layer, linetype, points, orientation).
Here is an example:
You want to compare two polylines, and define them as similar if they are only different in orientation on the xy-plane. Then you would need to rotate/mirror one of the polylines in code before trying to see if the points line up. However, the two polylines could still be the same, since point1 on one polyline doesn't have to be point1 on the other polyline.
You can see how complicated this is getting, and I didn't even take scale into account.
Anyway, this is essentially why comparing two objects defaults to comparing their memory address (or the objectId in AutoCAD, I think). Autodesk does not have support for what you want, and it seems to me that it may be better to get your input through another method, maybe via user input?