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

Problems using custom solder mask colors #36

Closed
set-soft opened this issue Oct 11, 2023 · 7 comments
Closed

Problems using custom solder mask colors #36

set-soft opened this issue Oct 11, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@set-soft
Copy link

I'm having problems testing the case where a color is defined using its hexadecimal representatio, the following code:

soldermask_inputs = {"Light Color": [*color, 1.0], "Dark Color": [*(color * 0.2), 1.0]}

Produces TypeError: can't multiply sequence by non-int of type 'float'

Which is consistent with what I get in the interpreter:

>>> color = (1,2,3)
>>> (color * 0.2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can't multiply sequence by non-int of type 'float'

Perhaps you can use something like:

>>> list(map(lambda x: x*0.2, color))
[0.2, 0.4, 0.6000000000000001]
@30350n
Copy link
Owner

30350n commented Oct 11, 2023

Even better, I can just use Blenders builtin Color type. Thanks for the catch, should be fixed now!

@set-soft
Copy link
Author

Even better, I can just use Blenders builtin Color type. Thanks for the catch, should be fixed now!

Yes, this seems to be ok. But isn't enough to solve the problems. After applying it I'm getting:

RuntimeError: Error: Python: Traceback (most recent call last):
  File "/usr/bin/3.5/scripts/addons/pcb2blender_importer/importer.py", line 205, in execute
    if (pcb := self.import_pcb3d(context, filepath)) == {"CANCELLED"}:
  File "/usr/bin/3.5/scripts/addons/pcb2blender_importer/importer.py", line 375, in import_pcb3d
    setup_pcb_material(board_material.node_tree, images, pcb.stackup)
  File "/usr/bin/3.5/scripts/addons/pcb2blender_importer/materials.py", line 144, in setup_pcb_material
    setup_node_tree(node_tree, nodes, label_nodes=False)
  File "/usr/bin/3.5/scripts/addons/pcb2blender_importer/custom_node_utils/__init__.py", line 19, in setup_node_tree
    setattr(node, attr, value)
TypeError: bpy_struct: item.attr = val: enum "CUSTOM" not found in ('GREEN', 'RED', 'YELLOW', 'BLUE', 'PURPLE', 'WHITE', 'BLACK', 'MATTE_BLACK')
Location: /usr/bin/3.5/scripts/modules/bpy/ops.py:113

@30350n
Copy link
Owner

30350n commented Oct 12, 2023

Ah yeah okay, I see I messed up there, should also be fixed now 🤞

@30350n 30350n added the bug Something isn't working label Oct 12, 2023
@set-soft
Copy link
Author

Hi @30350n !

Close, I had to also change:

--- materials.py	2023-10-18 13:01:04.874202150 -0300
+++ /tmp/materials.py	2023-10-18 13:39:41.123547271 -0300
@@ -239,7 +239,6 @@
     bl_width_default = 180
 
     def update_props(self, context):
-        light_color, dark_color = MASK_COLOR_MAP[self.soldermask]
         match self.soldermask:
             case "WHITE":
                 roughness = 0.15
@@ -249,6 +248,7 @@
                 roughness = 0.25
 
         if self.soldermask != "CUSTOM":
+            light_color, dark_color = MASK_COLOR_MAP[self.soldermask]
             self.inputs["Light Color"].default_value = (*srgb2lin(light_color), 1.0)
             self.inputs["Dark Color"].default_value  = (*srgb2lin(dark_color),  1.0)
             self.inputs["Roughness"].default_value = roughness

set-soft added a commit to INTI-CMNB/kicad_auto_test that referenced this issue Oct 18, 2023
To fix the custom colors support

See 30350n/pcb2blender#36
@30350n
Copy link
Owner

30350n commented Oct 18, 2023

Should now actually be fixed. Didn't really have time to properly test this yet until now, sorry. I've added a test file now and everything passes, so this should be fine now.

@set-soft
Copy link
Author

Perfect, I tried the last code and it works. I defined some "pink" color for the @mundodisco8 snow flake board (the one that triggered upgrading to 2.7 to get correct solder mask color) and got:

Snowflake-3D_blender_top

@mundodisco8
Copy link

mundodisco8 commented Oct 20, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants