function in getParameterDefinition

  • Hello everyone, i don't know if i'm at the right place. I want to know if there is a way to use some function in getParameterDefinitions. i have a list of things that i always use as parameter in my jscad project. Each time i change something in this list i have to open all my jscad files and change my parameters. Is there any way to put my list in an include file and retrieve it in the getParameterDefinition? Hope i'm clear. Thanks in advance for your answers

  • Thanks @kaosat-dev Kaosat-dev but it's not really what i'm trying to do. I have a first file that contains parameters for screws to make holes easily in printed parts you have countersunk head, hexagonal head, cylindrical head etc... and for each you have different diameters of scew. For each new files that i creates who use this include file i've to make a section of choice in getParameterDefinitions . Is it posible to do something to retrieve those parameters directly in the first file. an exemple of what i'm trying to do:

    listdrill = function listdrill(type){
    var toreturn = [];
    if (type == ' countersunk'){
    if( type =='hexagonal'){
    toreturn = [......
    return toreturn;
    and in the other file :

    function getParameterDefinitions{
    var listdrill = listdrill(type);
    var foruser='{name:'drillDiameter', initial: '3', type:'choice', caption: 'diameter', values: [';
    foruser= foruser+'''+listdrill[i][0]+'',';}
    This is an exemple of what i'm trying to do. Hope it's a little bit clearer. it partialy work in the main part of a program but not in the getParameterDefinitions. Sorry i haven't found the way to put the code in black. Sorry for my pour english, i'm a french guy. Do you think it's possible? I've tryed with require that you have mentioned but jscad answer me ReferenceError: require is not defined. Thanks for reading hopes that a solution exist. Best regards

  • administrators

    Hi @imkael !
    I regularly use something similar (if I get your question right): ie store all defaults for parameters for re-use (, however I am not sure it would work for the old 'include' syntax: but you can get it working trivially using the 'require' module syntax (available in the V2 prototype, CLI & the desktop app):

    in a file called 'parameterDefaults.js' (or whatever you want to call it)

    const paramDefaults = {
      quality: 120,
      robotName: 'SMARS',
    module.exports = paramDefaults

    and then you can simply require that module as you need it:

    const paramDefaults = require('./parameterDefaults.js')
    //code that uses those values elsewhere

    hope this helps !