VPMInstance.GetFindNumber()
This method allows you to retrieve the Find Number attributes to use them in a drawing for create balloon numbers and for bill of material extraction.
Signature
VPMInstance.GetFindNumber() : String
ReturnType
String
Example
//Get child VPMInstances
let children(List)
children = iReference.Children
children = children->Filter("VPMInstance","")
//Notify("Instance size : #",children.Size())
let instance, insCompare(VPMInstance)
let reference, refCompare(VPMReference)
let i,j(Integer)
i=1
//Get Max Index and Missing List
let max(Integer)
let str(String)
let listFN,listMissing, listExisting(List)
listFN.RemoveAll()
listMissing.RemoveAll()
listExisting.RemoveAll()
max = 0
for instance inside children
{
str = instance.GetFindNumber()
if max < str.ToReal()
max = str.ToReal()
listExisting.Append(str.ToReal())
}
//Notify("max = str.ToReal() : #",max = str.ToReal())
listFN = NumbersBetweenByStep(0,max = str.ToReal(),1,true)
if fillMissing
listMissing = listFN - listExisting
max = max+1
//Notify("Max index : #",max)
//Notify("listFN : #",listFN)
//Notify("listExisting : #",listExisting)
//Notify("listMissing : #",listMissing)
for instance inside children
{
if instance.GetFindNumber() == "" // or (instance.GetFindNumber() <> NULL and fixed <> true)
{
// Check if another instance of same reference exists and have F/N
reference = instance.Reference
j=1
For j while j<=children.Size()
{
if i<> j
{
insCompare = children.GetItem(j)
refCompare = insCompare.Reference
if reference.Name == refCompare.Name and insCompare.GetFindNumber()<>""
{
//Notify("Duplicate Instance Name # and max #", insCompare.GetFindNumber())
instance.SetFindNumber(insCompare.GetFindNumber())
}
}
}
if instance.GetFindNumber() == ""
{
if fillMissing and listMissing.Size()<>0
{
instance.SetFindNumber(listMissing.GetItem(1))
listMissing->RemoveItem(1)
} else
{
//Notify("Instance Name # and max #",instance.Name,max)
instance.SetFindNumber(max)
max = max + 1
}
}
}
i=i+1
}