topologicpy 0.7.93__py3-none-any.whl → 0.7.96__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
topologicpy/Wire.py CHANGED
@@ -982,9 +982,9 @@ class Wire():
982
982
  sides = int(math.floor(sides))
983
983
  for i in range(sides+1):
984
984
  angle = fromAngle + math.radians(angleRange/sides)*i
985
- x = math.sin(angle)*radius + origin.X()
986
- y = math.cos(angle)*radius + origin.Y()
987
- z = origin.Z()
985
+ x = math.sin(angle)*radius + Vertex.X(origin)
986
+ y = math.cos(angle)*radius + Vertex.Y(origin)
987
+ z = Vertex.Z(origin)
988
988
  xList.append(x)
989
989
  yList.append(y)
990
990
  baseV.append(Vertex.ByCoordinates(x, y, z))
@@ -1421,6 +1421,157 @@ class Wire():
1421
1421
  ch = Topology.Unflatten(ch, origin=origin, direction=normal)
1422
1422
  return ch
1423
1423
 
1424
+
1425
+ @staticmethod
1426
+ def CShape(origin=None,
1427
+ width=1,
1428
+ length=1,
1429
+ a=0.25,
1430
+ b=0.25,
1431
+ c =0.25,
1432
+ flipHorizontal = False,
1433
+ flipVertical = False,
1434
+ direction=[0,0,1],
1435
+ placement="center",
1436
+ tolerance=0.0001,
1437
+ silent=False):
1438
+ """
1439
+ Creates a C-shape.
1440
+
1441
+ Parameters
1442
+ ----------
1443
+ origin : topologic_core.Vertex , optional
1444
+ The location of the origin of the C-shape. The default is None which results in the C-shape being placed at (0, 0, 0).
1445
+ width : float , optional
1446
+ The overall width of the C-shape. The default is 1.0.
1447
+ length : float , optional
1448
+ The overall length of the C-shape. The default is 1.0.
1449
+ a : float , optional
1450
+ The hortizontal thickness of the vertical arm of the C-shape. The default is 0.25.
1451
+ b : float , optional
1452
+ The vertical thickness of the lower horizontal arm of the C-shape. The default is 0.25.
1453
+ c : float , optional
1454
+ The vertical thickness of the upper horizontal arm of the C-shape. The default is 0.25.
1455
+ direction : list , optional
1456
+ The vector representing the up direction of the C-shape. The default is [0, 0, 1].
1457
+ placement : str , optional
1458
+ The description of the placement of the origin of the C-shape. This can be "center", "lowerleft", "upperleft", "lowerright", "upperright". It is case insensitive. The default is "center".
1459
+ tolerance : float , optional
1460
+ The desired tolerance. The default is 0.0001.
1461
+ silent : bool , optional
1462
+ If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
1463
+
1464
+ Returns
1465
+ -------
1466
+ topologic_core.Wire
1467
+ The created C-shape.
1468
+
1469
+ """
1470
+ from topologicpy.Vertex import Vertex
1471
+ from topologicpy.Wire import Wire
1472
+ from topologicpy.Topology import Topology
1473
+
1474
+ if not isinstance(width, int) and not isinstance(width, float):
1475
+ if not silent:
1476
+ print("Wire.CShape - Error: The width input parameter is not a valid number. Returning None.")
1477
+ return None
1478
+ if not isinstance(length, int) and not isinstance(length, float):
1479
+ if not silent:
1480
+ print("Wire.CShape - Error: The length input parameter is not a valid number. Returning None.")
1481
+ return None
1482
+ if not isinstance(a, int) and not isinstance(a, float):
1483
+ if not silent:
1484
+ print("Wire.CShape - Error: The a input parameter is not a valid number. Returning None.")
1485
+ return None
1486
+ if not isinstance(b, int) and not isinstance(b, float):
1487
+ if not silent:
1488
+ print("Wire.CShape - Error: The b input parameter is not a valid number. Returning None.")
1489
+ return None
1490
+ if width <= tolerance:
1491
+ if not silent:
1492
+ print("Wire.CShape - Error: The width input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
1493
+ return None
1494
+ if length <= tolerance:
1495
+ if not silent:
1496
+ print("Wire.CShape - Error: The length input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
1497
+ return None
1498
+ if a <= tolerance:
1499
+ if not silent:
1500
+ print("Wire.CShape - Error: The a input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
1501
+ return None
1502
+ if b <= tolerance:
1503
+ if not silent:
1504
+ print("Wire.CShape - Error: The b input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
1505
+ return None
1506
+ if c <= tolerance:
1507
+ if not silent:
1508
+ print("Wire.CShape - Error: The c input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
1509
+ return None
1510
+ if a >= (width - tolerance):
1511
+ if not silent:
1512
+ print("Wire.CShape - Error: The a input parameter must be less than the width input parameter. Returning None.")
1513
+ return None
1514
+ if b+c >= (length - tolerance):
1515
+ if not silent:
1516
+ print("Wire.CShape - Error: The b and c input parameters must add to less than the length input parameter. Returning None.")
1517
+ return None
1518
+ if origin == None:
1519
+ origin = Vertex.Origin()
1520
+ if not Topology.IsInstance(origin, "vertex"):
1521
+ if not silent:
1522
+ print("Wire.CShape - Error: The origin input parameter is not a valid topologic vertex. Returning None.")
1523
+ return None
1524
+ if not isinstance(direction, list):
1525
+ if not silent:
1526
+ print("Wire.CShape - Error: The direction input parameter is not a valid list. Returning None.")
1527
+ return None
1528
+ if not len(direction) == 3:
1529
+ if not silent:
1530
+ print("Wire.CShape - Error: The direction input parameter is not a valid vector. Returning None.")
1531
+ return None
1532
+
1533
+ # Define the vertices of the C-shape (counterclockwise)
1534
+ v1 = Vertex.Origin() # Base origin
1535
+ v2 = Vertex.ByCoordinates(width, 0)
1536
+ v3 = Vertex.ByCoordinates(width, b)
1537
+ v4 = Vertex.ByCoordinates(a, b)
1538
+ v5 = Vertex.ByCoordinates(a, length-c)
1539
+ v6 = Vertex.ByCoordinates(width, length-c)
1540
+ v7 = Vertex.ByCoordinates(width, length)
1541
+ v8 = Vertex.ByCoordinates(0, length)
1542
+
1543
+ # Create the C-shaped wire
1544
+ c_shape = Wire.ByVertices([v1, v2, v3, v4, v5, v6, v7, v8], close=True)
1545
+ c_shape = Topology.Translate(c_shape, -width/2, -length/2, 0)
1546
+ c_shape = Topology.Translate(c_shape, Vertex.X(origin), Vertex.Y(origin), Vertex.Z(origin))
1547
+ reverse = False
1548
+ if flipHorizontal == True:
1549
+ xScale = -1
1550
+ reverse = not reverse
1551
+ else:
1552
+ xScale = 1
1553
+ if flipVertical == True:
1554
+ yScale = -1
1555
+ reverse = not reverse
1556
+ else:
1557
+ yScale = 1
1558
+ if xScale == -1 or yScale == -1:
1559
+ c_shape = Topology.Scale(c_shape, x=xScale, y=yScale, z=1)
1560
+ if reverse == True:
1561
+ c_shape = Wire.Reverse(c_shape)
1562
+ if placement.lower() == "lowerleft":
1563
+ c_shape = Topology.Translate(c_shape, width/2, length/2, 0)
1564
+ elif placement.lower() == "upperright":
1565
+ c_shape = Topology.Translate(c_shape, -width/2, -length/2, 0)
1566
+ elif placement.lower() == "upperleft":
1567
+ c_shape = Topology.Translate(c_shape, width/2, -length/2, 0)
1568
+ elif placement.lower() == "lowerright":
1569
+ c_shape = Topology.Translate(c_shape, -width/2, length/2, 0)
1570
+
1571
+ if direction != [0, 0, 1]:
1572
+ c_shape = Topology.Orient(c_shape, origin=origin, dirA=[0, 0, 1], dirB=direction)
1573
+ return c_shape
1574
+
1424
1575
  @staticmethod
1425
1576
  def Cycles(wire, maxVertices: int = 4, tolerance: float = 0.0001) -> list:
1426
1577
  """
@@ -1512,7 +1663,7 @@ class Wire():
1512
1663
 
1513
1664
  graph = []
1514
1665
  for anEdge in tEdges:
1515
- graph.append([vIndex(anEdge.StartVertex(), tVertices, tolerance), vIndex(anEdge.EndVertex(), tVertices, tolerance)]) # Hook to Core
1666
+ graph.append([vIndex(Edge.StartVertex(anEdge), tVertices, tolerance), vIndex(Edge.EndVertex(anEdge), tVertices, tolerance)]) # Hook to Core
1516
1667
 
1517
1668
  cycles = []
1518
1669
  resultingCycles = main(graph, cycles, maxVertices)
@@ -1801,9 +1952,9 @@ class Wire():
1801
1952
  sides = int(math.floor(sides))
1802
1953
  for i in range(sides+1):
1803
1954
  angle = fromAngle + math.radians(angleRange/sides)*i
1804
- x = math.sin(angle)*a + origin.X()
1805
- y = math.cos(angle)*b + origin.Y()
1806
- z = origin.Z()
1955
+ x = math.sin(angle)*a + Vertex.X(origin)
1956
+ y = math.cos(angle)*b + Vertex.Y(origin)
1957
+ z = Vertex.Z(origin)
1807
1958
  xList.append(x)
1808
1959
  yList.append(y)
1809
1960
  baseV.append(Vertex.ByCoordinates(x, y, z))
@@ -1817,8 +1968,8 @@ class Wire():
1817
1968
  baseWire = Topology.Translate(baseWire, a, b, 0)
1818
1969
  baseWire = Topology.Orient(baseWire, origin=origin, dirA=[0, 0, 1], dirB=direction)
1819
1970
  # Create a Cluster of the two foci
1820
- v1 = Vertex.ByCoordinates(c+origin.X(), 0+origin.Y(), 0)
1821
- v2 = Vertex.ByCoordinates(-c+origin.X(), 0+origin.Y(), 0)
1971
+ v1 = Vertex.ByCoordinates(c+Vertex.X(origin), 0+Vertex.Y(origin), 0)
1972
+ v2 = Vertex.ByCoordinates(-c+Vertex.X(origin), 0+Vertex.Y(origin), 0)
1822
1973
  foci = Cluster.ByTopologies([v1, v2])
1823
1974
  if placement.lower() == "lowerleft":
1824
1975
  foci = Topology.Translate(foci, a, b, 0)
@@ -2332,18 +2483,18 @@ class Wire():
2332
2483
  return False
2333
2484
 
2334
2485
  def angleBetweenEdges(e1, e2, tolerance=0.0001):
2335
- a = e1.EndVertex().X() - e1.StartVertex().X()
2336
- b = e1.EndVertex().Y() - e1.StartVertex().Y()
2337
- c = e1.EndVertex().Z() - e1.StartVertex().Z()
2338
- d = Vertex.Distance(e1.EndVertex(), e2.StartVertex())
2486
+ a = Vertex.X(Edge.EndVertex(e1)) - Vertex.X(Edge.StartVertex(e1))
2487
+ b = Vertex.Y(Edge.EndVertex(e1)) - Vertex.Y(Edge.StartVertex(e1))
2488
+ c = Vertex.Z(Edge.EndVertex(e1)) - Vertex.Z(Edge.StartVertex(e1))
2489
+ d = Vertex.Distance(Edge.EndVertex(e1), Edge.StartVertex(e2))
2339
2490
  if d <= tolerance:
2340
- d = e2.StartVertex().X() - e2.EndVertex().X()
2341
- e = e2.StartVertex().Y() - e2.EndVertex().Y()
2342
- f = e2.StartVertex().Z() - e2.EndVertex().Z()
2491
+ d = Vertex.X(Edge.StartVertex(e2)) - Vertex.X(Edge.EndVertex(e2))
2492
+ e = Vertex.Y(Edge.StartVertex(e2)) - Vertex.Y(Edge.EndVertex(e2))
2493
+ f = Vertex.Z(Edge.StartVertex(e2)) - Vertex.Z(Edge.EndVertex(e2))
2343
2494
  else:
2344
- d = e2.EndVertex().X() - e2.StartVertex().X()
2345
- e = e2.EndVertex().Y() - e2.StartVertex().Y()
2346
- f = e2.EndVertex().Z() - e2.StartVertex().Z()
2495
+ d = Vertex.X(Edge.EndVertex(e2)) - Vertex.X(Edge.StartVertex(e2))
2496
+ e = Vertex.Y(Edge.EndVertex(e2)) - Vertex.Y(Edge.StartVertex(e2))
2497
+ f = Vertex.Z(Edge.EndVertex(e2)) - Vertex.Z(Edge.StartVertex(e2))
2347
2498
  dotProduct = a*d + b*e + c*f
2348
2499
  modOfVector1 = math.sqrt( a*a + b*b + c*c)*math.sqrt(d*d + e*e + f*f)
2349
2500
  angle = dotProduct/modOfVector1
@@ -2387,6 +2538,160 @@ class Wire():
2387
2538
  return True
2388
2539
  return False
2389
2540
 
2541
+ @staticmethod
2542
+ def IShape(origin=None,
2543
+ width=1,
2544
+ length=1,
2545
+ a=0.25,
2546
+ b=0.25,
2547
+ c =0.25,
2548
+ flipHorizontal = False,
2549
+ flipVertical = False,
2550
+ direction=[0,0,1],
2551
+ placement="center",
2552
+ tolerance=0.0001,
2553
+ silent=False):
2554
+ """
2555
+ Creates an I-shape.
2556
+
2557
+ Parameters
2558
+ ----------
2559
+ origin : topologic_core.Vertex , optional
2560
+ The location of the origin of the I-shape. The default is None which results in the I-shape being placed at (0, 0, 0).
2561
+ width : float , optional
2562
+ The overall width of the I-shape. The default is 1.0.
2563
+ length : float , optional
2564
+ The overall length of the I-shape. The default is 1.0.
2565
+ a : float , optional
2566
+ The hortizontal thickness of the central vertical arm of the I-shape. The default is 0.25.
2567
+ b : float , optional
2568
+ The vertical thickness of the lower horizontal arm of the I-shape. The default is 0.25.
2569
+ c : float , optional
2570
+ The vertical thickness of the upper horizontal arm of the I-shape. The default is 0.25.
2571
+ direction : list , optional
2572
+ The vector representing the up direction of the I-shape. The default is [0, 0, 1].
2573
+ placement : str , optional
2574
+ The description of the placement of the origin of the I-shape. This can be "center", "lowerleft", "upperleft", "lowerright", "upperright". It is case insensitive. The default is "center".
2575
+ tolerance : float , optional
2576
+ The desired tolerance. The default is 0.0001.
2577
+ silent : bool , optional
2578
+ If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
2579
+
2580
+ Returns
2581
+ -------
2582
+ topologic_core.Wire
2583
+ The created I-shape.
2584
+
2585
+ """
2586
+ from topologicpy.Vertex import Vertex
2587
+ from topologicpy.Wire import Wire
2588
+ from topologicpy.Topology import Topology
2589
+
2590
+ if not isinstance(width, int) and not isinstance(width, float):
2591
+ if not silent:
2592
+ print("Wire.IShape - Error: The width input parameter is not a valid number. Returning None.")
2593
+ return None
2594
+ if not isinstance(length, int) and not isinstance(length, float):
2595
+ if not silent:
2596
+ print("Wire.IShape - Error: The length input parameter is not a valid number. Returning None.")
2597
+ return None
2598
+ if not isinstance(a, int) and not isinstance(a, float):
2599
+ if not silent:
2600
+ print("Wire.IShape - Error: The a input parameter is not a valid number. Returning None.")
2601
+ return None
2602
+ if not isinstance(b, int) and not isinstance(b, float):
2603
+ if not silent:
2604
+ print("Wire.IShape - Error: The b input parameter is not a valid number. Returning None.")
2605
+ return None
2606
+ if width <= tolerance:
2607
+ if not silent:
2608
+ print("Wire.IShape - Error: The width input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
2609
+ return None
2610
+ if length <= tolerance:
2611
+ if not silent:
2612
+ print("Wire.IShape - Error: The length input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
2613
+ return None
2614
+ if a <= tolerance:
2615
+ if not silent:
2616
+ print("Wire.IShape - Error: The a input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
2617
+ return None
2618
+ if b <= tolerance:
2619
+ if not silent:
2620
+ print("Wire.IShape - Error: The b input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
2621
+ return None
2622
+ if c <= tolerance:
2623
+ if not silent:
2624
+ print("Wire.IShape - Error: The c input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
2625
+ return None
2626
+ if a >= (width - tolerance):
2627
+ if not silent:
2628
+ print("Wire.IShape - Error: The a input parameter must be less than the width input parameter. Returning None.")
2629
+ return None
2630
+ if b+c >= (length - tolerance):
2631
+ if not silent:
2632
+ print("Wire.IShape - Error: The b and c input parameters must add to less than the length input parameter. Returning None.")
2633
+ return None
2634
+ if origin == None:
2635
+ origin = Vertex.Origin()
2636
+ if not Topology.IsInstance(origin, "vertex"):
2637
+ if not silent:
2638
+ print("Wire.IShape - Error: The origin input parameter is not a valid topologic vertex. Returning None.")
2639
+ return None
2640
+ if not isinstance(direction, list):
2641
+ if not silent:
2642
+ print("Wire.IShape - Error: The direction input parameter is not a valid list. Returning None.")
2643
+ return None
2644
+ if not len(direction) == 3:
2645
+ if not silent:
2646
+ print("Wire.IShape - Error: The direction input parameter is not a valid vector. Returning None.")
2647
+ return None
2648
+
2649
+ # Define the vertices of the I-shape (counterclockwise)
2650
+ v1 = Vertex.Origin() # Base origin
2651
+ v2 = Vertex.ByCoordinates(width, 0)
2652
+ v3 = Vertex.ByCoordinates(width, b)
2653
+ v4 = Vertex.ByCoordinates(width/2+a/2, b)
2654
+ v5 = Vertex.ByCoordinates(width/2+a/2, length-c)
2655
+ v6 = Vertex.ByCoordinates(width, length-c)
2656
+ v7 = Vertex.ByCoordinates(width, length)
2657
+ v8 = Vertex.ByCoordinates(0, length)
2658
+ v9 = Vertex.ByCoordinates(0, length-c)
2659
+ v10 = Vertex.ByCoordinates(width/2-a/2, length-c)
2660
+ v11 = Vertex.ByCoordinates(width/2-a/2, b)
2661
+ v12 = Vertex.ByCoordinates(0,b)
2662
+
2663
+ # Create the I-shaped wire
2664
+ i_shape = Wire.ByVertices([v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12], close=True)
2665
+ i_shape = Topology.Translate(i_shape, -width/2, -length/2, 0)
2666
+ i_shape = Topology.Translate(i_shape, Vertex.X(origin), Vertex.Y(origin), Vertex.Z(origin))
2667
+ reverse = False
2668
+ if flipHorizontal == True:
2669
+ xScale = -1
2670
+ reverse = not reverse
2671
+ else:
2672
+ xScale = 1
2673
+ if flipVertical == True:
2674
+ yScale = -1
2675
+ reverse = not reverse
2676
+ else:
2677
+ yScale = 1
2678
+ if xScale == -1 or yScale == -1:
2679
+ i_shape = Topology.Scale(i_shape, x=xScale, y=yScale, z=1)
2680
+ if reverse == True:
2681
+ i_shape = Wire.Reverse(i_shape)
2682
+ if placement.lower() == "lowerleft":
2683
+ i_shape = Topology.Translate(i_shape, width/2, length/2, 0)
2684
+ elif placement.lower() == "upperright":
2685
+ i_shape = Topology.Translate(i_shape, -width/2, -length/2, 0)
2686
+ elif placement.lower() == "upperleft":
2687
+ i_shape = Topology.Translate(i_shape, width/2, -length/2, 0)
2688
+ elif placement.lower() == "lowerright":
2689
+ i_shape = Topology.Translate(i_shape, -width/2, length/2, 0)
2690
+
2691
+ if direction != [0, 0, 1]:
2692
+ i_shape = Topology.Orient(i_shape, origin=origin, dirA=[0, 0, 1], dirB=direction)
2693
+ return i_shape
2694
+
2390
2695
  @staticmethod
2391
2696
  def Length(wire, mantissa: int = 6) -> float:
2392
2697
  """
@@ -2480,7 +2785,148 @@ class Wire():
2480
2785
  vertices.append(Edge.VertexByParameter(edge, i*unitDistance))
2481
2786
  vertices.append(Edge.EndVertex(edge))
2482
2787
  return Wire.ByVertices(vertices)
2483
-
2788
+
2789
+ @staticmethod
2790
+ def LShape(origin=None,
2791
+ width=1,
2792
+ length=1,
2793
+ a=0.25,
2794
+ b=0.25,
2795
+ flipHorizontal = False,
2796
+ flipVertical = False,
2797
+ direction=[0,0,1],
2798
+ placement="center",
2799
+ tolerance=0.0001,
2800
+ silent=False):
2801
+ """
2802
+ Creates an L-shape.
2803
+
2804
+ Parameters
2805
+ ----------
2806
+ origin : topologic_core.Vertex , optional
2807
+ The location of the origin of the L-shape. The default is None which results in the L-shape being placed at (0, 0, 0).
2808
+ width : float , optional
2809
+ The overall width of the L-shape. The default is 1.0.
2810
+ length : float , optional
2811
+ The overall length of the L-shape. The default is 1.0.
2812
+ a : float , optional
2813
+ The hortizontal thickness of the vertical arm of the L-shape. The default is 0.25.
2814
+ b : float , optional
2815
+ The vertical thickness of the horizontal arm of the L-shape. The default is 0.25.
2816
+ direction : list , optional
2817
+ The vector representing the up direction of the L-shape. The default is [0, 0, 1].
2818
+ placement : str , optional
2819
+ The description of the placement of the origin of the L-shape. This can be "center", "lowerleft", "upperleft", "lowerright", "upperright". It is case insensitive. The default is "center".
2820
+ tolerance : float , optional
2821
+ The desired tolerance. The default is 0.0001.
2822
+ silent : bool , optional
2823
+ If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
2824
+
2825
+ Returns
2826
+ -------
2827
+ topologic_core.Wire
2828
+ The created L-shape.
2829
+
2830
+ """
2831
+ from topologicpy.Vertex import Vertex
2832
+ from topologicpy.Wire import Wire
2833
+ from topologicpy.Topology import Topology
2834
+
2835
+ if not isinstance(width, int) and not isinstance(width, float):
2836
+ if not silent:
2837
+ print("Wire.LShape - Error: The width input parameter is not a valid number. Returning None.")
2838
+ return None
2839
+ if not isinstance(length, int) and not isinstance(length, float):
2840
+ if not silent:
2841
+ print("Wire.LShape - Error: The length input parameter is not a valid number. Returning None.")
2842
+ return None
2843
+ if not isinstance(a, int) and not isinstance(a, float):
2844
+ if not silent:
2845
+ print("Wire.LShape - Error: The a input parameter is not a valid number. Returning None.")
2846
+ return None
2847
+ if not isinstance(b, int) and not isinstance(b, float):
2848
+ if not silent:
2849
+ print("Wire.LShape - Error: The b input parameter is not a valid number. Returning None.")
2850
+ return None
2851
+ if width <= tolerance:
2852
+ if not silent:
2853
+ print("Wire.LShape - Error: The width input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
2854
+ return None
2855
+ if length <= tolerance:
2856
+ if not silent:
2857
+ print("Wire.LShape - Error: The length input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
2858
+ return None
2859
+ if a <= tolerance:
2860
+ if not silent:
2861
+ print("Wire.LShape - Error: The a input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
2862
+ return None
2863
+ if b <= tolerance:
2864
+ if not silent:
2865
+ print("Wire.LShape - Error: The b input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
2866
+ return None
2867
+ if a >= (width - tolerance):
2868
+ if not silent:
2869
+ print("Wire.LShape - Error: The a input parameter must be less than the width input parameter. Returning None.")
2870
+ return None
2871
+ if b >= (length - tolerance):
2872
+ if not silent:
2873
+ print("Wire.LShape - Error: The b input parameter must be less than the length input parameter. Returning None.")
2874
+ return None
2875
+ if origin == None:
2876
+ origin = Vertex.Origin()
2877
+ if not Topology.IsInstance(origin, "vertex"):
2878
+ if not silent:
2879
+ print("Wire.LShape - Error: The origin input parameter is not a valid topologic vertex. Returning None.")
2880
+ return None
2881
+ if not isinstance(direction, list):
2882
+ if not silent:
2883
+ print("Wire.LShape - Error: The direction input parameter is not a valid list. Returning None.")
2884
+ return None
2885
+ if not len(direction) == 3:
2886
+ if not silent:
2887
+ print("Wire.LShape - Error: The direction input parameter is not a valid vector. Returning None.")
2888
+ return None
2889
+
2890
+ # Define the vertices of the L-shape (counterclockwise)
2891
+ v1 = Vertex.Origin() # Base origin
2892
+ v2 = Vertex.ByCoordinates(width, 0) # End of horizontal arm
2893
+ v3 = Vertex.ByCoordinates(width, b) # Top of horizontal arm
2894
+ v4 = Vertex.ByCoordinates(a, b) # Transition to vertical arm
2895
+ v5 = Vertex.ByCoordinates(a, length) # End of vertical arm
2896
+ v6 = Vertex.ByCoordinates(0, length) # Top of vertical arm
2897
+
2898
+ # Create the L-shaped wire
2899
+ l_shape = Wire.ByVertices([v1, v2, v3, v4, v5, v6], close=True)
2900
+ l_shape = Topology.Translate(l_shape, -width/2, -length/2, 0)
2901
+ l_shape = Topology.Translate(l_shape, Vertex.X(origin), Vertex.Y(origin), Vertex.Z(origin))
2902
+ reverse = False
2903
+ if flipHorizontal == True:
2904
+ xScale = -1
2905
+ reverse = not reverse
2906
+ else:
2907
+ xScale = 1
2908
+ if flipVertical == True:
2909
+ yScale = -1
2910
+ reverse = not reverse
2911
+ else:
2912
+ yScale = 1
2913
+ if xScale == -1 or yScale == -1:
2914
+ l_shape = Topology.Scale(l_shape, x=xScale, y=yScale, z=1)
2915
+ if reverse == True:
2916
+ l_shape = Wire.Reverse(l_shape)
2917
+ if placement.lower() == "lowerleft":
2918
+ l_shape = Topology.Translate(l_shape, width/2, length/2, 0)
2919
+ elif placement.lower() == "upperright":
2920
+ l_shape = Topology.Translate(l_shape, -width/2, -length/2, 0)
2921
+ elif placement.lower() == "upperleft":
2922
+ l_shape = Topology.Translate(l_shape, width/2, -length/2, 0)
2923
+ elif placement.lower() == "lowerright":
2924
+ l_shape = Topology.Translate(l_shape, -width/2, length/2, 0)
2925
+
2926
+ if direction != [0, 0, 1]:
2927
+ l_shape = Topology.Orient(l_shape, origin=origin, dirA=[0, 0, 1], dirB=direction)
2928
+ return l_shape
2929
+
2484
2930
  @staticmethod
2485
2931
  def Miter(wire, offset: float = 0, offsetKey: str = None, tolerance: float = 0.0001, silent: bool = False):
2486
2932
  """
@@ -2871,7 +3317,7 @@ class Wire():
2871
3317
  return None
2872
3318
  if not direction:
2873
3319
  direction = -1*Face.Normal(face, outputType="xyz", mantissa=mantissa)
2874
- large_face = Topology.Scale(face, face.CenterOfMass(), 500, 500, 500)
3320
+ large_face = Topology.Scale(face, Topology.CenterOfMass(face), 500, 500, 500)
2875
3321
  edges = []
2876
3322
  _ = wire.Edges(None, edges)
2877
3323
  projected_edges = []
@@ -2881,8 +3327,8 @@ class Wire():
2881
3327
  for edge in edges:
2882
3328
  if edge:
2883
3329
  if (Topology.Type(edge) == Topology.TypeID("Edge")):
2884
- sv = edge.StartVertex()
2885
- ev = edge.EndVertex()
3330
+ sv = Edge.StartVertex(edge)
3331
+ ev = Edge.EndVertex(edge)
2886
3332
 
2887
3333
  psv = Vertex.Project(vertex=sv, face=large_face, direction=direction)
2888
3334
  pev = Vertex.Project(vertex=ev, face=large_face, direction=direction)
@@ -2957,10 +3403,10 @@ class Wire():
2957
3403
  xOffset = -width*0.5
2958
3404
  yOffset = -length*0.5
2959
3405
 
2960
- vb1 = Vertex.ByCoordinates(origin.X()-width*0.5+xOffset,origin.Y()-length*0.5+yOffset,origin.Z())
2961
- vb2 = Vertex.ByCoordinates(origin.X()+width*0.5+xOffset,origin.Y()-length*0.5+yOffset,origin.Z())
2962
- vb3 = Vertex.ByCoordinates(origin.X()+width*0.5+xOffset,origin.Y()+length*0.5+yOffset,origin.Z())
2963
- vb4 = Vertex.ByCoordinates(origin.X()-width*0.5+xOffset,origin.Y()+length*0.5+yOffset,origin.Z())
3406
+ vb1 = Vertex.ByCoordinates(Vertex.X(origin)-width*0.5+xOffset,Vertex.Y(origin)-length*0.5+yOffset,Vertex.Z(origin))
3407
+ vb2 = Vertex.ByCoordinates(Vertex.X(origin)+width*0.5+xOffset,Vertex.Y(origin)-length*0.5+yOffset,Vertex.Z(origin))
3408
+ vb3 = Vertex.ByCoordinates(Vertex.X(origin)+width*0.5+xOffset,Vertex.Y(origin)+length*0.5+yOffset,Vertex.Z(origin))
3409
+ vb4 = Vertex.ByCoordinates(Vertex.X(origin)-width*0.5+xOffset,Vertex.Y(origin)+length*0.5+yOffset,Vertex.Z(origin))
2964
3410
 
2965
3411
  baseWire = Wire.ByVertices([vb1, vb2, vb3, vb4], True)
2966
3412
  if direction != [0, 0, 1]:
@@ -3181,6 +3627,88 @@ class Wire():
3181
3627
  else:
3182
3628
  return wire
3183
3629
 
3630
+ @staticmethod
3631
+ def Representation(wire, normalize: bool = True, rotate: bool = True, mantissa: int = 6, tolerance: float = 0.0001):
3632
+ """
3633
+ Returns a normalized representation of a closed wire with alternating edge lengths and interior angles.
3634
+
3635
+ Parameters
3636
+ ----------
3637
+ wire : topologic_core.Wire
3638
+ The input wire.
3639
+ normalize : bool , optional
3640
+ If set to True, the lengths in the list are normalized so that the shortest edge has a length of 1. the default is True.
3641
+ rotate : bool , optional
3642
+ If set to True, the list is rotated such that the shortest edge appears first.
3643
+ mantissa : int , optional
3644
+ The desired length of the mantissa. The default is 6.
3645
+ tolerance : float , optional
3646
+ The desired tolerance. The default is 0.0001.
3647
+
3648
+ Returns
3649
+ -------
3650
+ list
3651
+ The representation list.
3652
+
3653
+ """
3654
+ from topologicpy.Vertex import Vertex
3655
+ from topologicpy.Edge import Edge
3656
+ import math
3657
+
3658
+ def angleBetweenEdges(e1, e2, tolerance=0.0001):
3659
+ a = Vertex.X(Edge.EndVertex(e1)) - Vertex.X(Edge.StartVertex(e1))
3660
+ b = Vertex.Y(Edge.EndVertex(e1)) - Vertex.Y(Edge.StartVertex(e1))
3661
+ c = Vertex.Z(Edge.EndVertex(e1)) - Vertex.Z(Edge.StartVertex(e1))
3662
+ d = Vertex.Distance(Edge.EndVertex(e1), Edge.StartVertex(e2))
3663
+ if d <= tolerance:
3664
+ d = Vertex.X(Edge.StartVertex(e2)) - Vertex.X(Edge.EndVertex(e2))
3665
+ e = Vertex.Y(Edge.StartVertex(e2)) - Vertex.Y(Edge.EndVertex(e2))
3666
+ f = Vertex.Z(Edge.StartVertex(e2)) - Vertex.Z(Edge.EndVertex(e2))
3667
+ else:
3668
+ d = Vertex.X(Edge.EndVertex(e2)) - Vertex.X(Edge.StartVertex(e2))
3669
+ e = Vertex.Y(Edge.EndVertex(e2)) - Vertex.Y(Edge.StartVertex(e2))
3670
+ f = Vertex.Z(Edge.EndVertex(e2)) - Vertex.Z(Edge.StartVertex(e2))
3671
+ dotProduct = a*d + b*e + c*f
3672
+ modOfVector1 = math.sqrt( a*a + b*b + c*c)*math.sqrt(d*d + e*e + f*f)
3673
+ angle = dotProduct/modOfVector1
3674
+ angleInDegrees = math.degrees(math.acos(angle))
3675
+ return angleInDegrees
3676
+
3677
+ def getInteriorAngles(edges, tolerance=0.0001):
3678
+ angles = []
3679
+ for i in range(len(edges)-1):
3680
+ e1 = edges[i]
3681
+ e2 = edges[i+1]
3682
+ angles.append(angleBetweenEdges(e1, e2, tolerance=tolerance))
3683
+ return angles
3684
+
3685
+ def rotate_list_to_minimum(nums):
3686
+ if not nums:
3687
+ return nums # Return the empty list as-is
3688
+
3689
+ min_index = nums.index(min(nums))
3690
+ return nums[min_index:] + nums[:min_index]
3691
+
3692
+ def getRep(edges, normalize=True, rotate=True, tolerance=0.0001):
3693
+ angles = getInteriorAngles(edges, tolerance=tolerance)
3694
+ lengths = []
3695
+ normalizedLengths = []
3696
+ for anEdge in edges:
3697
+ lengths.append(Edge.Length(anEdge))
3698
+ if normalize == True:
3699
+ minLength = min(lengths)
3700
+ else:
3701
+ minLength = 1
3702
+ for aLength in lengths:
3703
+ normalizedLengths.append(aLength/minLength)
3704
+ if rotate == True:
3705
+ return rotate_list_to_minimum([x for x in itertools.chain(*itertools.zip_longest(normalizedLengths, angles)) if x is not None])
3706
+ return [x for x in itertools.chain(*itertools.zip_longest(normalizedLengths, angles)) if x is not None]
3707
+
3708
+ edges = Topology.Edges(wire)
3709
+ return_list = [round(x, mantissa) for x in getRep(edges, normalize=normalize, rotate=rotate, tolerance=tolerance)]
3710
+ return return_list
3711
+
3184
3712
  @staticmethod
3185
3713
  def Reverse(wire, transferDictionaries = False, tolerance: float = 0.0001):
3186
3714
  """
@@ -3305,7 +3833,7 @@ class Wire():
3305
3833
  eb_vertices = Topology.Vertices(eb_wire)
3306
3834
  if normal[2] > 0:
3307
3835
  eb_vertices = list(reversed(eb_vertices))
3308
- eb_polygon_coordinates = [(v.X(), v.Y(), v.Z()) for v in eb_vertices]
3836
+ eb_polygon_coordinates = [(Vertex.X(v), Vertex.Y(v), Vertex.Z(v)) for v in eb_vertices]
3309
3837
  eb_polygonxy = [(x[0], x[1]) for x in eb_polygon_coordinates]
3310
3838
 
3311
3839
  ib_polygonsxy = []
@@ -3314,7 +3842,7 @@ class Wire():
3314
3842
  ib_vertices = Topology.Vertices(ib_wire)
3315
3843
  if normal[2] > 0:
3316
3844
  ib_vertices = list(reversed(ib_vertices))
3317
- ib_polygon_coordinates = [(v.X(), v.Y(), v.Z()) for v in ib_vertices]
3845
+ ib_polygon_coordinates = [(Vertex.X(v), Vertex.Y(v), Vertex.Z(v)) for v in ib_vertices]
3318
3846
  ib_polygonxy = [(x[0], x[1]) for x in ib_polygon_coordinates]
3319
3847
  ib_polygonsxy.append(ib_polygonxy)
3320
3848
  zero_coordinates += ib_polygon_coordinates
@@ -3381,12 +3909,12 @@ class Wire():
3381
3909
 
3382
3910
  def perpendicular_distance(point, line_start, line_end):
3383
3911
  # Calculate the perpendicular distance from a point to a line segment
3384
- x0 = point.X()
3385
- y0 = point.Y()
3386
- x1 = line_start.X()
3387
- y1 = line_start.Y()
3388
- x2 = line_end.X()
3389
- y2 = line_end.Y()
3912
+ x0 = Vertex.X(point)
3913
+ y0 = Vertex.Y(point)
3914
+ x1 = Vertex.X(line_start)
3915
+ y1 = Vertex.Y(line_start)
3916
+ x2 = Vertex.X(line_end)
3917
+ y2 = Vertex.Y(line_end)
3390
3918
 
3391
3919
  numerator = abs((y2 - y1) * x0 - (x2 - x1) * y0 + x2 * y1 - y2 * x1)
3392
3920
  denominator = Vertex.Distance(line_start, line_end)
@@ -3433,7 +3961,7 @@ class Wire():
3433
3961
  # Calculate the effective area for each point except the first and last
3434
3962
  def effective_area(p1, p2, p3):
3435
3963
  # Triangle area formed by p1, p2, and p3
3436
- return 0.5 * abs(p1.X() * (p2.Y() - p3.Y()) + p2.X() * (p3.Y() - p1.Y()) + p3.X() * (p1.Y() - p2.Y()))
3964
+ return 0.5 * abs(Vertex.X(p1) * (Vertex.Y(p2) - Vertex.Y(p3)) + Vertex.X(p2) * (Vertex.Y(p3) - Vertex.Y(p1)) + Vertex.X(p3) * (Vertex.Y(p1) - Vertex.Y(p2)))
3437
3965
 
3438
3966
  # Keep track of effective areas
3439
3967
  areas = [None] # First point has no area
@@ -3911,9 +4439,9 @@ class Wire():
3911
4439
  else:
3912
4440
  radius = radiusB
3913
4441
  angle = math.radians(360/sides)*i
3914
- x = math.sin(angle)*radius + origin.X()
3915
- y = math.cos(angle)*radius + origin.Y()
3916
- z = origin.Z()
4442
+ x = math.sin(angle)*radius + Vertex.X(origin)
4443
+ y = math.cos(angle)*radius + Vertex.Y(origin)
4444
+ z = Vertex.Z(origin)
3917
4445
  xList.append(x)
3918
4446
  yList.append(y)
3919
4447
  baseV.append([x, y])
@@ -3921,29 +4449,29 @@ class Wire():
3921
4449
  if placement.lower() == "lowerleft":
3922
4450
  xmin = min(xList)
3923
4451
  ymin = min(yList)
3924
- xOffset = origin.X() - xmin
3925
- yOffset = origin.Y() - ymin
4452
+ xOffset = Vertex.X(origin) - xmin
4453
+ yOffset = Vertex.Y(origin) - ymin
3926
4454
  elif placement.lower() == "upperleft":
3927
4455
  xmin = min(xList)
3928
4456
  ymax = max(yList)
3929
- xOffset = origin.X() - xmin
3930
- yOffset = origin.Y() - ymax
4457
+ xOffset = Vertex.X(origin) - xmin
4458
+ yOffset = Vertex.Y(origin) - ymax
3931
4459
  elif placement.lower() == "lowerright":
3932
4460
  xmax = max(xList)
3933
4461
  ymin = min(yList)
3934
- xOffset = origin.X() - xmax
3935
- yOffset = origin.Y() - ymin
4462
+ xOffset = Vertex.X(origin) - xmax
4463
+ yOffset = Vertex.Y(origin) - ymin
3936
4464
  elif placement.lower() == "upperright":
3937
4465
  xmax = max(xList)
3938
4466
  ymax = max(yList)
3939
- xOffset = origin.X() - xmax
3940
- yOffset = origin.Y() - ymax
4467
+ xOffset = Vertex.X(origin) - xmax
4468
+ yOffset = Vertex.Y(origin) - ymax
3941
4469
  else:
3942
4470
  xOffset = 0
3943
4471
  yOffset = 0
3944
4472
  tranBase = []
3945
4473
  for coord in baseV:
3946
- tranBase.append(Vertex.ByCoordinates(coord[0]+xOffset, coord[1]+yOffset, origin.Z()))
4474
+ tranBase.append(Vertex.ByCoordinates(coord[0]+xOffset, coord[1]+yOffset, Vertex.Z(origin)))
3947
4475
 
3948
4476
  baseWire = Wire.ByVertices(tranBase, True)
3949
4477
  baseWire = Wire.Reverse(baseWire)
@@ -4054,16 +4582,160 @@ class Wire():
4054
4582
  xOffset = -(max((widthA*0.5 + offsetA), (widthB*0.5 + offsetB)))
4055
4583
  yOffset = -length*0.5
4056
4584
 
4057
- vb1 = Vertex.ByCoordinates(origin.X()-widthA*0.5+offsetA+xOffset,origin.Y()-length*0.5+yOffset,origin.Z())
4058
- vb2 = Vertex.ByCoordinates(origin.X()+widthA*0.5+offsetA+xOffset,origin.Y()-length*0.5+yOffset,origin.Z())
4059
- vb3 = Vertex.ByCoordinates(origin.X()+widthB*0.5+offsetB+xOffset,origin.Y()+length*0.5+yOffset,origin.Z())
4060
- vb4 = Vertex.ByCoordinates(origin.X()-widthB*0.5++offsetB+xOffset,origin.Y()+length*0.5+yOffset,origin.Z())
4585
+ vb1 = Vertex.ByCoordinates(Vertex.X(origin)-widthA*0.5+offsetA+xOffset,Vertex.Y(origin)-length*0.5+yOffset,Vertex.Z(origin))
4586
+ vb2 = Vertex.ByCoordinates(Vertex.X(origin)+widthA*0.5+offsetA+xOffset,Vertex.Y(origin)-length*0.5+yOffset,Vertex.Z(origin))
4587
+ vb3 = Vertex.ByCoordinates(Vertex.X(origin)+widthB*0.5+offsetB+xOffset,Vertex.Y(origin)+length*0.5+yOffset,Vertex.Z(origin))
4588
+ vb4 = Vertex.ByCoordinates(Vertex.X(origin)-widthB*0.5++offsetB+xOffset,Vertex.Y(origin)+length*0.5+yOffset,Vertex.Z(origin))
4061
4589
 
4062
4590
  baseWire = Wire.ByVertices([vb1, vb2, vb3, vb4], True)
4063
4591
  if direction != [0, 0, 1]:
4064
4592
  baseWire = Topology.Orient(baseWire, origin=origin, dirA=[0, 0, 1], dirB=direction)
4065
4593
  return baseWire
4066
4594
 
4595
+
4596
+ @staticmethod
4597
+ def TShape(origin=None,
4598
+ width=1,
4599
+ length=1,
4600
+ a=0.25,
4601
+ b=0.25,
4602
+ flipHorizontal = False,
4603
+ flipVertical = False,
4604
+ direction=[0,0,1],
4605
+ placement="center",
4606
+ tolerance=0.0001,
4607
+ silent=False):
4608
+ """
4609
+ Creates a T-shape.
4610
+
4611
+ Parameters
4612
+ ----------
4613
+ origin : topologic_core.Vertex , optional
4614
+ The location of the origin of the T-shape. The default is None which results in the L-shape being placed at (0, 0, 0).
4615
+ width : float , optional
4616
+ The overall width of the T-shape. The default is 1.0.
4617
+ length : float , optional
4618
+ The overall length of the T-shape. The default is 1.0.
4619
+ a : float , optional
4620
+ The hortizontal thickness of the vertical arm of the T-shape. The default is 0.5.
4621
+ b : float , optional
4622
+ The vertical thickness of the horizontal arm of the T-shape. The default is 0.5.
4623
+ direction : list , optional
4624
+ The vector representing the up direction of the T-shape. The default is [0, 0, 1].
4625
+ placement : str , optional
4626
+ The description of the placement of the origin of the T-shape. This can be "center", "lowerleft", "upperleft", "lowerright", "upperright". It is case insensitive. The default is "center".
4627
+ tolerance : float , optional
4628
+ The desired tolerance. The default is 0.0001.
4629
+ silent : bool , optional
4630
+ If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
4631
+
4632
+ Returns
4633
+ -------
4634
+ topologic_core.Wire
4635
+ The created T-shape.
4636
+
4637
+ """
4638
+ from topologicpy.Vertex import Vertex
4639
+ from topologicpy.Wire import Wire
4640
+ from topologicpy.Topology import Topology
4641
+
4642
+ if not isinstance(width, int) and not isinstance(width, float):
4643
+ if not silent:
4644
+ print("Wire.LShape - Error: The width input parameter is not a valid number. Returning None.")
4645
+ return None
4646
+ if not isinstance(length, int) and not isinstance(length, float):
4647
+ if not silent:
4648
+ print("Wire.LShape - Error: The length input parameter is not a valid number. Returning None.")
4649
+ return None
4650
+ if not isinstance(a, int) and not isinstance(a, float):
4651
+ if not silent:
4652
+ print("Wire.LShape - Error: The a input parameter is not a valid number. Returning None.")
4653
+ return None
4654
+ if not isinstance(b, int) and not isinstance(b, float):
4655
+ if not silent:
4656
+ print("Wire.LShape - Error: The b input parameter is not a valid number. Returning None.")
4657
+ return None
4658
+ if width <= tolerance:
4659
+ if not silent:
4660
+ print("Wire.LShape - Error: The width input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
4661
+ return None
4662
+ if length <= tolerance:
4663
+ if not silent:
4664
+ print("Wire.LShape - Error: The length input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
4665
+ return None
4666
+ if a <= tolerance:
4667
+ if not silent:
4668
+ print("Wire.LShape - Error: The a input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
4669
+ return None
4670
+ if b <= tolerance:
4671
+ if not silent:
4672
+ print("Wire.LShape - Error: The b input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
4673
+ return None
4674
+ if a >= (width - tolerance):
4675
+ if not silent:
4676
+ print("Wire.LShape - Error: The a input parameter must be less than the width input parameter. Returning None.")
4677
+ return None
4678
+ if b >= (length - tolerance):
4679
+ if not silent:
4680
+ print("Wire.LShape - Error: The b input parameter must be less than the length input parameter. Returning None.")
4681
+ return None
4682
+ if origin == None:
4683
+ origin = Vertex.Origin()
4684
+ if not Topology.IsInstance(origin, "vertex"):
4685
+ if not silent:
4686
+ print("Wire.LShape - Error: The origin input parameter is not a valid topologic vertex. Returning None.")
4687
+ return None
4688
+ if not isinstance(direction, list):
4689
+ if not silent:
4690
+ print("Wire.LShape - Error: The direction input parameter is not a valid list. Returning None.")
4691
+ return None
4692
+ if not len(direction) == 3:
4693
+ if not silent:
4694
+ print("Wire.LShape - Error: The direction input parameter is not a valid vector. Returning None.")
4695
+ return None
4696
+
4697
+ # Define the vertices of the T-shape (counterclockwise)
4698
+ v1 = Vertex.ByCoordinates(width/2-a/2, 0)
4699
+ v2 = Vertex.ByCoordinates(width/2+a/2, 0)
4700
+ v3 = Vertex.ByCoordinates(width/2+a/2, length-b)
4701
+ v4 = Vertex.ByCoordinates(width, length-b)
4702
+ v5 = Vertex.ByCoordinates(width, length)
4703
+ v6 = Vertex.ByCoordinates(0, length)
4704
+ v7 = Vertex.ByCoordinates(0, length-b)
4705
+ v8 = Vertex.ByCoordinates(width/2-a/2, length-b) # Top of vertical arm
4706
+
4707
+ # Create the T-shaped wire
4708
+ t_shape = Wire.ByVertices([v1, v2, v3, v4, v5, v6, v7, v8], close=True)
4709
+ t_shape = Topology.Translate(t_shape, -width/2, -length/2, 0)
4710
+ t_shape = Topology.Translate(t_shape, Vertex.X(origin), Vertex.Y(origin), Vertex.Z(origin))
4711
+ reverse = False
4712
+ if flipHorizontal == True:
4713
+ xScale = -1
4714
+ reverse = not reverse
4715
+ else:
4716
+ xScale = 1
4717
+ if flipVertical == True:
4718
+ yScale = -1
4719
+ reverse = not reverse
4720
+ else:
4721
+ yScale = 1
4722
+ if xScale == -1 or yScale == -1:
4723
+ t_shape = Topology.Scale(t_shape, x=xScale, y=yScale, z=1)
4724
+ if reverse == True:
4725
+ t_shape = Wire.Reverse(t_shape)
4726
+ if placement.lower() == "lowerleft":
4727
+ t_shape = Topology.Translate(t_shape, width/2, length/2, 0)
4728
+ elif placement.lower() == "upperright":
4729
+ t_shape = Topology.Translate(t_shape, -width/2, -length/2, 0)
4730
+ elif placement.lower() == "upperleft":
4731
+ t_shape = Topology.Translate(t_shape, width/2, -length/2, 0)
4732
+ elif placement.lower() == "lowerright":
4733
+ t_shape = Topology.Translate(t_shape, -width/2, length/2, 0)
4734
+
4735
+ if direction != [0, 0, 1]:
4736
+ t_shape = Topology.Orient(t_shape, origin=origin, dirA=[0, 0, 1], dirB=direction)
4737
+ return t_shape
4738
+
4067
4739
  @staticmethod
4068
4740
  def VertexDistance(wire, vertex, origin= None, mantissa: int = 6, tolerance: float = 0.0001):
4069
4741
  """