discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

using hasmaps in OpenSCAD and PythonSCAD.

JD
John David
Thu, Feb 12, 2026 12:41 AM

I am trying to use a hashmap that will work in both OpenSCAD and
PythonSCAD, but I keep getting errors that the function is not found.  Has
anyone had success in calling OpenSCAD code from PythonSCAD, which includes
a hashmap?

A snippet of the code is as follows:

OpenSCAD:
///////////////
Color_Table =
hashmap(items=[ // the laser color parameters (name,power,feed,color)
["L00",[1.0,1.0,0x000000]],
["L01",[1.0,1.0,0x0000FF]],
["L02",[1.0,1.0,0xFF0000]],
["L29",[1.0,1.0,0xFFDB66]],
["T1",[0.0,0.0,0xF36926]],
["T2",[0.0,0.0,0x0C96D9]]
]
);

function Color_Table_to_color(name) =  Color_Table[name][2];
///////////////

I have also tried making the color table a function (function Color_Table()
= ...)

Any suggestions?

I am trying to use a hashmap that will work in both OpenSCAD and PythonSCAD, but I keep getting errors that the function is not found. Has anyone had success in calling OpenSCAD code from PythonSCAD, which includes a hashmap? A snippet of the code is as follows: OpenSCAD: /////////////// Color_Table = hashmap(items=[ // the laser color parameters (name,power,feed,color) ["L00",[1.0,1.0,0x000000]], ["L01",[1.0,1.0,0x0000FF]], ["L02",[1.0,1.0,0xFF0000]], ["L29",[1.0,1.0,0xFFDB66]], ["T1",[0.0,0.0,0xF36926]], ["T2",[0.0,0.0,0x0C96D9]] ] ); function Color_Table_to_color(name) = Color_Table[name][2]; /////////////// I have also tried making the color table a function (function Color_Table() = ...) Any suggestions?
JB
Jordan Brown
Thu, Feb 12, 2026 12:54 AM

OpenSCAD proper does not have a hashmap() function and does not have
anything called a "hashmap".  It does have objects, which are probably
similar:

Color_Table = object([ // the laser color parameters (name,power,feed,color)
["L00",[1.0,1.0,0x000000]],
["L01",[1.0,1.0,0x0000FF]],
["L02",[1.0,1.0,0xFF0000]],
["L29",[1.0,1.0,0xFFDB66]],
["T1",[0.0,0.0,0xF36926]],
["T2",[0.0,0.0,0x0C96D9]]
]);

I have no idea whether obejcts are integrated into PythonSCAD, or
whether PythonSCAD exports a hashmap() function into OpenSCAD.

OpenSCAD proper does not have a hashmap() function and does not have anything called a "hashmap".  It does have objects, which are probably similar: Color_Table = object([ // the laser color parameters (name,power,feed,color) ["L00",[1.0,1.0,0x000000]], ["L01",[1.0,1.0,0x0000FF]], ["L02",[1.0,1.0,0xFF0000]], ["L29",[1.0,1.0,0xFFDB66]], ["T1",[0.0,0.0,0xF36926]], ["T2",[0.0,0.0,0x0C96D9]] ]); I have no idea whether obejcts are integrated into PythonSCAD, or whether PythonSCAD exports a hashmap() function into OpenSCAD.
JD
John David
Thu, Feb 12, 2026 3:26 AM

I've used hashmaps with BOSL2 in the past, but thought hm was part of the
OpenSCAD primitives.  That is why I tried it.

I just tried your object code, and it failed as well.  I'll keep looking
for similar functionality that works for both code bases.

Thank you!

On Wed, Feb 11, 2026 at 7:54 PM Jordan Brown openscad@jordan.maileater.net
wrote:

OpenSCAD proper does not have a hashmap() function and does not have
anything called a "hashmap".  It does have objects, which are probably
similar:

Color_Table = object([ // the laser color parameters (name,power,feed,color)
["L00",[1.0,1.0,0x000000]],
["L01",[1.0,1.0,0x0000FF]],
["L02",[1.0,1.0,0xFF0000]],
["L29",[1.0,1.0,0xFFDB66]],
["T1",[0.0,0.0,0xF36926]],
["T2",[0.0,0.0,0x0C96D9]]
]);

I have no idea whether obejcts are integrated into PythonSCAD, or whether
PythonSCAD exports a hashmap() function into OpenSCAD.

I've used hashmaps with BOSL2 in the past, but thought hm was part of the OpenSCAD primitives. That is why I tried it. I just tried your object code, and it failed as well. I'll keep looking for similar functionality that works for both code bases. Thank you! On Wed, Feb 11, 2026 at 7:54 PM Jordan Brown <openscad@jordan.maileater.net> wrote: > OpenSCAD proper does not have a hashmap() function and does not have > anything called a "hashmap". It does have objects, which are probably > similar: > > Color_Table = object([ // the laser color parameters (name,power,feed,color) > ["L00",[1.0,1.0,0x000000]], > ["L01",[1.0,1.0,0x0000FF]], > ["L02",[1.0,1.0,0xFF0000]], > ["L29",[1.0,1.0,0xFFDB66]], > ["T1",[0.0,0.0,0xF36926]], > ["T2",[0.0,0.0,0x0C96D9]] > ]); > > I have no idea whether obejcts are integrated into PythonSCAD, or whether > PythonSCAD exports a hashmap() function into OpenSCAD. > > >
JL
Jamie Larkby-Lahet
Thu, Feb 12, 2026 4:02 AM

you can use search() to treat a vector of key vaue pairs as a map. object()
is in the dev builds only at this time.

https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#search

On Wed, Feb 11, 2026, 21:27 John David via Discuss <
discuss@lists.openscad.org> wrote:

I've used hashmaps with BOSL2 in the past, but thought hm was part of the
OpenSCAD primitives.  That is why I tried it.

I just tried your object code, and it failed as well.  I'll keep looking
for similar functionality that works for both code bases.

Thank you!

On Wed, Feb 11, 2026 at 7:54 PM Jordan Brown <
openscad@jordan.maileater.net> wrote:

OpenSCAD proper does not have a hashmap() function and does not have
anything called a "hashmap".  It does have objects, which are probably
similar:

Color_Table = object([ // the laser color parameters (name,power,feed,color)
["L00",[1.0,1.0,0x000000]],
["L01",[1.0,1.0,0x0000FF]],
["L02",[1.0,1.0,0xFF0000]],
["L29",[1.0,1.0,0xFFDB66]],
["T1",[0.0,0.0,0xF36926]],
["T2",[0.0,0.0,0x0C96D9]]
]);

I have no idea whether obejcts are integrated into PythonSCAD, or whether
PythonSCAD exports a hashmap() function into OpenSCAD.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

you can use search() to treat a vector of key vaue pairs as a map. object() is in the dev builds only at this time. https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#search On Wed, Feb 11, 2026, 21:27 John David via Discuss < discuss@lists.openscad.org> wrote: > I've used hashmaps with BOSL2 in the past, but thought hm was part of the > OpenSCAD primitives. That is why I tried it. > > I just tried your object code, and it failed as well. I'll keep looking > for similar functionality that works for both code bases. > > Thank you! > > On Wed, Feb 11, 2026 at 7:54 PM Jordan Brown < > openscad@jordan.maileater.net> wrote: > >> OpenSCAD proper does not have a hashmap() function and does not have >> anything called a "hashmap". It does have objects, which are probably >> similar: >> >> Color_Table = object([ // the laser color parameters (name,power,feed,color) >> ["L00",[1.0,1.0,0x000000]], >> ["L01",[1.0,1.0,0x0000FF]], >> ["L02",[1.0,1.0,0xFF0000]], >> ["L29",[1.0,1.0,0xFFDB66]], >> ["T1",[0.0,0.0,0xF36926]], >> ["T2",[0.0,0.0,0x0C96D9]] >> ]); >> >> I have no idea whether obejcts are integrated into PythonSCAD, or whether >> PythonSCAD exports a hashmap() function into OpenSCAD. >> >> >> _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
JB
Jordan Brown
Thu, Feb 12, 2026 4:24 AM

On 2/11/2026 7:26 PM, John David wrote:

I just tried your object code, and it failed as well.  I'll keep
looking for similar functionality that works for both code bases.

I have no idea whether it integrates with PythonSCAD.

It definitely works in OpenSCAD development snapshots, but it is
considered an "experimental" feature and so you must enable it using
Preferences/Features.

On 2/11/2026 7:26 PM, John David wrote: > I just tried your object code, and it failed as well.  I'll keep > looking for similar functionality that works for both code bases. I have no idea whether it integrates with PythonSCAD. It definitely works in OpenSCAD development snapshots, but it is considered an "experimental" feature and so you must enable it using Preferences/Features.
GS
Guenther Sohler
Thu, Feb 12, 2026 7:07 AM

In PythonSCAD you can leverage all features which comes with python,
So also hashes(python dicts)
This sample works:

hash.py:

def colorhash(key):
Color_Table ={
"L00": [1.0,1.0,0x000000],
"L01":[1.0,1.0,0x0000FF],
"L02":[1.0,1.0,0xFF0000],
"L29":[1.0,1.0,0xFFDB66],
"T1":[0.0,0.0,0xF36926],
"T2":[0.0,0.0,0x0C96D9]}
return Color_Table[key]

hash.scad:

use <hash.py>
echo(colorhash("L02"));

PythonSCAD aims to be 100% openscad compatible. so I has OpenSCAD objects,
but Python dicts are powerful anyway.
Look into hash.scad and see the ease how to export python functions ito
SCAD code.

Cheers

~
~

On Thu, Feb 12, 2026 at 1:54 AM Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:

OpenSCAD proper does not have a hashmap() function and does not have
anything called a "hashmap".  It does have objects, which are probably
similar:

Color_Table = object([ // the laser color parameters (name,power,feed,color)
["L00",[1.0,1.0,0x000000]],
["L01",[1.0,1.0,0x0000FF]],
["L02",[1.0,1.0,0xFF0000]],
["L29",[1.0,1.0,0xFFDB66]],
["T1",[0.0,0.0,0xF36926]],
["T2",[0.0,0.0,0x0C96D9]]
]);

I have no idea whether obejcts are integrated into PythonSCAD, or whether
PythonSCAD exports a hashmap() function into OpenSCAD.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

In PythonSCAD you can leverage all features which comes with python, So also hashes(python dicts) This sample works: hash.py: def colorhash(key): Color_Table ={ "L00": [1.0,1.0,0x000000], "L01":[1.0,1.0,0x0000FF], "L02":[1.0,1.0,0xFF0000], "L29":[1.0,1.0,0xFFDB66], "T1":[0.0,0.0,0xF36926], "T2":[0.0,0.0,0x0C96D9]} return Color_Table[key] hash.scad: use <hash.py> echo(colorhash("L02")); PythonSCAD aims to be 100% openscad compatible. so I has OpenSCAD objects, but Python dicts are powerful anyway. Look into hash.scad and see the ease how to export python functions ito SCAD code. Cheers ~ ~ On Thu, Feb 12, 2026 at 1:54 AM Jordan Brown via Discuss < discuss@lists.openscad.org> wrote: > OpenSCAD proper does not have a hashmap() function and does not have > anything called a "hashmap". It does have objects, which are probably > similar: > > Color_Table = object([ // the laser color parameters (name,power,feed,color) > ["L00",[1.0,1.0,0x000000]], > ["L01",[1.0,1.0,0x0000FF]], > ["L02",[1.0,1.0,0xFF0000]], > ["L29",[1.0,1.0,0xFFDB66]], > ["T1",[0.0,0.0,0xF36926]], > ["T2",[0.0,0.0,0x0C96D9]] > ]); > > I have no idea whether obejcts are integrated into PythonSCAD, or whether > PythonSCAD exports a hashmap() function into OpenSCAD. > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
JD
John David
Sat, Feb 14, 2026 5:36 AM

Sorry I did not see this before I spent a lot of time messing from the
OpenSCAD side today.  I'll go back and give the python to openscad side a
try.

BTW, I got something similar to this working from pure OpenSCAD, but the
colorhash is immutable and I was planning to allow the user to be able to
set the power and feeds associated with the colormap.

Anyway, I'll give the python-first a try later.

EBo --

On Thu, Feb 12, 2026 at 2:07 AM Guenther Sohler via Discuss <
discuss@lists.openscad.org> wrote:

In PythonSCAD you can leverage all features which comes with python,
So also hashes(python dicts)
This sample works:

hash.py:

def colorhash(key):
Color_Table ={
"L00": [1.0,1.0,0x000000],
"L01":[1.0,1.0,0x0000FF],
"L02":[1.0,1.0,0xFF0000],
"L29":[1.0,1.0,0xFFDB66],
"T1":[0.0,0.0,0xF36926],
"T2":[0.0,0.0,0x0C96D9]}
return Color_Table[key]

hash.scad:

use <hash.py>
echo(colorhash("L02"));

PythonSCAD aims to be 100% openscad compatible. so I has OpenSCAD objects,
but Python dicts are powerful anyway.
Look into hash.scad and see the ease how to export python functions ito
SCAD code.

Cheers

~
~

On Thu, Feb 12, 2026 at 1:54 AM Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:

OpenSCAD proper does not have a hashmap() function and does not have
anything called a "hashmap".  It does have objects, which are probably
similar:

Color_Table = object([ // the laser color parameters (name,power,feed,color)
["L00",[1.0,1.0,0x000000]],
["L01",[1.0,1.0,0x0000FF]],
["L02",[1.0,1.0,0xFF0000]],
["L29",[1.0,1.0,0xFFDB66]],
["T1",[0.0,0.0,0xF36926]],
["T2",[0.0,0.0,0x0C96D9]]
]);

I have no idea whether obejcts are integrated into PythonSCAD, or whether
PythonSCAD exports a hashmap() function into OpenSCAD.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Sorry I did not see this before I spent a lot of time messing from the OpenSCAD side today. I'll go back and give the python to openscad side a try. BTW, I got something similar to this working from pure OpenSCAD, but the colorhash is immutable and I was planning to allow the user to be able to set the power and feeds associated with the colormap. Anyway, I'll give the python-first a try later. EBo -- On Thu, Feb 12, 2026 at 2:07 AM Guenther Sohler via Discuss < discuss@lists.openscad.org> wrote: > In PythonSCAD you can leverage all features which comes with python, > So also hashes(python dicts) > This sample works: > > hash.py: > > def colorhash(key): > Color_Table ={ > "L00": [1.0,1.0,0x000000], > "L01":[1.0,1.0,0x0000FF], > "L02":[1.0,1.0,0xFF0000], > "L29":[1.0,1.0,0xFFDB66], > "T1":[0.0,0.0,0xF36926], > "T2":[0.0,0.0,0x0C96D9]} > return Color_Table[key] > > hash.scad: > > use <hash.py> > echo(colorhash("L02")); > > PythonSCAD aims to be 100% openscad compatible. so I has OpenSCAD objects, > but Python dicts are powerful anyway. > Look into hash.scad and see the ease how to export python functions ito > SCAD code. > > Cheers > > > ~ > ~ > > On Thu, Feb 12, 2026 at 1:54 AM Jordan Brown via Discuss < > discuss@lists.openscad.org> wrote: > >> OpenSCAD proper does not have a hashmap() function and does not have >> anything called a "hashmap". It does have objects, which are probably >> similar: >> >> Color_Table = object([ // the laser color parameters (name,power,feed,color) >> ["L00",[1.0,1.0,0x000000]], >> ["L01",[1.0,1.0,0x0000FF]], >> ["L02",[1.0,1.0,0xFF0000]], >> ["L29",[1.0,1.0,0xFFDB66]], >> ["T1",[0.0,0.0,0xF36926]], >> ["T2",[0.0,0.0,0x0C96D9]] >> ]); >> >> I have no idea whether obejcts are integrated into PythonSCAD, or whether >> PythonSCAD exports a hashmap() function into OpenSCAD. >> >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
JD
John David
Sat, Feb 14, 2026 5:37 AM

BTW, I am getting the error "

Parsing design (AST generation)...

ERROR: File not trusted
'/home/ebo/.local/share/OpenSCAD/libraries/tabbed-box/colormap.py'

Any idea how to turn that off?

On Sat, Feb 14, 2026 at 12:36 AM John David ebo.2112@gmail.com wrote:

Sorry I did not see this before I spent a lot of time messing from the
OpenSCAD side today.  I'll go back and give the python to openscad side a
try.

BTW, I got something similar to this working from pure OpenSCAD, but the
colorhash is immutable and I was planning to allow the user to be able to
set the power and feeds associated with the colormap.

Anyway, I'll give the python-first a try later.

EBo --

On Thu, Feb 12, 2026 at 2:07 AM Guenther Sohler via Discuss <
discuss@lists.openscad.org> wrote:

In PythonSCAD you can leverage all features which comes with python,
So also hashes(python dicts)
This sample works:

hash.py:

def colorhash(key):
Color_Table ={
"L00": [1.0,1.0,0x000000],
"L01":[1.0,1.0,0x0000FF],
"L02":[1.0,1.0,0xFF0000],
"L29":[1.0,1.0,0xFFDB66],
"T1":[0.0,0.0,0xF36926],
"T2":[0.0,0.0,0x0C96D9]}
return Color_Table[key]

hash.scad:

use <hash.py>
echo(colorhash("L02"));

PythonSCAD aims to be 100% openscad compatible. so I has OpenSCAD
objects, but Python dicts are powerful anyway.
Look into hash.scad and see the ease how to export python functions ito
SCAD code.

Cheers

~
~

On Thu, Feb 12, 2026 at 1:54 AM Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:

OpenSCAD proper does not have a hashmap() function and does not have
anything called a "hashmap".  It does have objects, which are probably
similar:

Color_Table = object([ // the laser color parameters (name,power,feed,color)
["L00",[1.0,1.0,0x000000]],
["L01",[1.0,1.0,0x0000FF]],
["L02",[1.0,1.0,0xFF0000]],
["L29",[1.0,1.0,0xFFDB66]],
["T1",[0.0,0.0,0xF36926]],
["T2",[0.0,0.0,0x0C96D9]]
]);

I have no idea whether obejcts are integrated into PythonSCAD, or
whether PythonSCAD exports a hashmap() function into OpenSCAD.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

BTW, I am getting the error " Parsing design (AST generation)... ERROR: File not trusted '/home/ebo/.local/share/OpenSCAD/libraries/tabbed-box/colormap.py' Any idea how to turn that off? On Sat, Feb 14, 2026 at 12:36 AM John David <ebo.2112@gmail.com> wrote: > Sorry I did not see this before I spent a lot of time messing from the > OpenSCAD side today. I'll go back and give the python to openscad side a > try. > > BTW, I got something similar to this working from pure OpenSCAD, but the > colorhash is immutable and I was planning to allow the user to be able to > set the power and feeds associated with the colormap. > > Anyway, I'll give the python-first a try later. > > EBo -- > > On Thu, Feb 12, 2026 at 2:07 AM Guenther Sohler via Discuss < > discuss@lists.openscad.org> wrote: > >> In PythonSCAD you can leverage all features which comes with python, >> So also hashes(python dicts) >> This sample works: >> >> hash.py: >> >> def colorhash(key): >> Color_Table ={ >> "L00": [1.0,1.0,0x000000], >> "L01":[1.0,1.0,0x0000FF], >> "L02":[1.0,1.0,0xFF0000], >> "L29":[1.0,1.0,0xFFDB66], >> "T1":[0.0,0.0,0xF36926], >> "T2":[0.0,0.0,0x0C96D9]} >> return Color_Table[key] >> >> hash.scad: >> >> use <hash.py> >> echo(colorhash("L02")); >> >> PythonSCAD aims to be 100% openscad compatible. so I has OpenSCAD >> objects, but Python dicts are powerful anyway. >> Look into hash.scad and see the ease how to export python functions ito >> SCAD code. >> >> Cheers >> >> >> ~ >> ~ >> >> On Thu, Feb 12, 2026 at 1:54 AM Jordan Brown via Discuss < >> discuss@lists.openscad.org> wrote: >> >>> OpenSCAD proper does not have a hashmap() function and does not have >>> anything called a "hashmap". It does have objects, which are probably >>> similar: >>> >>> Color_Table = object([ // the laser color parameters (name,power,feed,color) >>> ["L00",[1.0,1.0,0x000000]], >>> ["L01",[1.0,1.0,0x0000FF]], >>> ["L02",[1.0,1.0,0xFF0000]], >>> ["L29",[1.0,1.0,0xFFDB66]], >>> ["T1",[0.0,0.0,0xF36926]], >>> ["T2",[0.0,0.0,0x0C96D9]] >>> ]); >>> >>> I have no idea whether obejcts are integrated into PythonSCAD, or >>> whether PythonSCAD exports a hashmap() function into OpenSCAD. >>> >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org > >
GS
Guenther Sohler
Sat, Feb 14, 2026 5:46 AM

yes, of course,

just launch PythonSCAD with --trust-python

many folks actually install this option into the desktop symbol ...

On Sat, Feb 14, 2026 at 6:37 AM John David ebo.2112@gmail.com wrote:

BTW, I am getting the error "

Parsing design (AST generation)...

ERROR: File not trusted
'/home/ebo/.local/share/OpenSCAD/libraries/tabbed-box/colormap.py'

Any idea how to turn that off?

On Sat, Feb 14, 2026 at 12:36 AM John David ebo.2112@gmail.com wrote:

Sorry I did not see this before I spent a lot of time messing from the
OpenSCAD side today.  I'll go back and give the python to openscad side a
try.

BTW, I got something similar to this working from pure OpenSCAD, but the
colorhash is immutable and I was planning to allow the user to be able to
set the power and feeds associated with the colormap.

Anyway, I'll give the python-first a try later.

EBo --

On Thu, Feb 12, 2026 at 2:07 AM Guenther Sohler via Discuss <
discuss@lists.openscad.org> wrote:

In PythonSCAD you can leverage all features which comes with python,
So also hashes(python dicts)
This sample works:

hash.py:

def colorhash(key):
Color_Table ={
"L00": [1.0,1.0,0x000000],
"L01":[1.0,1.0,0x0000FF],
"L02":[1.0,1.0,0xFF0000],
"L29":[1.0,1.0,0xFFDB66],
"T1":[0.0,0.0,0xF36926],
"T2":[0.0,0.0,0x0C96D9]}
return Color_Table[key]

hash.scad:

use <hash.py>
echo(colorhash("L02"));

PythonSCAD aims to be 100% openscad compatible. so I has OpenSCAD
objects, but Python dicts are powerful anyway.
Look into hash.scad and see the ease how to export python functions ito
SCAD code.

Cheers

~
~

On Thu, Feb 12, 2026 at 1:54 AM Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:

OpenSCAD proper does not have a hashmap() function and does not have
anything called a "hashmap".  It does have objects, which are probably
similar:

Color_Table = object([ // the laser color parameters (name,power,feed,color)
["L00",[1.0,1.0,0x000000]],
["L01",[1.0,1.0,0x0000FF]],
["L02",[1.0,1.0,0xFF0000]],
["L29",[1.0,1.0,0xFFDB66]],
["T1",[0.0,0.0,0xF36926]],
["T2",[0.0,0.0,0x0C96D9]]
]);

I have no idea whether obejcts are integrated into PythonSCAD, or
whether PythonSCAD exports a hashmap() function into OpenSCAD.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

yes, of course, just launch PythonSCAD with --trust-python many folks actually install this option into the desktop symbol ... On Sat, Feb 14, 2026 at 6:37 AM John David <ebo.2112@gmail.com> wrote: > BTW, I am getting the error " > > Parsing design (AST generation)... > > ERROR: File not trusted > '/home/ebo/.local/share/OpenSCAD/libraries/tabbed-box/colormap.py' > > Any idea how to turn that off? > > On Sat, Feb 14, 2026 at 12:36 AM John David <ebo.2112@gmail.com> wrote: > >> Sorry I did not see this before I spent a lot of time messing from the >> OpenSCAD side today. I'll go back and give the python to openscad side a >> try. >> >> BTW, I got something similar to this working from pure OpenSCAD, but the >> colorhash is immutable and I was planning to allow the user to be able to >> set the power and feeds associated with the colormap. >> >> Anyway, I'll give the python-first a try later. >> >> EBo -- >> >> On Thu, Feb 12, 2026 at 2:07 AM Guenther Sohler via Discuss < >> discuss@lists.openscad.org> wrote: >> >>> In PythonSCAD you can leverage all features which comes with python, >>> So also hashes(python dicts) >>> This sample works: >>> >>> hash.py: >>> >>> def colorhash(key): >>> Color_Table ={ >>> "L00": [1.0,1.0,0x000000], >>> "L01":[1.0,1.0,0x0000FF], >>> "L02":[1.0,1.0,0xFF0000], >>> "L29":[1.0,1.0,0xFFDB66], >>> "T1":[0.0,0.0,0xF36926], >>> "T2":[0.0,0.0,0x0C96D9]} >>> return Color_Table[key] >>> >>> hash.scad: >>> >>> use <hash.py> >>> echo(colorhash("L02")); >>> >>> PythonSCAD aims to be 100% openscad compatible. so I has OpenSCAD >>> objects, but Python dicts are powerful anyway. >>> Look into hash.scad and see the ease how to export python functions ito >>> SCAD code. >>> >>> Cheers >>> >>> >>> ~ >>> ~ >>> >>> On Thu, Feb 12, 2026 at 1:54 AM Jordan Brown via Discuss < >>> discuss@lists.openscad.org> wrote: >>> >>>> OpenSCAD proper does not have a hashmap() function and does not have >>>> anything called a "hashmap". It does have objects, which are probably >>>> similar: >>>> >>>> Color_Table = object([ // the laser color parameters (name,power,feed,color) >>>> ["L00",[1.0,1.0,0x000000]], >>>> ["L01",[1.0,1.0,0x0000FF]], >>>> ["L02",[1.0,1.0,0xFF0000]], >>>> ["L29",[1.0,1.0,0xFFDB66]], >>>> ["T1",[0.0,0.0,0xF36926]], >>>> ["T2",[0.0,0.0,0x0C96D9]] >>>> ]); >>>> >>>> I have no idea whether obejcts are integrated into PythonSCAD, or >>>> whether PythonSCAD exports a hashmap() function into OpenSCAD. >>>> >>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >>
JD
John David
Sat, Feb 14, 2026 5:48 AM

Figured it out.  hash.py need "from openscad import *" to run.  Now it does.

On Sat, Feb 14, 2026 at 12:37 AM John David ebo.2112@gmail.com wrote:

BTW, I am getting the error "

Parsing design (AST generation)...

ERROR: File not trusted
'/home/ebo/.local/share/OpenSCAD/libraries/tabbed-box/colormap.py'

Any idea how to turn that off?

On Sat, Feb 14, 2026 at 12:36 AM John David ebo.2112@gmail.com wrote:

Sorry I did not see this before I spent a lot of time messing from the
OpenSCAD side today.  I'll go back and give the python to openscad side a
try.

BTW, I got something similar to this working from pure OpenSCAD, but the
colorhash is immutable and I was planning to allow the user to be able to
set the power and feeds associated with the colormap.

Anyway, I'll give the python-first a try later.

EBo --

On Thu, Feb 12, 2026 at 2:07 AM Guenther Sohler via Discuss <
discuss@lists.openscad.org> wrote:

In PythonSCAD you can leverage all features which comes with python,
So also hashes(python dicts)
This sample works:

hash.py:

def colorhash(key):
Color_Table ={
"L00": [1.0,1.0,0x000000],
"L01":[1.0,1.0,0x0000FF],
"L02":[1.0,1.0,0xFF0000],
"L29":[1.0,1.0,0xFFDB66],
"T1":[0.0,0.0,0xF36926],
"T2":[0.0,0.0,0x0C96D9]}
return Color_Table[key]

hash.scad:

use <hash.py>
echo(colorhash("L02"));

PythonSCAD aims to be 100% openscad compatible. so I has OpenSCAD
objects, but Python dicts are powerful anyway.
Look into hash.scad and see the ease how to export python functions ito
SCAD code.

Cheers

~
~

On Thu, Feb 12, 2026 at 1:54 AM Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:

OpenSCAD proper does not have a hashmap() function and does not have
anything called a "hashmap".  It does have objects, which are probably
similar:

Color_Table = object([ // the laser color parameters (name,power,feed,color)
["L00",[1.0,1.0,0x000000]],
["L01",[1.0,1.0,0x0000FF]],
["L02",[1.0,1.0,0xFF0000]],
["L29",[1.0,1.0,0xFFDB66]],
["T1",[0.0,0.0,0xF36926]],
["T2",[0.0,0.0,0x0C96D9]]
]);

I have no idea whether obejcts are integrated into PythonSCAD, or
whether PythonSCAD exports a hashmap() function into OpenSCAD.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Figured it out. hash.py need "from openscad import *" to run. Now it does. On Sat, Feb 14, 2026 at 12:37 AM John David <ebo.2112@gmail.com> wrote: > BTW, I am getting the error " > > Parsing design (AST generation)... > > ERROR: File not trusted > '/home/ebo/.local/share/OpenSCAD/libraries/tabbed-box/colormap.py' > > Any idea how to turn that off? > > On Sat, Feb 14, 2026 at 12:36 AM John David <ebo.2112@gmail.com> wrote: > >> Sorry I did not see this before I spent a lot of time messing from the >> OpenSCAD side today. I'll go back and give the python to openscad side a >> try. >> >> BTW, I got something similar to this working from pure OpenSCAD, but the >> colorhash is immutable and I was planning to allow the user to be able to >> set the power and feeds associated with the colormap. >> >> Anyway, I'll give the python-first a try later. >> >> EBo -- >> >> On Thu, Feb 12, 2026 at 2:07 AM Guenther Sohler via Discuss < >> discuss@lists.openscad.org> wrote: >> >>> In PythonSCAD you can leverage all features which comes with python, >>> So also hashes(python dicts) >>> This sample works: >>> >>> hash.py: >>> >>> def colorhash(key): >>> Color_Table ={ >>> "L00": [1.0,1.0,0x000000], >>> "L01":[1.0,1.0,0x0000FF], >>> "L02":[1.0,1.0,0xFF0000], >>> "L29":[1.0,1.0,0xFFDB66], >>> "T1":[0.0,0.0,0xF36926], >>> "T2":[0.0,0.0,0x0C96D9]} >>> return Color_Table[key] >>> >>> hash.scad: >>> >>> use <hash.py> >>> echo(colorhash("L02")); >>> >>> PythonSCAD aims to be 100% openscad compatible. so I has OpenSCAD >>> objects, but Python dicts are powerful anyway. >>> Look into hash.scad and see the ease how to export python functions ito >>> SCAD code. >>> >>> Cheers >>> >>> >>> ~ >>> ~ >>> >>> On Thu, Feb 12, 2026 at 1:54 AM Jordan Brown via Discuss < >>> discuss@lists.openscad.org> wrote: >>> >>>> OpenSCAD proper does not have a hashmap() function and does not have >>>> anything called a "hashmap". It does have objects, which are probably >>>> similar: >>>> >>>> Color_Table = object([ // the laser color parameters (name,power,feed,color) >>>> ["L00",[1.0,1.0,0x000000]], >>>> ["L01",[1.0,1.0,0x0000FF]], >>>> ["L02",[1.0,1.0,0xFF0000]], >>>> ["L29",[1.0,1.0,0xFFDB66]], >>>> ["T1",[0.0,0.0,0xF36926]], >>>> ["T2",[0.0,0.0,0x0C96D9]] >>>> ]); >>>> >>>> I have no idea whether obejcts are integrated into PythonSCAD, or >>>> whether PythonSCAD exports a hashmap() function into OpenSCAD. >>>> >>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >>