16
16
)
17
17
from cadquery .occ_impl .assembly import toJSON , toCAF , toFusedCAF
18
18
from cadquery .occ_impl .shapes import Face , box
19
- from cadquery .occ_impl .geom import Location
20
19
21
20
from OCP .gp import gp_XYZ
22
21
from OCP .TDocStd import TDocStd_Document
@@ -399,7 +398,6 @@ def get_doc_nodes(doc, leaf=False):
399
398
400
399
name_att = TDataStd_Name ()
401
400
label .FindAttribute (TDataStd_Name .GetID_s (), name_att )
402
- name = TCollection_ExtendedString (name_att .Get ()).ToExtString ()
403
401
404
402
color = style .GetColorSurfRGBA ()
405
403
shape = expl .FindShapeFromPathId_s (doc , node .Id )
@@ -412,7 +410,6 @@ def get_doc_nodes(doc, leaf=False):
412
410
faces = []
413
411
if not node .IsAssembly :
414
412
it = TDF_ChildIterator (label )
415
- i = 0
416
413
while it .More ():
417
414
child = it .Value ()
418
415
child_shape = tool .GetShape_s (child )
@@ -916,7 +913,7 @@ def check_nodes(doc, expected):
916
913
"boxes0_assy" ,
917
914
[
918
915
(["box0" , "box0_part" ], {"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )}),
919
- (["box1" , "box1_part " ], {"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )}),
916
+ (["box1" , "box0_part " ], {"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )}),
920
917
],
921
918
),
922
919
(
@@ -983,15 +980,15 @@ def check_nodes(doc, expected):
983
980
{"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )},
984
981
),
985
982
(
986
- ["chassis" , "wheel-axle-front" , "wheel:right" , "wheel:right_part " ],
983
+ ["chassis" , "wheel-axle-front" , "wheel:right" , "wheel:left_part " ],
987
984
{"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )},
988
985
),
989
986
(
990
987
["chassis" , "wheel-axle-rear" , "wheel:left" , "wheel:left_part" ],
991
988
{"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )},
992
989
),
993
990
(
994
- ["chassis" , "wheel-axle-rear" , "wheel:right" , "wheel:right_part " ],
991
+ ["chassis" , "wheel-axle-rear" , "wheel:right" , "wheel:left_part " ],
995
992
{"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )},
996
993
),
997
994
(
@@ -1685,3 +1682,25 @@ def test_order_of_transform():
1685
1682
m1 , m2 = assy2 .toCompound ().Solids ()
1686
1683
1687
1684
assert (m1 .Center () - m2 .Center ()).Length == approx (0 )
1685
+
1686
+
1687
+ def test_step_export_filesize (tmpdir ):
1688
+ """A sanity check of STEP file size.
1689
+ Multiple instances of a shape with same color is not expected to result
1690
+ in significant file size increase.
1691
+ """
1692
+ part = box (1 , 1 , 1 )
1693
+ N = 10
1694
+ filesize = {}
1695
+
1696
+ for i , color in enumerate ((None , cq .Color ("red" ))):
1697
+ assy = cq .Assembly ()
1698
+ for j in range (1 , N + 1 ):
1699
+ assy .add (
1700
+ part , name = f"part{ j } " , loc = cq .Location (x = j * 1 ), color = copy .copy (color )
1701
+ )
1702
+ stepfile = Path (tmpdir , f"assy_step_filesize{ i } .step" )
1703
+ assy .export (str (stepfile ))
1704
+ filesize [i ] = stepfile .stat ().st_size
1705
+
1706
+ assert filesize [1 ] < 1.2 * filesize [0 ]
0 commit comments