@@ -100,8 +100,8 @@ def empty_top_assy():
100
100
101
101
b1 = cq .Workplane ().box (1 , 1 , 1 )
102
102
103
- assy = cq .Assembly ()
104
- assy .add (b1 , color = cq .Color ("green" ))
103
+ assy = cq .Assembly (name = "top" )
104
+ assy .add (b1 , color = cq .Color ("green" ), name = "b" )
105
105
106
106
return assy
107
107
@@ -441,10 +441,15 @@ def get_doc_nodes(doc, leaf=False):
441
441
ctool = expl .ColorTool ()
442
442
style = node .Style
443
443
label = node .RefLabel
444
+ label2 = node .Label
444
445
445
446
name_att = TDataStd_Name ()
446
447
label .FindAttribute (TDataStd_Name .GetID_s (), name_att )
447
448
449
+ if label2 .IsAttribute (TDataStd_Name .GetID_s ()):
450
+ name_att = TDataStd_Name ()
451
+ label2 .FindAttribute (TDataStd_Name .GetID_s (), name_att )
452
+
448
453
color = style .GetColorSurfRGBA ()
449
454
shape = expl .FindShapeFromPathId_s (doc , node .Id )
450
455
color_shape = Quantity_ColorRGBA ()
@@ -1082,9 +1087,12 @@ def make_model(name: str, COPY: bool):
1082
1087
assy = Assembly (name = "test_assy" )
1083
1088
assy .add (box (1 , 2 , 5 ), color = Color ("green" ))
1084
1089
1085
- for v in rect (10 , 10 ).vertices ():
1090
+ for i , v in enumerate ( rect (10 , 10 ).vertices () ):
1086
1091
assy .add (
1087
- b .copy () if COPY else b , loc = Location (v .Center ()), color = Color ("red" )
1092
+ b .copy () if COPY else b ,
1093
+ name = f"element_{ i } " ,
1094
+ loc = Location (v .Center ()),
1095
+ color = Color ("red" ),
1088
1096
)
1089
1097
1090
1098
assy .export (name )
@@ -1417,27 +1425,11 @@ def test_leaf_node_count(assy_fixture, count, request):
1417
1425
[
1418
1426
(
1419
1427
["chassis" , "wheel-axle.*" , "wheel:.*" ],
1420
- {
1421
- "color" : (1.0 , 0.0 , 0.0 , 1.0 ),
1422
- "color_shape" : (1.0 , 0.0 , 0.0 , 1.0 ),
1423
- "num_nodes" : 4 ,
1424
- },
1425
- ),
1426
- (
1427
- ["chassis" , "wheel-axle.*" , "wheel:.*" , "wheel.*_part" ],
1428
- {"color" : (1.0 , 0.0 , 0.0 , 1.0 ), "num_nodes" : 4 },
1428
+ {"color" : (1.0 , 0.0 , 0.0 , 1.0 ), "num_nodes" : 4 ,},
1429
1429
),
1430
1430
(
1431
1431
["chassis" , "wheel-axle.*" , "axle" ],
1432
- {
1433
- "color" : (0.0 , 1.0 , 0.0 , 1.0 ),
1434
- "color_shape" : (0.0 , 1.0 , 0.0 , 1.0 ),
1435
- "num_nodes" : 2 ,
1436
- },
1437
- ),
1438
- (
1439
- ["chassis" , "wheel-axle.*" , "axle" , "axle_part" ],
1440
- {"color" : (0.0 , 1.0 , 0.0 , 1.0 ), "num_nodes" : 2 },
1432
+ {"color" : (0.0 , 1.0 , 0.0 , 1.0 ), "num_nodes" : 2 ,},
1441
1433
),
1442
1434
],
1443
1435
),
@@ -1478,103 +1470,100 @@ def check_nodes(doc, expected):
1478
1470
{"color_shape" : (0.0 , 1.0 , 0.0 , 1.0 )},
1479
1471
),
1480
1472
(
1481
- ["TOP" , "SECOND" , "BOTTOM" , "BOTTOM_part" ],
1473
+ ["TOP" , "SECOND" , "BOTTOM" ],
1482
1474
{
1483
1475
"color_shape" : (0.0 , 1.0 , 0.0 , 1.0 ),
1484
1476
"color_subshapes" : (0.0 , 1.0 , 0.0 , 1.0 ),
1485
1477
},
1486
1478
),
1487
1479
],
1488
1480
),
1489
- ("empty_top_assy" , [([".*_part " ], {"color_shape" : (0.0 , 1.0 , 0.0 , 1.0 )}),]),
1481
+ ("empty_top_assy" , [(["top" , "b " ], {"color_shape" : (0.0 , 1.0 , 0.0 , 1.0 )}),]),
1490
1482
(
1491
1483
"boxes0_assy" ,
1492
1484
[
1493
- (["box0" , "box0_part" ], {"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )}),
1494
- (["box1" , "box0_part" ], {"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )}),
1485
+ (["box0" ], {"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )}),
1486
+ (["box1" ], {"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )}),
1495
1487
],
1496
1488
),
1497
1489
(
1498
1490
"boxes1_assy" ,
1499
1491
[
1500
- (["box0" , "box0_part" ], {"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )}),
1501
- (["box1" , "box0_part" ], {"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )}),
1492
+ (["box0" ], {"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )}),
1493
+ (["box1" ], {"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )}),
1502
1494
],
1503
1495
),
1504
1496
(
1505
1497
"boxes2_assy" ,
1506
1498
[
1507
- (["box0" , "box0_part" ], {"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )}),
1508
- (["box1" , "box1_part" ], {"color_shape" : (0.0 , 1.0 , 0.0 , 1.0 )}),
1499
+ (["box0" ], {"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )}),
1500
+ (["box1" ], {"color_shape" : (0.0 , 1.0 , 0.0 , 1.0 )}),
1509
1501
],
1510
1502
),
1511
1503
(
1512
1504
"boxes3_assy" ,
1513
1505
[
1514
- (["box0" , "box0_part" ], {"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )}),
1506
+ (["box0" ], {"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )}),
1515
1507
(
1516
- ["box1" , "box1_part" ],
1508
+ ["box1" ],
1517
1509
{"color_shape" : cq .Color ().toTuple ()},
1518
1510
), # default color when unspecified
1519
1511
],
1520
1512
),
1521
1513
(
1522
1514
"boxes4_assy" ,
1523
1515
[
1524
- (["box_0" , "box_0_part" ], {"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )}),
1525
- (["box_1" , "box_1_part" ], {"color_shape" : (0.0 , 1.0 , 0.0 , 1.0 )}),
1516
+ (["box_0" ], {"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )}),
1517
+ (["box_1" ], {"color_shape" : (0.0 , 1.0 , 0.0 , 1.0 )}),
1526
1518
],
1527
1519
),
1528
1520
(
1529
1521
"boxes5_assy" ,
1530
1522
[
1531
- (["box:a" , "box:a_part" ], {"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )}),
1532
- (["box:b" , "box:b_part" ], {"color_shape" : (0.0 , 1.0 , 0.0 , 1.0 )}),
1523
+ (["box:a" ], {"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )}),
1524
+ (["box:b" ], {"color_shape" : (0.0 , 1.0 , 0.0 , 1.0 )}),
1533
1525
],
1534
1526
),
1535
1527
(
1536
1528
"boxes6_assy" ,
1537
1529
[
1538
- (["box__0" , "box__0_part" ], {"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )}),
1539
- (["box__1" , "box__1_part" ], {"color_shape" : (0.0 , 1.0 , 0.0 , 1.0 )}),
1530
+ (["box__0" ], {"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )}),
1531
+ (["box__1" ], {"color_shape" : (0.0 , 1.0 , 0.0 , 1.0 )}),
1540
1532
],
1541
1533
),
1542
1534
(
1543
1535
"boxes7_assy" ,
1544
1536
[
1545
- (["box_0" , "box_0_part" ], {"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )}),
1546
- (["box" , "box_part" ], {"color_shape" : (0.0 , 1.0 , 0.0 , 1.0 )}),
1547
- (
1548
- ["another box" , "another box_part" ],
1549
- {"color_shape" : (0.23 , 0.26 , 0.26 , 0.6 )},
1550
- ),
1537
+ (["box_0" ], {"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )}),
1538
+ (["box" ], {"color_shape" : (0.0 , 1.0 , 0.0 , 1.0 )}),
1539
+ (["another box" ], {"color_shape" : (0.23 , 0.26 , 0.26 , 0.6 )},),
1551
1540
],
1552
1541
),
1553
1542
(
1554
1543
"chassis0_assy" ,
1555
1544
[
1556
1545
(
1557
- ["chassis" , "wheel-axle-front" , "wheel:left" , "wheel:left_part" ],
1546
+ ["chassis" , "wheel-axle-front" , "wheel:left" ],
1558
1547
{"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )},
1559
1548
),
1560
1549
(
1561
- ["chassis" , "wheel-axle-front" , "wheel:right" , "wheel:left_part" ],
1550
+ ["chassis" , "wheel-axle-front" , "wheel:right" ],
1562
1551
{"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )},
1563
1552
),
1564
1553
(
1565
- ["chassis" , "wheel-axle-rear" , "wheel:left" , "wheel:left_part" ],
1554
+ ["chassis" , "wheel-axle-rear" , "wheel:left" ],
1566
1555
{"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )},
1567
1556
),
1568
1557
(
1569
- ["chassis" , "wheel-axle-rear" , "wheel:right" , "wheel:left_part" ],
1558
+ ["chassis" , "wheel-axle-rear" , "wheel:right" ],
1570
1559
{"color_shape" : (1.0 , 0.0 , 0.0 , 1.0 )},
1571
1560
),
1572
1561
(
1573
- ["chassis" , "wheel-axle-front" , "axle" , "axle_part" ],
1562
+ ["chassis" , "wheel-axle-front" , "axle" ],
1574
1563
{"color_shape" : (0.0 , 1.0 , 0.0 , 1.0 )},
1575
1564
),
1576
1565
(
1577
- ["chassis" , "wheel-axle-rear" , "axle" , "axle_part" ],
1566
+ ["chassis" , "wheel-axle-rear" , "axle" ],
1578
1567
{"color_shape" : (0.0 , 1.0 , 0.0 , 1.0 )},
1579
1568
),
1580
1569
],
0 commit comments