MAKE_NAME(nged)

make a unique name

πŸ“… published 7.44.0, from nixpkgs unstable

πŸ’… MAKE_NAME(nged) β€” bestie's guide to making unique names ✨

okay so welcome to make_name, a little command from the BRL-CAD User Commands fam that literally just makes you a unique object name, and honestly? it eats. πŸŽ€


🌸 SYNOPSIS 🌸

make_name template | -s [num]

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe: make_name generates a unique object name by substituting an auto-incrementing integer counter into the template string you hand it. the counter starts at 0 and increments every single time a name is generated. ✨

and before it ever returns a name to you, make_name verifies the name does not already exist in the database β€” and if it does, it just keeps incrementing the counter further until it finds an unused name. no cap, it checks. πŸ‘‘

the template string uses the @ character as a placeholder, and that @ gets replaced by the current counter value:

  • prefix@suffix β€” the @ is replaced by the current counter value. for example, part@.s might produce part0.s, part1.s, etc. πŸ“
  • name with no @ β€” if there's no @ present, the counter value is appended directly to the end of the template. simple as that πŸ’…
  • @@ β€” a literal @@ in the template is treated as an escaped @ and is passed through unchanged (it does not get replaced by the counter). iykyk 🧚

the counter is shared across all calls within the same session and persists until it's reset with -s. so like… it remembers. main character energy fr fr πŸ’œ


✨ OPTIONS ✨

  • -s [num] β€” set the internal counter to num. if num is omitted, the counter is reset to 0. πŸŽ€

πŸ”₯ EXAMPLES πŸ”₯

Example 1. Generate unique names with a prefix template

mged> make_name part@.s mged> make_name part@.s mged> make_name part@.s

    part0.s
    part1.s
    part2.s

each call increments the internal counter, producing a new unique name. and if part0.s already existed in the database, the first call would return part1.s instead. see how that works? 😭✨

Example 2. Generate a name with no @ placeholder

mged> make_name widget

widget0

with no @ in the template, the counter is appended to the end of the string. periodt. πŸ’…

Example 3. Reset the counter and restart numbering

mged> make_name part@.s mged> make_name -s 100 mged> make_name part@.s

    part3.s
    part100.s

after generating part3.s, the counter is set to 100 with -s 100. the next call then produces part100.s. iconic behaviour tbh 🌈


πŸ‘‘ AUTHOR πŸ‘‘

BRL-CAD Team β€” legends, honestly 🫢


πŸ’€ BUG REPORTS πŸ’€

reports of bugs or problems should be submitted via electronic mail to devs@brlcad.org. pls be nice to them πŸ™ˆ

ngl if something's acting cursed, that's the address β€” don't just suffer in silence bestie πŸ’–

so yeah, that's make_name πŸ’œ this page comes to you from BRL-CAD in the BRL-CAD User Commands collection β€” MAKE_NAME(nged), mwah, go make some names that don't collide πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from