trevorsandy / lpub3d

An LDraw™ editor for LEGO® style digital building instructions.
https://trevorsandy.github.io/lpub3d/
131 stars 19 forks source link

Re-use Build Mod name (ID) #663

Closed jacovandermolen closed 1 year ago

jacovandermolen commented 1 year ago

Subject

Adding BMs re-uses a Build Mod name (ID) that is already in use.

Environment

Steps to reproduce

While working on instructions I add some Build Mods. My main model file is named main.ldr and thus the first BM you make gets the name "main.ldr Mod 1", the next "main.ldr Mod 2", and so on. Later, I decide to add a new BM before one I did add earlier. This one is named "main.ldr Mod 1" again.

Expected behaviour

Whereever I am in a model, the next available number should be used in the name for a new BM.

Actual behaviour

A number for the name of the BM is used again.

Workaround

Rename the BM manually.

Solution suggestion

LPub does know what names for BMs are used, since a menu pops up with used names if you choose to remove a BM somewhere.

trevorsandy commented 1 year ago

Thank you for reporting this behaviour.

Indeed, I saw this while testing the last update.

I'll take a look.

Cheers,

trevorsandy commented 1 year ago

This behaviour has been corrected.

The implemented behaviour change will parse the current submodel to count the number of existing build modifications. The count will be incremented by one and the submodel will be parsed again to determine if the constructed build modification key exists. If yes, the count increment and submodel parse will be repeated until the key exists parse returns false.

In the following shot. the build modification keys start at 2 and goes to 9 so there are 8 build modification keys in the current submodel. As the initially proposed new build modification key for step 2 is 9 and 9 already exist, the key is incremented and the accepted key is then 10.

Screenshot - 04_01_2023 , 04_54_54

Cheers,

jacovandermolen commented 1 year ago

Great! When is the next DevOps build due?