Skip to content

Wrong quantities on BoM #162

@rockstorm101

Description

@rockstorm101

I'm finding this difficulty when using the BoM feature. To make the assembly easier and avoid writing the same code several times I was defining some sub-assemblies within a variable and then adding several of those sub-assemblies onto a base part. Proceeding this way generated the right SCAD code but the wrong BoM. Would it be possible (though I don't see how to be honest with you, so this is maybe more of a rant than an issue itself) to implement a fix for this? The following example illustrates (I hope) the problem. If I were to modify the example file like this:

diff --git a/solid/examples/bom_scad.py b/solid/examples/bom_scad.py
index a059a66..84047fb 100755
--- a/solid/examples/bom_scad.py
+++ b/solid/examples/bom_scad.py
@@ -93,15 +93,17 @@ def doohickey(c):
 
 
 def assembly():
+    short_screw = m3_12()
+    nut = m3_nut()
     return union()(
             doohickey(c='blue'),
-            translate((-10, 0, doohickey_h / 2))(m3_12()),
+            translate((-10, 0, doohickey_h / 2))(short_screw),
             translate((0, 0, doohickey_h / 2))(m3_16()),
-            translate((10, 0, doohickey_h / 2))(m3_12()),
+            translate((10, 0, doohickey_h / 2))(short_screw),
             # Nuts
-            translate((-10, 0, -nut_height - doohickey_h / 2))(m3_nut()),
-            translate((0, 0, -nut_height - doohickey_h / 2))(m3_nut()),
-            translate((10, 0, -nut_height - doohickey_h / 2))(m3_nut()),
+            translate((-10, 0, -nut_height - doohickey_h / 2))(nut),
+            translate((0, 0, -nut_height - doohickey_h / 2))(nut),
+            translate((10, 0, -nut_height - doohickey_h / 2))(nut),
     )
 
 

The example now produces, as expected I guess, the right SCAD assembly with all the parts on it but the wrong quantities on the BoM:

[...]
Or, Spreadsheet-ready TSV:

Description	Count	Unit Price	Total Price	link	leftover
M3x16 Bolt	1	   € 0.12	   € 0.12	http://example.io/M3x160
M3x12 Bolt	1	 US$ 0.09	 US$ 0.09		0
M3 Nut	1	  R$ 0.04	  R$ 0.04		
doohickey	1				
					
Total Cost,    €			   € 0.12		
Total Cost,  US$			 US$ 0.09		
Total Cost,   R$			  R$ 0.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions