Page 1 of 1
Script loading as addon but not as a menu item in tools
Posted: Fri Sep 12, 2025 2:55 pm
by Shakadula5153
I have a script but for the life of me I cannot get mm5 to add it as a menu item so I may execute it. Missing something basic.
Thoughts
Re: Script loading as addon but not as a menu item in tools
Posted: Fri Sep 12, 2025 5:17 pm
by Peke
Hi,
Please open support Ticket and supply sample of script, so that we can peek. Unless you want to release it here so that others can tweak it too?
Re: Script loading as addon but not as a menu item in tools
Posted: Sat Sep 13, 2025 9:09 am
by Shakadula5153
Here you go. It should only execute one time: Don't need a menu item cause I can't figure that out so one time executable works for me.
JSON:
Code: Select all
{
"id": "appendyear",
"title": "Append Year to Title",
"description": "Appends the Year to track titles (runs once only)",
"version": "1.4.0",
"author": "Shaka",
"type": "script",
"files": [
{ "filename": "AppendYear.JS", "type": "script" }
]
}
AppendYear:
// AppendYear.JS
// Appends year to track titles once, then never again.
app.listen(app.events.startup, async () => {
try {
// Check flag
let alreadyRun = await app.settings.get("AppendYear", "done");
if (alreadyRun === "true") {
console.log("AppendYearToTitle already executed, skipping.");
return;
}
let sql = `
UPDATE Songs
SET SongTitle = SongTitle || ' (' || substr(CAST(Year AS TEXT), 1, 4) || ')'
WHERE Year IS NOT NULL
AND Year > 0
AND SongTitle NOT LIKE '% (' || substr(CAST(Year AS TEXT), 1, 4) || ')'
`;
await app.db.execute(sql);
console.log("AppendYearToTitle executed. Marking as done.");
await app.settings.set("AppendYear", "done", "true");
// Popup confirmation
ui.messageBox("AppendYearToTitle executed successfully!");
} catch (e) {
ui.messageBox("Error in AppendYearToTitle: " + e);
}
});
Re: Script loading as addon but not as a menu item in tools
Posted: Sun Sep 14, 2025 3:24 am
by Shakadula5153
trying something new.
Update Songs
SET SongTitle = SongTitle || ' (' || substr(CAST(Year AS TEXT), 1, 4) || ')'
WHERE Year IS NOT NULL
AND length(CAST(Year AS TEXT)) >= 4
AND SongTitle NOT LIKE '%(' || substr(CAST(Year AS TEXT), 1, 4) || ')';
I am executing this in the SQLITE editor but no updates are happening. When I query with no update I get the results I want but changing to update has no effect. Thoughts?
Again, this is a ONE time execution.
Re: Script loading as addon but not as a menu item in tools
Posted: Sun Sep 14, 2025 4:29 am
by Shakadula5153
Update: I got my update to work on my test machine and now I am working on my production machine. Problem is this debug version I am using is clugie. I get errors when I exit and have to close from a test box stating to continue in safe mode etc. Anyway I am going to install the standard version of MM to see is that helps. Update: Installed standard version and it still noes not work and throws runtime error 217 when exiting application. SQL Editor also does not work.
Also in this version of MM my SQL Editor does not work. I get the editor but it will not let me type into the sql command box. GEEEZZZZZZZ,
So my new SQL code to concatenate Year to title is:
UPDATE Songs
SET SongTitle = SongTitle || ' (' || substr(CAST(Year AS TEXT), 1, 4) || ')'
WHERE Year IS NOT NULL
AND length(CAST(Year AS TEXT)) >= 4
AND SongTitle NOT LIKE '%(' || substr(CAST(Year AS TEXT), 1, 4) || ')';
So I should get "I Got You Babe (6507) From "I Got You Babe"
Running version 2024.2.0.3167. I think this is 32 bit. Don't I want 64bit?
Re: Script loading as addon but not as a menu item in tools
Posted: Mon Sep 15, 2025 1:52 pm
by Shakadula5153
figured it out. Reinstalled MM5. SQL works fine new.
Please disregard thread.
Re: Script loading as addon but not as a menu item in tools
Posted: Tue Sep 23, 2025 10:28 am
by Alim_online
If the script shows up as an add-on but not under Tools, you need to append your operator to a menu, e.g.:
def menu_func(self, context):
self.layout.operator("myaddon.my_operator")
def register():
bpy.utils.register_class(MyOperator)
bpy.types.VIEW3D_MT_object.append(menu_func)
Otherwise it won’t appear in Tools.
Re: Script loading as addon but not as a menu item in tools
Posted: Mon Oct 27, 2025 7:43 pm
by christopher.wanko
Shakadula5153 wrote: ↑Sun Sep 14, 2025 4:29 am
UPDATE Songs
SET SongTitle = SongTitle || ' (' || substr(CAST(Year AS TEXT), 1, 4) || ')'
WHERE Year IS NOT NULL
AND length(CAST(Year AS TEXT)) >= 4
AND SongTitle NOT LIKE '%(' || substr(CAST(Year AS TEXT), 1, 4) || ')';
This is bugging me. You presumably want the year only once in the song title? What if your song title is formatted like "I Got You Babe - 1971 " ? Your SQL won't match. Your SQL *only* matches on the presence of your formatting rule. Are you sure this is what you want to have happen?
For example, you might prefer to leave any prior year formats alone for the time being:
UPDATE songs
SET songtitle = songtitle || ' (' || SUBSTR(CAST(year AS TEXT), 1, 4) || ')'
WHERE year IS NOT NULL AND year > 0 AND SUBSTR(year,1,4) BETWEEN '1900' AND '2025'
AND songtitle NOT LIKE '%'||SUBSTR(year,1,4)||'%'
;;
Just consider this.
--#