How To calculate Distances

Here is a example to create a simple method for calculation of distance between two components.

usingPCBI.Automation;

usingPCBI.MathUtils;

usingSystem;

namespace example

{

classClassScript

{

publicvoidExecute(IPCBIWindowparent,stringReference1,stringReference2)

{

IStepstep=parent.GetCurrentStep();

if(step==null)return;

ICMPObjectcmp1=null,cmp2=null;

foreach(ICMPObjectcmpinstep.GetAllCMPObjects())

{

if(cmp.Ref==Reference1)cmp1=cmp;

elseif(cmp.Ref==Reference2)cmp2=cmp;

if(cmp1!=null&&cmp2!=null)break;

}

IODBObject.DistanceResultClassdistanceInfo=cmp1.DistanceTo(cmp2,false);

Console.WriteLine("Distancebetween"+cmp1.Ref+"and"+cmp2.Ref+"="+IMath.Mils2MM(distanceInfo.Distance).ToString("N3")+"mm");

}

}

}