Was anyone at it before?
Let's say we have two drawings, Drawing1 and Drawing2. Both are saved as files, Drawing2 is additionally opened in the application for visualisation of apparent changes.
Now let's compare these drawings. Drawing1 needs to be loaded into a side database, both databases have a transaction running, and...
let comparer = Autodesk.AutoCAD.Internal.DrawingCompare()
use objectDiffEven =
comparer.ObjectDiffEvent
|> Observable.subscribe(
fun e ->
transients :=
match e.ChangeType, e.DrawingId with
// from Drawing 1
| 1, 1 -> hnd2ent1 e.ObjHandle 2s
| 2, 1 -> hnd2ent1 e.ObjHandle 4s
| 3, 2 -> hnd2ent1 e.ObjHandle 1s
// from Drawing 2
| 1, 2 -> hnd2ent2 e.ObjHandle 5s
| 2, 2 -> hnd2ent2 e.ObjHandle 6s
| 3, 1 -> hnd2ent2 e.ObjHandle 3s
// Can anything else happen?
| _ -> !transients )
let res = comparer.CompareDwgFiles(drawing1, drawing2)
...oh the joys of partial application. If the entity comes from Drawing1, get the ObjectId out of the side database, open and clone it, else open and clone straight away. Assign a distinct color, show the entity in the drawing window and store it as head of the transients list ref cell for later disposal.
Now for the colors, whose meanings here aren't entirely clear to me. Yellow and blue objects share the same Handle and are in both drawings, albeit differing in their properties. Red or cyan means they are only in Drawing1, green or magenta for Drawing2. What's the difference?
Anyone?