Hi Experts,
I have a simple model with Just one Cell, then I copy the Cell and place the copied Cell to the model twice, the model looks as below, and i have attached the .dgn model
I am running a Microstation CE.
copied items.dgn
now with the api, i can get 3 cells, the quesiton is that how can i check whether those cells have the same geometry, only difference is the postion/transformation. is it possible to tell the source Cell of a copied cell.
I just want to know those cells have the same geometry(except the position/transformation).
thanks,
Rick
Rick, which API are you using?
Hi Rick,
at first, please read and follow this forum best practices. You have not wrote about MicroStation version (which can be crucial, because of MicroStation continuous development) and API/language you would like to use, so the discussion can be general only.
Also, please keep the topic subject as short as possible. To write lengthy sentence does not make it easy to read and understand.
Rick cheng said:the quesiton is that how can i check whether those cells have the same geometry
I think there is no such function available in native and managed API, but maybe somebody else will provide some tip.
On the other hand, I think it's possible to implement own "geometry comparer". It's probably quite complex task when any geometry should be maintained, but if you your cell will be simple (e.g. no meshes), I think it's doable.
Rick cheng said:is it possible to tell the source Cell of a copied cell.
It depends whether the cell is placed as normal or as shared:
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Hi Rick cheng
Although other element comparison APIs may exist, I (quickly) found two MDL native C API functions that may help.
Hint: If you transform both elements to the identity (in memory) you may be able to use the first function, otherwise the 2nd function provides the most flexibility of this otherwise complex topic.
HTH,Bob
Hello Rick,
I think you need to consider your requirement more detail, what's your final goal exactly, and what's the definition of "same geometries". Some examples:
1. If there are two cells which has one circle, they looks same, but the cell origin are different, one is the center point, another one is a quarter point, are they same?
2. Two circles again, only the line width is different, line width 0 Vs radius, are they same?
There are reasons why no general tool to detect "same geometries", the definition is not same.
Back to your question, I think it can be eliminated by good CAD spec, all users should not revise the cell, and all cells must have a unique name as per good naming rules. If cells have same name, then they must be same.
Hi Bob,
Robert Hook said:Although other element comparison APIs may exist, I (quickly) found two MDL native C API functions that may help.
That's great, I still thought I saw some comparison function in the past, but was not able to find it ;-)
Although it's another question, it would be nice to develop this topic further from API development perspective, because CE API has moved from C style based on data structures to OOP access based on element handlers, where underlying data structures are not visible as not important. So it would be nice to know what approach can be used to achieve the same but without working with ElmDscr.
Regards,
Changsong Ling said:I think you need to consider your requirement more detail, what's your final goal exactly, and what's the definition of "same geometries".
Exactly, "the same" can be applied in very different way(s) in different scenarios and projects ;-)
Changsong Ling said:I think it can be eliminated by good CAD spec
Hmm ... I have heard about this mythical animal ;-)
Another problem with this approach (but I agree with you completely) is that when the specs exist, there are no easy to use tools that can be used to check whether data suits them.
Jan Ĺ legr said:there are no easy to use tools that can be used to check whether data suits them
Yes, exactly. Maybe I should say, both good CAD spec and good management. I have encountered such problem many times, many users always do what's the most convenient for themselves, such as delete the tag element instead of empty the tag value, and when they need the tag again, they probably just copy another tag/text.
Thanks Bob, I will have a try with those api to varify whether it works for my case. where I just copied a cell multiple times.
thanks for the reply, and yes it not clear for the definition of Same. to make things simple, in my case, I just copy a Cell and paste the Cell twice.
at first I have only one Cell, then after paste twice, I have 3 Cells, I just want to know the later two cells have the same geometry as the first one,
the same geometry means consist of same geometry element, same size.. but the cell's position is different. or is there anyway from API side, I can check whether the later 2 Cells is copied from the first Cell.
Rick cheng said:I just copy a Cell and paste the Cell twice.
If so, how could they be different?
Rick cheng said:the same geometry means consist of same geometry element, same size
An idea: scan all the sub elements in both cells, check each sub elements, if they are all same(you can define what means "same"), then the two cells are same.
Rick cheng said: check whether the later 2 Cells is copied from the first Cell
I don't think there is such function to record the source of the cell, they are independant elements. The most closest workaround, judge by the createdtime of the element? The copied cell must be later then the source cell. Is it OK for you?