<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[function in getParameterDefinition]]></title><description><![CDATA[<p dir="auto">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</p>
]]></description><link>https://openjscad.nodebb.com/topic/86/function-in-getparameterdefinition</link><generator>RSS for Node</generator><lastBuildDate>Sun, 15 Mar 2026 04:52:58 GMT</lastBuildDate><atom:link href="https://openjscad.nodebb.com/topic/86.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 02 May 2019 13:31:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to function in getParameterDefinition on Sat, 02 Nov 2019 12:03:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://openjscad.nodebb.com/uid/2">@kaosat-dev</a>  thanks for your reply i haven't test it  yet  (I just saw it today). i will tell you if it's works for me. Best regards</p>
]]></description><link>https://openjscad.nodebb.com/post/193</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/193</guid><dc:creator><![CDATA[imkael]]></dc:creator><pubDate>Sat, 02 Nov 2019 12:03:57 GMT</pubDate></item><item><title><![CDATA[Reply to function in getParameterDefinition on Mon, 27 May 2019 06:45:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://openjscad.nodebb.com/uid/18">@imkael</a> désolé pour la réponse très tardive !</p>
<ul>
<li>la version expérimentale avec gestion de modules est ici: <a href="https://jscad.xyz/playground.html" rel="nofollow ugc">https://jscad.xyz/playground.html</a></li>
<li>si j'ai bien compris, oui ça devrait être possible</li>
<li>il faudra juste bien exporter les bonnes variables dans chaque module:</li>
</ul>
<p dir="auto">drilling.jscad</p>
<pre><code class="language-javascript">const listdrill = function listdrill(type) {

  var toreturn = [];
  if (type == ' countersunk'){
  toreturn=[
    [1.6,3.73,1],
    [2,4.78,1.1],
    [3,6.82,1.4],
  ...
  ];
  if( type =='hexagonal'){
    toreturn = [......
  ];
  return toreturn;
}
// IMPORTANT !!
module.exports = listdrill

</code></pre>
<p dir="auto">index.jscad</p>
<pre><code class="language-javascript">const listdrill = require('..path/to/drilling.jscad')

function getParameterDefinitions{
  const listdrillPerType = listdrill(type);
  const foruser = '{name:'drillDiameter', initial: '3', type:'choice', caption: 'diameter', values: [';
  for(i=0;i&lt;listdrillPerType.length;i++) {
   foruser= foruser+'''+listdrillPerType[i][0]+'',';}
    ...
  return[
    foruser,
  ];
 }

function main (params) {
}

module.exports = { getParameterDefinitions, main }
</code></pre>
]]></description><link>https://openjscad.nodebb.com/post/138</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/138</guid><dc:creator><![CDATA[kaosat-dev]]></dc:creator><pubDate>Mon, 27 May 2019 06:45:47 GMT</pubDate></item><item><title><![CDATA[Reply to function in getParameterDefinition on Mon, 06 May 2019 08:32:24 GMT]]></title><description><![CDATA[<p dir="auto">Thanks <a class="plugin-mentions-user plugin-mentions-a" href="https://openjscad.nodebb.com/uid/2">@kaosat-dev</a> 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:</p>
<p dir="auto">drilling.jscad<br />
[code]<br />
listdrill = function listdrill(type){<br />
var toreturn = [];<br />
if (type == ' countersunk'){<br />
toreturn=[<br />
[1.6,3.73,1],<br />
[2,4.78,1.1],<br />
[3,6.82,1.4],<br />
...<br />
];<br />
if( type =='hexagonal'){<br />
toreturn = [......<br />
];<br />
}<br />
return toreturn;<br />
}<br />
[/code]<br />
and in the other file :<br />
[code]<br />
include("..path/to/drilling.jscad");</p>
<p dir="auto">function getParameterDefinitions{<br />
var listdrill = listdrill(type);<br />
var foruser='{name:'drillDiameter', initial: '3', type:'choice', caption: 'diameter', values: [';<br />
for(i=0;i&lt;listdrill.length;i++){<br />
foruser= foruser+'''+listdrill[i][0]+'',';}<br />
...<br />
return[<br />
foruser,<br />
];<br />
}<br />
[/code]<br />
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</p>
]]></description><link>https://openjscad.nodebb.com/post/119</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/119</guid><dc:creator><![CDATA[imkael]]></dc:creator><pubDate>Mon, 06 May 2019 08:32:24 GMT</pubDate></item><item><title><![CDATA[Reply to function in getParameterDefinition on Fri, 03 May 2019 21:09:16 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="https://openjscad.nodebb.com/uid/18">@imkael</a> !<br />
I regularly use something similar (if I get your question right): ie store all defaults for parameters for re-use (<a href="https://github.com/PiRo-bots/kiwikee/blob/master/cad/kiwikee/index.js#L14" rel="nofollow ugc">https://github.com/PiRo-bots/kiwikee/blob/master/cad/kiwikee/index.js#L14</a>), 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 &amp; the desktop app):</p>
<p dir="auto">in a file called 'parameterDefaults.js' (or whatever you want to call it)</p>
<pre><code class="language-javascript">const paramDefaults = {
  quality: 120,
  robotName: 'SMARS',
}

module.exports = paramDefaults
</code></pre>
<p dir="auto">and then you can simply require that module as you need it:</p>
<pre><code class="language-javascript">const paramDefaults = require('./parameterDefaults.js')
//code that uses those values elsewhere
</code></pre>
<p dir="auto">hope this helps !</p>
]]></description><link>https://openjscad.nodebb.com/post/118</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/118</guid><dc:creator><![CDATA[kaosat-dev]]></dc:creator><pubDate>Fri, 03 May 2019 21:09:16 GMT</pubDate></item></channel></rss>