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

similar entities

6 REPLIES 6
Reply
Message 1 of 7
Nawara17
214 Views, 6 Replies

similar entities

ent.equals(anotherEnt);
ent.CompareTo(anotherEnt);

these two statments are comparing the objects not the shapes of the entities.

Please, Can anybody tell me, how can i know by comparing two entities that their shapes are similar??

Thanks in advance.

Nawara==>Noora
6 REPLIES 6
Message 2 of 7
jbooth
in reply to: Nawara17

First you have to define "similar".

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.
Message 3 of 7
Nawara17
in reply to: Nawara17

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:

bool found=false;
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
found=true;
}
}
if(!found)
{
// here a form will appear to the user to classify the entity.
//and a new block definition will be created
definedEnts.Add(ent);
}
found=false;
}

in this code I don't know how to write (If Condition) to compare the entities. Please, Can anybody help??

Nawara17
Message 4 of 7
jbooth
in reply to: Nawara17

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?

Good Luck.
Message 5 of 7
Nawara17
in reply to: Nawara17

So, there is no other solutions. the only one is to bother the user to classify each entity even if they're the same.

anyway thanks alot for your replay 🙂

Noora
Message 6 of 7
jbooth
in reply to: Nawara17

Don't get me wrong, you could compare the object's type:

If entity1 is Circle andalso entity2 is Circle then
__Return True
Else If entity1 is RotatedDimension andalso entity2 is RotatedDimension then
__Return True
...
End If

However, not all objects are similar in that way; one rectangle is only similar to another rectangle if its width/height ratio are the same.
Message 7 of 7
Nawara17
in reply to: Nawara17

I got it.
But you're talking about rectangle and circle not about a complicated entity as i got.

This solution is almost impossible.

the only possible one is asking the user for an input for each entity 🙂

Thanks aloooooot Jason and sorry for bothering you. regards,
Noora

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