.NET

Reply
Valued Contributor
52 Posts
0 Kudos
Registered: ‎03-27-2006
Post 1 of 7

similar entities

66 Views, 6 Replies
07-19-2006 02:48 PM
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
Distinguished Contributor
223 Posts
0 Kudos
Registered: ‎02-17-2006
Post 2 of 7

Re: similar entities

07-19-2006 03:38 PM 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.
Valued Contributor
52 Posts
0 Kudos
Registered: ‎03-27-2006
Post 3 of 7

Re: similar entities

07-19-2006 04:05 PM 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
Distinguished Contributor
223 Posts
0 Kudos
Registered: ‎02-17-2006
Post 4 of 7

Re: similar entities

07-20-2006 01:18 PM 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.
Valued Contributor
52 Posts
0 Kudos
Registered: ‎03-27-2006
Post 5 of 7

Re: similar entities

07-20-2006 02:31 PM 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 :smileyhappy:

Noora
Distinguished Contributor
223 Posts
0 Kudos
Registered: ‎02-17-2006
Post 6 of 7

Re: similar entities

07-20-2006 04:29 PM 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.
Valued Contributor
52 Posts
0 Kudos
Registered: ‎03-27-2006
Post 7 of 7

Re: similar entities

07-20-2006 06:15 PM 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 :smileyhappy:

Thanks aloooooot Jason and sorry for bothering you. regards,
Noora
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post