[LDCad] Script to Recolor Model from Inventory Parts - Printable Version +- LDraw.org Discussion Forums (https://forums.ldraw.org) +-- Forum: LDraw Programs (https://forums.ldraw.org/forum-7.html) +--- Forum: LDraw Editors and Viewers (https://forums.ldraw.org/forum-11.html) +--- Thread: [LDCad] Script to Recolor Model from Inventory Parts (/thread-26091.html) |
Script to Recolor Model from Inventory Parts - Mike C - 2022-02-28 Hello everyone, This is my first time posting on these forums and my first time using Lua, but maybe this will be useful or fun to someone else.
LDraw and LDCad have been wonderful resources for making us both happy. By coloring my designs in LDCad, I can have a plan when I begin a build with my sometimes impatient building partner. These attachments are my attempt at using Lua to let me build in LDCad without worrying about color, and then recolor the entire model with a click from the parts we actually own. Originally, I wrote this to assign color to the parts in order by their y value. But then I actually read Roland's very helpful LDCad documentation at http://www.melkert.net/LDCad/docs/scriptAPI where I saw the getComp method, and realized I could parameterize this function to easily sort along different axes (e.g., XYZ, ZYX, etc.) If anyone has ANY thoughts or suggestions, please share, as I am clearly new at this. Next, I plan on working on scripts to build walls using the parts in my inventory. Happy building, Mike |