| Article | 70002829 |
| Type | Wish |
| Product | Engine |
| Date Added | 1/22/2026 12:00:00 AM |
| Fixed | 12.0.01 (2/4/2026 12:00:00 AM) |
| Submitted by | Sefa Akgul |
Summary
Command to compare two drawings and the differences
Solution
In version 12.0.01 new methods were added to provide the functionality of comparing two drawings.
1.vdDocument.Compare(vdDocument with) as IvdCompareResults
Compare this document's Model Entities 'with' the passed document
Recommended to compare drawings of the same type/extension (for example compare two dwg drawings or two vdml drawings).
Remarks :
Double value properties are compared using the vdDocument.FileProperties.CompareDocumentSettings.DecimalPrecision which by default is 8.
vdDocument.FileProperties.CompareDocumentSettings.CollectionLimit variable defines the maximun number of objects that a collection property of a vdFigure can have in order to be valid for comparing
If a figure has a collection property that exceeds this number then this figure is marked as Incomparable.Default value of CollectionLimit is 0 for no limit and all figures are comparable (examples of such figures is an insert with it's block having many items or a polyface having a lot of gPoints.
Only some of the basic geometrical properties of each figure type participate in the comparison.This is done for performance reasons. See Section 4 for details for each figure.
Following entity types are Incomparable
vdIFC object types
user develop custom objects .These objects must override the vdFigure.GetCompareHash method (example at the bottom of this article).
returns a IvdCompareResults object that contains information about the compare results
The IvdCompareResults has the following properties
Drawing1Common as vdSelection : Returns the collection of entities that belong to the first document and are same as entities in the second document.
Drawing1Exclusive as vdSelection : Returns the collection of entities that belong to the first document and do not exist in the second document.
Drawing1Modified as vdSelection : Returns the collection of entities that belong to the first document and exist in the second document, but with some of their properties modified.
Drawing1Incomparable as vdSelection : Returns the collection of entities that belong to the first document and are Incomparable (do not implement method).
Drawing2Common as vdSelection : Returns the collection of entities that belong to the second document and are the same with corresponding entities in the second document.
Drawing2Exclusive as vdSelection : Returns the collection of entities that belong to the second document and do not exist in the first document.
Drawing2Modified as vdSelection : Returns the collection of entities that belong to the second document and exist in the first document, but with some of their properties modified.
Drawing2Incomparable as vdSelection : Returns the collection of entities that belong to the second document and are Incomparable (do not implement method).
NumberofDiffs as Integer : Returns the number of differences between the drawings.
2.vdCommandAction.CmdCompare( object Drawing1Path, object Drawing2Path, bool navigate) as integer
Compare two drawings and visualize the result in this Document object
Remarks
Allows you to quickly identify differences between two versions of a drawing, displaying changes with color coding.
Strongly recommended to compare drawings of the same type/extension; When non-VDF drawings (like .DGN, .DXF, .PDF etc) are imported into VDF then some of their objects might be translated
to different VDF objects and vice versa. So by comparing drawings of different files types then command may return differences although on-screen the files look exactly the same.
Two block references are added to this document one foreach compare document
The comparison works only for objects in Model Space
Double value properties compare using the vdDocument.FileProperties.CompareDocumentSettings.DecimalPrecision which by default is 8
Color Coding:
vdDocument.FilePropertis.CompareDocumentSettings.SameObjectsColor :Objects that are same in both drawings. Default value is Color.Gray
vdDocument.FilePropertis.CompareDocumentSettings.NoMatchingObjectsColor1 : Objects in drawing1 that are not matching any object from drawing2. Default value is Color.Red
vdDocument.FilePropertis.CompareDocumentSettings.NoMatchingObjectsColor2 : Objects in drawing2 that are not matching any object from drawing1. Default value is Color.Green
vdDocument.FilePropertis.CompareDocumentSettings.DifferentObjectsFadeEffect :Fade Effect for objects of same type same handle on both drawings but different properties. Default value is 25
vdDocument.FilePropertis.CompareDocumentSettings.RectangleColor : Rectangles that groups the neighboring changes. Default value is Color.Yellow
vdDocument.FilePropertis.CompareDocumentSettings.IncomparableObjectsColor : Objects that are Incomparable usually do not support comparison. Default value is Color.LightGray
Drawing1Path: Drawing 1 to compare
Drawing2Path Drawing 2 to compare with.
navigate If it is true waiting for the user to press the arrows keys to automatically zoom to the yellow rectangle areas where there is a difference.
Returns 0 if there are no differences >0 if there are differences , -1 on error
3.A new virtual method was added in vdFigure int GetCompareHash()
Called when this object is going to be compared with another object by vdDocument.Compare
Override this method to your custom object and return a unique 32 bit integer value according to the object type and its properties
Example override GetCompareHash method in order your custom object to be comparable
public class CustomObject : vdFigure , IvdProxyFigure
{
gPoint mOrigin = new gPoint();
Vector mNormal = new Vector();
double mRotation = 0;//in radians
int mIntvalue = 0;
string mDisplayText = "";
gPoints mpoints = new gPoints();
vdEntities mSomeEntities = new vdEntities();
Int32Array mIntCollection = new Int32Array();
DoubleArray mDoubleCollection = new DoubleArray();
public override int GetCompareHash()
{
unchecked
{
int hash = 17;//start with this line
hash = hash * 23 + GetType().GetHashCode();//always put this at the start and follow the object properties
int hash2 = mpoints.GetCompareHashCode();
if(hash2 == 0) return 0;//always check the collections depend on the vdDocument.FileProperties.CompareDocumentSettings.CollectionLimit
hash = hash * 23 + hash2;
hash2 = mSomeEntities.GetCompareHashCode();
if(hash2 == 0) return 0;//always check the collections depend on the vdDocument.FileProperties.CompareDocumentSettings.CollectionLimit
hash = hash * 23 + hash2;
hash2 = mIntCollection.GetCompareHashCode();
if(hash2 == 0) return 0;//always check the collections depend on the vdDocument.FileProperties.CompareDocumentSettings.CollectionLimit
hash = hash * 23 + hash2;
hash2 = mDoubleCollection.GetCompareHashCode();
if(hash2 == 0) return 0;//always check the collections depend on the vdDocument.FileProperties.CompareDocumentSettings.CollectionLimit
hash = hash * 23 + hash2;
hash = hash * 23 + Globals.GetCompareHash(mOrigin);
hash = hash * 23 + Globals.GetCompareHash(mNormal);
hash = hash * 23 + Globals.GetCompareHashAngle(mRotation);//use GetCompareHashAngle for rotation in radians
hash = hash * 23 + mIntvalue.GetHashCode();
hash = hash * 23 + mDisplayText.GetHashCode();
return hash;
}
}
}
4.Properties of figure types that participate in the comparison
vdArcAlignedText
TextString
Style //uses the Name
Height
Center
Radius
StartAngle
EndAngle
vd3DFace
VertexList
vdArc
Center
Radius
StartAngle
EndAngle
HatchProperties //uses FillMode property
vdAttrib
base vdText properties and..
TagString
ValueString
InVisibleMode
vdAttribDef
base vdText properties and..
TagString
ValueString
vdCircle
Center
Radius
HatchProperties //uses FillMode property
vdDimension
DefPoint1
DefPoint2
DefPoint3
DefPoint4
TextPosition
LinePosition
Style //uses Name
dimText
dimType
UsingDefaultTextPosition
Rotation
HorizontalRotation
vdEllipse
Center
MajorLength
MinorLength
MajorAngle
StartAngle
EndAngle
HatchProperties //uses FillMode property
vdGroundSurface
Points
LockTriangles
vdHelix
BaseCenter
BaseRadius
TopRadius
Height
TurnHeight
Turns
Twist
Constrain
StartAngle
vdImage
base vdRectText properties and..
ImageDefinition
ImageScale
vdInfinityLine
BasePoint
Direction
InfinityType
vdInsert
InsertionPoint
Xscale
Yscale
Zscale
Rotation
Attributes
Block //uses Name and block entire Entities
vdLeader
VertexList
LeaderMText
LeaderType
Style ///uses the Name
vdLine
StartPoint
EndPoint
vdMtext
TextString
Style //uses Name
BoxWidth
Height
Rotation
InsertionPoint
vdMultiLine
Flags
Justification
MultilineStyle //uses the Name
ScaleFactor
VertexList
vdPoint
InsertionPoint
vdPointCloud
points
ECSMatrix
vdPolyface
VertexList
FaceList
vdPolyHatch
HatchProperties //uses FillMode property
PolyCurves // entire collection comparer
vdPolyline
Flag
VertexList
SPlineFlag
HatchProperties //uses FillMode property
vdRect
InsertionPoint
Width
Height
Rotation
HatchProperties //uses FillMode property
vdText
InsertionPoint
TextString
Style // uses the Name
VerJustify
HorJustify
Rotation
AlignmentPoint
Height
Note:
the Compare command is also added
in commands.txt resource, that make a call to vdCommandAction.CompareEx static method
in the menu.txt resource, in File sub-menu section
