Hello
I often needs to add a lot of numbers in my drawing, to identify parts, to make numbers on rules or meter number and so one.
For this, I often use a "generic" text contained "00" that I copy/paste at the right place or that I dispatch using "array copy", "polar array copy" or the "copy to point list" plugin.
But after the copy is done, I need to manually edit each text object to set the right number.
So I decided to write this small script to automate this job. (because I have a job to do that need around 80 part to renumber)
Select all the text objects to renumber, in the order you want to number them and run the script.
In the script, you can define the variables "start" that will contain the start number, "stepvalue" that will contain the step and "formatstring" that will contain the format to use for the numbers.
' dh42 05/2024
' numérotation incrémental d'une sélection d'objets texte
' incremental numbering of a selection of text objects
sub main
Dim start As Double, stepvalue As Double, currentvalue As Double
Dim formatstring As String
'########################
formatstring = "00"
start = 1
stepvalue = 1
'########################
currentvalue = start
Dim s As MText
If CamBamUI.MainUI.ActiveView.SelectedEntities.Length > 0 Then
For Each ent As Entity In CamBamUI.MainUI.ActiveView.SelectedEntities
If TypeOf ent Is MText Then
s = ent
s.Text = Format(currentvalue, formatstring)
s.Update
currentvalue = currentvalue + stepvalue
End If
Next ent
End If
end sub
Unzip the attached file and save it in your script folder.
I hope it can be useful for some.
Note VB script are not working on Linux version and on 64bits CamBam Windows version ; If needed I can turn it into a plugin so it will works on all versions.
++
David