Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where is the documentation on scripts/plugins? #1751

Open
growe19 opened this issue Aug 6, 2024 · 0 comments
Open

Where is the documentation on scripts/plugins? #1751

growe19 opened this issue Aug 6, 2024 · 0 comments
Labels

Comments

@growe19
Copy link

growe19 commented Aug 6, 2024

ArmorPaint 1.0 alpha-6246a99, Windows

Issue description:
Looking for some solid documentation on scripts and plugins so I can create something. I've been attempting all sorts using the hello_world example. And whilst I can get a nice UI there is no functionality because my code doesn't work.

Steps to reproduce:
My code to try and add Layers and Groups from a template quickly:

let plugin = new arm.Plugin();

let handle1 = new zui.Handle();

// Function to create and add layers
function addTemplatedLayers() {
let project = arm.Project.get();

if (project) {
    console.log("Project found.");

    // Create a new group layer
    let groupLayer = new arm.Layer();
    groupLayer.name = "New Group";
    groupLayer.setType(arm.LayerType.Group);
    groupLayer.init();
    
    // Create new paint layers
    let paintLayer = new arm.Layer();
    paintLayer.name = "Paint Layer";
    paintLayer.setType(arm.LayerType.Paint);
    paintLayer.init();

    let fillLayer = new arm.Layer();
    fillLayer.name = "Fill Layer";
    fillLayer.setType(arm.LayerType.Fill);
    fillLayer.init();

    let decalLayer = new arm.Layer();
    decalLayer.name = "Decal Layer";
    decalLayer.setType(arm.LayerType.Decal);
    decalLayer.init();

    // Add layers to the group
    groupLayer.children.push(paintLayer);
    groupLayer.children.push(fillLayer);
    groupLayer.children.push(decalLayer);
    console.log("Added layers to the group.");

    // Add the group to the project's root layer
    project.layerRoot.addChild(groupLayer);
    console.log("Added group to the project's root layer.");

    // Update the project and UI to reflect changes
    project.layerRoot.updateChildren();
    arm.UI.refresh();
    console.log("Updated project and UI.");
} else {
    console.error("No project found.");
}

}

plugin.drawUI = function(ui) {
if (ui.panel(handle1, "Add Templated Layers Plugin")) {
if (ui.button("Add Templated Layers")) {
addTemplatedLayers();
}
}
}

@growe19 growe19 added the bug label Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant