diff --git a/Gui/Command.py b/Gui/Command.py index 959432a..329496b 100644 --- a/Gui/Command.py +++ b/Gui/Command.py @@ -168,9 +168,13 @@ class CadQueryExecuteScript: if build_result.success: # Display all the results that the user requested for result in build_result.results: - show(result) + # Apply options to the show function if any were provided + if result.options and result.options["rgba"]: + show(result.shape, result.options["rgba"]) + else: + show(result.shape) else: - FreeCAD.Console.PrintError("Error executing CQGI-compliant script.\r\n") + FreeCAD.Console.PrintError("Error executing CQGI-compliant script. " + str(build_result.exception) + "\r\n") else: # Save our code to a tempfile and render it tempFile = tempfile.NamedTemporaryFile(delete=False) diff --git a/Libs/cadquery-lib/.coverage b/Libs/cadquery-lib/.coverage deleted file mode 100644 index 349220a..0000000 --- a/Libs/cadquery-lib/.coverage +++ /dev/null @@ -1 +0,0 @@ -!coverage.py: This is a private format, don't read it directly!{"lines": {"/home/jwright/Downloads/cadquery/cadquery/cq_directive.py": [], "/home/jwright/Downloads/cadquery/cadquery/cq.py": [2049, 2052, 2053, 2054, 2056, 2057, 2058, 2060, 18, 20, 21, 22, 23, 24, 27, 2076, 2078, 33, 34, 35, 36, 2085, 2086, 39, 40, 2089, 43, 2093, 49, 51, 2102, 2103, 2104, 58, 59, 60, 2109, 62, 2111, 65, 2126, 2127, 2128, 81, 2130, 2131, 84, 2133, 2134, 2140, 2141, 2142, 2143, 96, 2145, 2147, 2149, 102, 2151, 104, 106, 107, 108, 110, 112, 2166, 2168, 2170, 2171, 2172, 2173, 2174, 2178, 363, 2180, 133, 2182, 2183, 136, 2185, 138, 2187, 140, 141, 2255, 143, 145, 149, 150, 151, 153, 154, 156, 2207, 368, 2211, 2213, 2215, 2217, 2218, 2220, 174, 175, 176, 178, 182, 184, 185, 2235, 188, 189, 190, 2239, 192, 193, 195, 374, 2246, 2247, 2249, 2251, 2252, 205, 2254, 207, 2257, 211, 213, 222, 224, 2427, 2276, 2277, 2279, 2282, 2087, 238, 239, 240, 2088, 243, 244, 246, 383, 253, 255, 2307, 2308, 2309, 2310, 2433, 2312, 265, 2314, 2316, 2318, 2333, 2336, 2339, 2340, 2341, 2342, 2344, 2346, 306, 2075, 308, 309, 310, 311, 2361, 314, 2363, 2364, 2366, 2368, 322, 329, 330, 332, 333, 335, 337, 341, 344, 345, 349, 350, 353, 355, 356, 357, 360, 361, 2411, 364, 365, 2414, 2415, 2416, 2417, 2418, 2419, 2420, 2422, 375, 2424, 378, 379, 2428, 382, 2431, 384, 385, 2434, 388, 390, 396, 398, 404, 406, 411, 413, 2471, 2472, 2474, 427, 428, 432, 2482, 2483, 2485, 2486, 2488, 2489, 2491, 2494, 2497, 2498, 2500, 454, 455, 456, 457, 458, 461, 462, 464, 466, 78, 79, 2524, 479, 80, 482, 483, 485, 486, 488, 490, 1447, 82, 2132, 519, 521, 2480, 551, 553, 582, 97, 584, 605, 607, 103, 839, 631, 633, 651, 653, 669, 671, 2502, 681, 683, 692, 694, 720, 722, 723, 724, 725, 727, 729, 2070, 742, 743, 745, 758, 2071, 766, 769, 131, 2072, 2523, 805, 807, 808, 811, 812, 813, 815, 137, 2527, 836, 838, 481, 842, 843, 844, 846, 369, 874, 876, 877, 880, 882, 883, 886, 910, 912, 914, 936, 937, 938, 939, 943, 947, 948, 949, 951, 952, 953, 955, 968, 969, 971, 972, 974, 975, 976, 977, 979, 981, 994, 995, 996, 997, 998, 999, 1001, 1022, 1024, 1025, 1026, 1027, 1031, 1032, 172, 1034, 1036, 1050, 1053, 1054, 1055, 1056, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1067, 1069, 1089, 1090, 1091, 1092, 1094, 1096, 1123, 1124, 1125, 1127, 2236, 2237, 1137, 1139, 1141, 1143, 1144, 1146, 1149, 2241, 1160, 1161, 1163, 1170, 1172, 1179, 1181, 1191, 1192, 1194, 1204, 1205, 1208, 2359, 1223, 1224, 1227, 2253, 1242, 1243, 1244, 1246, 2259, 1278, 1279, 1281, 1282, 1284, 1286, 1287, 1289, 1291, 1307, 1308, 1309, 1311, 1313, 1314, 1316, 1318, 1338, 1341, 1343, 1345, 1346, 1347, 1350, 1352, 1354, 2091, 1372, 1373, 1374, 1376, 1390, 1391, 1392, 1394, 1401, 1403, 1404, 1406, 1421, 1423, 1433, 1434, 1435, 1439, 1446, 241, 1448, 1449, 1451, 1472, 1475, 1476, 1478, 1480, 1481, 1482, 1486, 1487, 1488, 1490, 1492, 1524, 1525, 1527, 1529, 1530, 1532, 1534, 1535, 1536, 1538, 1540, 1542, 1560, 1561, 1564, 1567, 1568, 1570, 1572, 263, 2313, 1598, 1601, 1602, 1603, 1604, 1605, 1607, 1608, 1609, 1610, 1612, 1613, 1616, 1619, 1648, 1649, 1650, 1651, 1653, 1655, 1666, 1668, 1669, 1670, 1671, 1672, 1673, 1675, 1677, 1692, 1695, 1698, 1699, 1701, 1704, 1706, 1707, 1709, 1711, 1725, 1728, 1730, 1732, 1741, 1742, 1743, 1745, 1747, 1757, 1758, 1762, 1763, 1764, 1765, 1767, 1769, 1770, 1773, 1803, 1804, 1806, 1812, 1814, 1817, 1818, 1819, 1821, 1825, 2107, 2356, 2357, 1856, 1857, 1859, 1862, 1865, 1866, 1867, 1868, 1869, 1870, 1872, 1876, 2362, 63, 1902, 1903, 1905, 1911, 1913, 1914, 1916, 1919, 320, 1940, 1942, 1945, 1954, 1955, 1956, 1957, 1958, 1959, 1963, 1964, 1966, 1967, 1968, 1970, 1995, 1997, 1998, 2000, 2001, 2002, 2004, 2027, 2030, 2034, 2035, 2037, 2041, 2044, 2045, 2047], "/home/jwright/Downloads/cadquery/cadquery/freecad_impl/__init__.py": [18, 19, 20, 23, 26, 27, 30, 32, 33, 34, 35, 36, 37, 38, 39, 41, 42, 101, 102, 103, 104, 105, 106], "/home/jwright/Downloads/cadquery/cadquery/freecad_impl/shapes.py": [1026, 1027, 1028, 1030, 521, 599, 524, 930, 526, 88, 530, 259, 533, 535, 810, 461, 802, 602, 1033, 544, 546, 603, 518, 554, 556, 557, 559, 49, 50, 51, 52, 986, 55, 568, 104, 571, 572, 61, 574, 575, 576, 578, 579, 68, 69, 71, 72, 1036, 74, 587, 866, 591, 81, 594, 595, 84, 85, 87, 355, 89, 90, 91, 93, 94, 607, 96, 609, 610, 611, 612, 808, 616, 105, 110, 873, 624, 113, 626, 116, 446, 630, 631, 632, 633, 634, 703, 636, 637, 645, 134, 961, 649, 652, 937, 660, 663, 664, 668, 601, 160, 673, 678, 625, 681, 682, 172, 173, 686, 175, 689, 178, 691, 181, 184, 628, 187, 188, 189, 702, 191, 971, 708, 710, 711, 493, 204, 717, 206, 719, 720, 209, 210, 211, 212, 213, 726, 728, 729, 219, 220, 221, 223, 224, 208, 738, 114, 234, 809, 750, 751, 830, 241, 242, 244, 245, 246, 297, 248, 761, 250, 322, 256, 257, 770, 771, 97, 261, 262, 811, 776, 812, 778, 983, 281, 815, 284, 285, 803, 287, 288, 290, 291, 804, 293, 294, 817, 296, 988, 95, 299, 300, 818, 302, 303, 816, 305, 306, 308, 821, 822, 311, 312, 825, 314, 827, 828, 906, 868, 831, 832, 834, 323, 325, 326, 328, 329, 330, 332, 334, 335, 336, 337, 338, 340, 569, 345, 348, 826, 864, 506, 354, 59, 356, 357, 358, 871, 360, 762, 805, 373, 374, 375, 377, 378, 381, 865, 384, 386, 899, 406, 390, 391, 392, 393, 394, 907, 397, 910, 399, 400, 913, 402, 915, 917, 918, 409, 98, 412, 414, 929, 418, 422, 423, 424, 425, 939, 940, 429, 942, 431, 432, 433, 434, 949, 438, 951, 901, 953, 954, 671, 956, 492, 958, 447, 960, 449, 963, 904, 970, 759, 460, 973, 462, 589, 464, 981, 470, 471, 984, 473, 474, 79, 476, 477, 478, 479, 480, 482, 934, 1000, 1001, 490, 935, 1004, 82, 494, 1007, 496, 1009, 83, 1013, 869, 1016, 1018, 507, 508, 1021, 510, 597], "/home/jwright/Downloads/cadquery/cadquery/__init__.py": [2, 3, 4, 5, 10, 11, 15, 16, 17, 18, 21], "/home/jwright/Downloads/cadquery/cadquery/selectors.py": [51, 514, 515, 516, 518, 519, 521, 522, 523, 525, 526, 319, 528, 18, 531, 20, 21, 22, 23, 24, 538, 29, 542, 543, 544, 34, 35, 548, 553, 555, 45, 47, 48, 50, 563, 564, 53, 54, 567, 56, 57, 570, 59, 573, 574, 575, 577, 578, 579, 581, 582, 583, 585, 586, 75, 76, 77, 78, 591, 592, 593, 594, 596, 598, 87, 600, 89, 102, 103, 104, 105, 106, 108, 530, 110, 111, 112, 114, 117, 118, 119, 532, 122, 123, 124, 125, 126, 128, 129, 131, 133, 137, 138, 139, 140, 142, 655, 656, 657, 146, 659, 663, 152, 153, 156, 158, 160, 161, 162, 164, 165, 166, 568, 168, 170, 188, 190, 191, 193, 535, 546, 211, 213, 214, 121, 216, 536, 234, 236, 237, 238, 239, 242, 261, 262, 263, 265, 266, 267, 268, 269, 270, 301, 272, 293, 294, 295, 296, 297, 298, 299, 562, 302, 305, 307, 309, 310, 649, 313, 314, 316, 650, 565, 321, 329, 330, 331, 332, 333, 334, 335, 337, 339, 654, 342, 345, 349, 350, 351, 354, 355, 358, 360, 364, 365, 366, 367, 369, 370, 371, 373, 376, 379, 380, 382, 384, 387, 388, 390, 392, 396, 397, 398, 400, 80, 404, 405, 406, 408, 410, 413, 81, 419, 420, 421, 422, 423, 426, 427, 428, 429, 430, 433, 434, 437, 438, 439, 442, 445, 448, 449, 450, 587, 452, 455, 458, 463, 464, 466, 468, 590, 472, 473, 476, 477, 478, 479, 480, 481, 482, 485, 486, 487, 488, 489, 490, 491, 494, 495, 496, 497, 498, 501, 502, 503, 504, 505, 507, 508, 510, 341], "/home/jwright/Downloads/cadquery/cadquery/cqgi.py": [4, 5, 6, 7, 8, 10, 12, 23, 24, 27, 36, 38, 43, 44, 45, 46, 51, 53, 64, 66, 67, 68, 70, 71, 72, 74, 83, 95, 96, 98, 99, 101, 102, 103, 104, 105, 106, 107, 110, 111, 112, 113, 114, 116, 117, 118, 119, 120, 121, 122, 124, 125, 126, 128, 129, 131, 132, 133, 135, 136, 139, 149, 150, 151, 152, 153, 154, 155, 156, 158, 159, 160, 162, 163, 165, 166, 167, 168, 171, 175, 176, 177, 179, 180, 182, 183, 184, 185, 188, 189, 192, 193, 196, 197, 200, 201, 204, 214, 215, 218, 221, 224, 227, 230, 232, 234, 235, 237, 238, 240, 241, 242, 243, 244, 245, 246, 247, 249, 251, 256, 257, 258, 259, 260, 261, 262, 263, 265, 266, 267, 268, 271, 275, 280, 285, 286, 287, 288, 290, 295, 297, 301, 303, 309, 315, 316, 318, 323, 324, 325, 326, 328, 332, 333, 336, 340, 341, 344, 349, 351, 362, 365, 368, 372, 377, 378, 379, 381, 382, 384, 385, 386, 388, 389, 390, 391, 393, 394, 395, 397, 398, 400, 403, 404, 405, 407, 411, 412, 416, 417, 418, 420, 421, 422, 423, 425, 428, 430, 431, 433, 434, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 453, 455, 456, 459, 462, 463, 464, 466, 467, 472], "/home/jwright/Downloads/cadquery/cadquery/freecad_impl/importers.py": [2, 3, 5, 6, 7, 8, 9, 10, 12, 13, 15, 16, 17, 20, 28, 29, 33, 39, 41, 44, 45, 46, 48, 53], "/home/jwright/Downloads/cadquery/cadquery/freecad_impl/exporters.py": [1, 3, 4, 6, 9, 10, 15, 16, 17, 18, 19, 20, 23, 24, 25, 28, 34, 46, 47, 49, 51, 53, 55, 56, 59, 60, 61, 62, 63, 64, 65, 66, 71, 74, 76, 77, 78, 79, 83, 84, 86, 91, 92, 93, 95, 96, 99, 103, 105, 107, 108, 111, 115, 116, 118, 121, 122, 124, 125, 127, 128, 130, 131, 132, 133, 136, 137, 138, 139, 140, 141, 142, 143, 144, 147, 148, 149, 150, 151, 152, 153, 154, 157, 164, 165, 167, 168, 169, 170, 172, 173, 174, 177, 179, 180, 186, 187, 188, 189, 190, 191, 195, 210, 211, 212, 214, 215, 216, 217, 218, 220, 221, 223, 225, 226, 227, 232, 237, 239, 243, 245, 246, 247, 248, 251, 252, 254, 257, 258, 259, 260, 263, 266, 269, 270, 271, 273, 274, 275, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 294, 297, 304, 305, 306, 307, 353, 389, 391], "/home/jwright/Downloads/cadquery/cadquery/freecad_impl/geom.py": [515, 516, 517, 522, 523, 524, 529, 18, 20, 21, 22, 23, 26, 540, 542, 544, 546, 547, 548, 550, 632, 42, 44, 45, 46, 47, 560, 49, 50, 563, 564, 565, 567, 568, 569, 58, 572, 573, 575, 581, 70, 583, 72, 73, 74, 75, 76, 77, 78, 79, 592, 593, 594, 595, 597, 87, 89, 91, 93, 95, 608, 97, 99, 101, 614, 103, 616, 105, 618, 107, 109, 110, 113, 114, 116, 117, 630, 119, 120, 633, 122, 123, 125, 638, 127, 128, 130, 635, 132, 645, 134, 136, 144, 146, 147, 149, 152, 155, 158, 161, 162, 164, 167, 170, 173, 174, 177, 181, 182, 183, 184, 188, 189, 191, 192, 195, 586, 631, 206, 208, 209, 463, 634, 570, 238, 637, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 254, 255, 260, 261, 262, 263, 264, 266, 267, 268, 269, 270, 272, 273, 643, 278, 279, 280, 281, 282, 284, 285, 133, 48, 290, 291, 296, 297, 302, 303, 51, 308, 309, 52, 314, 315, 590, 629, 53, 320, 321, 326, 327, 55, 332, 345, 346, 348, 349, 350, 352, 354, 356, 358, 360, 362, 364, 365, 367, 609, 389, 391, 495, 69, 418, 419, 582, 423, 424, 71, 428, 430, 584, 611, 585, 445, 446, 587, 454, 588, 461, 462, 589, 464, 466, 467, 469, 591, 483, 485, 488, 489, 490, 491, 494, 613, 497, 499], "/home/jwright/Downloads/cadquery/cadquery/plugins/__init__.py": [18], "/home/jwright/Downloads/cadquery/cadquery/contrib/__init__.py": []}} \ No newline at end of file diff --git a/Libs/cadquery-lib/.gitignore b/Libs/cadquery-lib/.gitignore deleted file mode 100644 index e7df8cf..0000000 --- a/Libs/cadquery-lib/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -build/ -*.pyc -doc/_build/* -dist/* -.idea/* -cadquery.egg-info -target/* diff --git a/Libs/cadquery-lib/.travis.yml b/Libs/cadquery-lib/.travis.yml deleted file mode 100644 index aa8160b..0000000 --- a/Libs/cadquery-lib/.travis.yml +++ /dev/null @@ -1,32 +0,0 @@ -language: python -before_install: -- sudo add-apt-repository -y ppa:freecad-maintainers/freecad-stable -- sudo apt-get update -qq -install: -- sudo apt-get install -y freecad freecad-doc -- gcc --version -- g++ --version -- python ./setup.py install -- pip install -r requirements-dev.txt -- pip install travis-sphinx - -script: -- coverage run --source=cadquery ./runtests.py -- travis-sphinx --nowarn --source=doc build - -after_success: -- coveralls -- travis-sphinx deploy - -branches: - except: - - pythonocc - - 2_0_branch - - deploy: - provider: pypi - user: dcowden - password: - secure: aP02wBbry1j3hYG/w++siF1lk26teuRQlPAx1c+ec8fxUw+bECa2HbPQHcIvSXB5N6nc6P3L9LjHt9ktm+Dn6FLJu3qWYNGAZx9PTn24ug0iAmB+JyNrsET3nK6WUKR1XpBqvjKgdpukd1Hknh2FSzYoyUvFWH9/CovITCFN3jo= - on: - tags: true \ No newline at end of file diff --git a/Libs/cadquery-lib/README.md b/Libs/cadquery-lib/README.md index 8cc0b03..d041e0f 100644 --- a/Libs/cadquery-lib/README.md +++ b/Libs/cadquery-lib/README.md @@ -223,7 +223,11 @@ Use these steps if you would like to write CadQuery scripts as a python API. In ```bash pip install cadquery ``` -3. test your installation:: +4. installing cadquery should install pyparsing as well, but if not:: +```bash + pip install pyparsing +``` +5. test your installation:: ```python from cadquery import * box = Workplane("XY").box(1,2,3) @@ -234,7 +238,7 @@ You're up and running! Installing -- Using CadQuery from Inside FreeCAD ================================================= -Use the Excellent CadQuery-FreeCAD plugin here: +Use the CadQuery module for FreeCAD here: https://github.com/jmwright/cadquery-freecad-module It includes a distribution of the latest version of cadquery. diff --git a/Libs/cadquery-lib/cadquery.egg-info/PKG-INFO b/Libs/cadquery-lib/cadquery.egg-info/PKG-INFO new file mode 100644 index 0000000..823c3bd --- /dev/null +++ b/Libs/cadquery-lib/cadquery.egg-info/PKG-INFO @@ -0,0 +1,154 @@ +Metadata-Version: 1.1 +Name: cadquery +Version: 1.0.0 +Summary: CadQuery is a parametric scripting language for creating and traversing CAD models +Home-page: https://github.com/dcowden/cadquery +Author: David Cowden +Author-email: dave.cowden@gmail.com +License: Apache Public License 2.0 +Description: What is a CadQuery? + ======================================== + + [![Travis Build Status](https://travis-ci.org/dcowden/cadquery.svg)](https://travis-ci.org/dcowden/cadquery) + [![Coverage Status](https://coveralls.io/repos/dcowden/cadquery/badge.svg)](https://coveralls.io/r/dcowden/cadquery) + [![GitHub version](https://badge.fury.io/gh/dcowden%2Fcadquery.svg)](https://github.com/dcowden/cadquery/releases/tag/v0.3.0) + [![License](https://img.shields.io/badge/license-LGPL-lightgrey.svg)](https://github.com/dcowden/cadquery/blob/master/LICENSE) + + CadQuery is an intuitive, easy-to-use python based language for building parametric 3D CAD models. CadQuery is for 3D CAD what jQuery is for javascript. Imagine selecting Faces of a 3d object the same way you select DOM objects with JQuery! + + CadQuery has several goals: + + * Build models with scripts that are as close as possible to how you'd describe the object to a human. + * Create parametric models that can be very easily customized by end users + * Output high quality CAD formats like STEP and AMF in addition to traditional STL + * Provide a non-proprietary, plain text model format that can be edited and executed with only a web browser + + Using CadQuery, you can write short, simple scripts that produce high quality CAD models. It is easy to make many different objects using a single script that can be customized. + + Full Documentation + ============================ + You can find the full cadquery documentation at http://dcowden.github.io/cadquery + + + Getting Started With CadQuery + ======================================== + + The easiest way to get started with CadQuery is to Install FreeCAD (version 14+) (http://www.freecadweb.org/), and then to use our great CadQuery-FreeCAD plugin here: https://github.com/jmwright/cadquery-freecad-module + + + It includes the latest version of cadquery alreadby bundled, and has super-easy installation on Mac, Windows, and Unix. + + It has tons of awesome features like integration with FreeCAD so you can see your objects, code-autocompletion, an examples bundle, and script saving/loading. Its definitely the best way to kick the tires! + + We also have a Google Group to make it easy to get help from other CadQuery users. Please join the group and introduce yourself, and we would also love to hear what you are doing with CadQuery. https://groups.google.com/forum/#!forum/cadquery + + + + Why CadQuery instead of OpenSCAD? + ======================================== + + CadQuery is based on OpenCasCade. CadQuery shares many features with OpenSCAD, another open source, script based, parametric model generator. + + The primary advantage of OpenSCAD is the large number of already existing model libaries that exist already. So why not simply use OpenSCAD? + + CadQuery scripts have several key advantages over OpenSCAD: + + 1. **The scripts use a standard programming language**, python, and thus can benefit from the associated infrastructure. + This includes many standard libraries and IDEs + + 2. **More powerful CAD kernel** OpenCascade is much more powerful than CGAL. Features supported natively + by OCC include NURBS, splines, surface sewing, STL repair, STEP import/export, and other complex operations, + in addition to the standard CSG operations supported by CGAL + + 3. **Ability to import/export STEP** We think the ability to begin with a STEP model, created in a CAD package, + and then add parametric features is key. This is possible in OpenSCAD using STL, but STL is a lossy format + + 4. **Less Code and easier scripting** CadQuery scripts require less code to create most objects, because it is possible to locate + features based on the position of other features, workplanes, vertices, etc. + + 5. **Better Performance** CadQuery scripts can build STL, STEP, and AMF faster than OpenSCAD. + + License + ======== + + CadQuery is licensed under the terms of the Apache Public License, version 2.0. + A copy of the license can be found at http://www.apache.org/licenses/LICENSE-2.0 + + Where is the GUI? + ================== + + If you would like IDE support, you can use CadQuery inside of FreeCAD. There's an excellent plugin module here https://github.com/jmwright/cadquery-freecad-module + + CadQuery also provides the backbone of http://parametricparts.com, so the easiest way to see it in action is to review the samples and objects there. + + Installing -- FreeStanding Installation + ======================================== + + Use these steps if you would like to write CadQuery scripts as a python API. In this case, FreeCAD is used only as a CAD kernel. + + 1. install FreeCAD, version 0.12 or greater for your platform. http://sourceforge.net/projects/free-cad/. + + 2. adjust your path if necessary. FreeCAD bundles a python interpreter, but you'll probably want to use your own, + preferably one that has virtualenv available. To use FreeCAD from any python interpreter, just append the FreeCAD + lib directory to your path. On (*Nix):: + + import sys + sys.path.append('/usr/lib/freecad/lib') + + or on Windows:: + + import sys + sys.path.append('/c/apps/FreeCAD/bin') + + *NOTE* FreeCAD on Windows will not work with python 2.7-- you must use pthon 2.6.X!!!! + + 3. install cadquery:: + + pip install cadquery + + 3. test your installation:: + + from cadquery import * + box = Workplane("XY").box(1,2,3) + exporters.toString(box,'STL') + + You're up and running! + + Installing -- Using CadQuery from Inside FreeCAD + ================================================= + + Use the Excellent CadQuery-FreeCAD plugin here: + https://github.com/jmwright/cadquery-freecad-module + + It includes a distribution of the latest version of cadquery. + + Where does the name CadQuery come from? + ======================================== + + CadQuery is inspired by ( `jQuery `_ ), a popular framework that + revolutionized web development involving javascript. + + If you are familiar with how jQuery, you will probably recognize several jQuery features that CadQuery uses: + + * A fluent api to create clean, easy to read code + * Language features that make selection and iteration incredibly easy + * + * Ability to use the library along side other python libraries + * Clear and complete documentation, with plenty of samples. + + +Platform: any +Classifier: Development Status :: 5 - Production/Stable +Classifier: Intended Audience :: Developers +Classifier: Intended Audience :: End Users/Desktop +Classifier: Intended Audience :: Information Technology +Classifier: Intended Audience :: Science/Research +Classifier: Intended Audience :: System Administrators +Classifier: License :: OSI Approved :: Apache Software License +Classifier: Operating System :: POSIX +Classifier: Operating System :: MacOS +Classifier: Operating System :: Unix +Classifier: Programming Language :: Python +Classifier: Topic :: Software Development :: Libraries :: Python Modules +Classifier: Topic :: Internet +Classifier: Topic :: Scientific/Engineering diff --git a/Libs/cadquery-lib/cadquery.egg-info/SOURCES.txt b/Libs/cadquery-lib/cadquery.egg-info/SOURCES.txt new file mode 100644 index 0000000..0507b5e --- /dev/null +++ b/Libs/cadquery-lib/cadquery.egg-info/SOURCES.txt @@ -0,0 +1,29 @@ +MANIFEST.in +README.txt +setup.cfg +setup.py +cadquery/__init__.py +cadquery/cq.py +cadquery/cq_directive.py +cadquery/cqgi.py +cadquery/selectors.py +cadquery.egg-info/PKG-INFO +cadquery.egg-info/SOURCES.txt +cadquery.egg-info/dependency_links.txt +cadquery.egg-info/not-zip-safe +cadquery.egg-info/top_level.txt +cadquery/contrib/__init__.py +cadquery/freecad_impl/__init__.py +cadquery/freecad_impl/exporters.py +cadquery/freecad_impl/geom.py +cadquery/freecad_impl/importers.py +cadquery/freecad_impl/shapes.py +cadquery/plugins/__init__.py +tests/TestCQGI.py +tests/TestCQSelectors.py +tests/TestCadObjects.py +tests/TestCadQuery.py +tests/TestExporters.py +tests/TestImporters.py +tests/TestWorkplanes.py +tests/__init__.py \ No newline at end of file diff --git a/Libs/cadquery-lib/cadquery.egg-info/dependency_links.txt b/Libs/cadquery-lib/cadquery.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Libs/cadquery-lib/cadquery.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/Libs/cadquery-lib/cadquery.egg-info/not-zip-safe b/Libs/cadquery-lib/cadquery.egg-info/not-zip-safe new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Libs/cadquery-lib/cadquery.egg-info/not-zip-safe @@ -0,0 +1 @@ + diff --git a/Libs/cadquery-lib/cadquery.egg-info/top_level.txt b/Libs/cadquery-lib/cadquery.egg-info/top_level.txt new file mode 100644 index 0000000..2bbe7fc --- /dev/null +++ b/Libs/cadquery-lib/cadquery.egg-info/top_level.txt @@ -0,0 +1,2 @@ +cadquery +tests diff --git a/Libs/cadquery-lib/cadquery/cqgi.py b/Libs/cadquery-lib/cadquery/cqgi.py index 8fa7b0c..d0777a8 100644 --- a/Libs/cadquery-lib/cadquery/cqgi.py +++ b/Libs/cadquery-lib/cadquery/cqgi.py @@ -34,7 +34,6 @@ class CQModel(object): the build method can be used to generate a 3d model """ - def __init__(self, script_source): """ Create an object by parsing the supplied python script. @@ -48,7 +47,7 @@ class CQModel(object): # TODO: pick up other scirpt metadata: # describe # pick up validation methods - self._find_descriptions() + self._find_descriptions() def _find_vars(self): """ @@ -136,6 +135,14 @@ class CQModel(object): p.set_value(v) +class ShapeResult(object): + """ + An object created by a build, including the user parameters provided + """ + def __init__(self): + self.shape = None + self.options = None + class BuildResult(object): """ The result of executing a CadQuery script. @@ -149,8 +156,8 @@ class BuildResult(object): """ def __init__(self): self.buildTime = None - self.results = [] - self.debugObjects = [] + self.results = [] #list of ShapeResult + self.debugObjects = [] #list of ShapeResult self.first_result = None self.success = False self.exception = None @@ -287,18 +294,25 @@ class ScriptCallback(object): self.outputObjects = [] self.debugObjects = [] - def build_object(self, shape): + def build_object(self, shape,options={}): """ - return an object to the executing environment + return an object to the executing environment, with options :param shape: a cadquery object + :param options: a dictionary of options that will be made available to the executing envrionment """ - self.outputObjects.append(shape) + o = ShapeResult() + o.options=options + o.shape = shape + self.outputObjects.append(o) def debug(self,obj,args={}): """ Debug print/output an object, with optional arguments. """ - self.debugObjects.append(DebugObject(obj,args)) + s = ShapeResult() + s.shape = obj + s.options = args + self.debugObjects.append(s) def describe_parameter(self,var_data ): """ @@ -315,15 +329,7 @@ class ScriptCallback(object): def has_results(self): return len(self.outputObjects) > 0 -class DebugObject(object): - """ - Represents a request to debug an object - Object is the type of object we want to debug - args are parameters for use during debuging ( for example, color, tranparency ) - """ - def __init__(self,object,args): - self.args = args - self.object = object + class InvalidParameterError(Exception): """ diff --git a/Libs/cadquery-lib/doc/cqgi.rst b/Libs/cadquery-lib/doc/cqgi.rst index 310f7d2..84a3602 100644 --- a/Libs/cadquery-lib/doc/cqgi.rst +++ b/Libs/cadquery-lib/doc/cqgi.rst @@ -37,6 +37,9 @@ CQGI compliant containers provide an execution environment for scripts. The envi Scripts must call build_output at least once. Invoking build_object more than once will send multiple objects to the container. An error will occur if the script does not return an object using the build_object() method. +An optional options dictionary can be provided to the build_object method. If provided, it is passed onto the executing environment, and is used to render the object. Typically, this will be colors, transparency, and other visual affects. + + This CQGI compliant script produces a cube with a circle on top, and displays a workplane as well as an intermediate circle as debug output:: base_cube = cq.Workplane('XY').rect(1.0,1.0).extrude(1.0) @@ -47,7 +50,7 @@ This CQGI compliant script produces a cube with a circle on top, and displays a circle=top_of_cube_plane.circle(0.5) debug(circle, { 'color': 'red' } ) - build_object( circle.extrude(1.0) ) + build_object( circle.extrude(1.0),{"color": "#aaaaaa" ) Note that importing cadquery is not required. At the end of this script, one object will be displayed, in addition to a workplane, a point, and a circle diff --git a/Libs/cadquery-lib/tests/TestCQGI.py b/Libs/cadquery-lib/tests/TestCQGI.py index 7cc967f..08c63dc 100644 --- a/Libs/cadquery-lib/tests/TestCQGI.py +++ b/Libs/cadquery-lib/tests/TestCQGI.py @@ -48,10 +48,11 @@ class TestCQGI(BaseTest): result = model.build() debugItems = result.debugObjects self.assertTrue(len(debugItems) == 2) - self.assertTrue( debugItems[0].object == "bar" ) - self.assertTrue( debugItems[0].args == { "color":'yellow' } ) - self.assertTrue( debugItems[1].object == 2.0 ) - self.assertTrue( debugItems[1].args == {} ) + + self.assertTrue( debugItems[0].shape == "bar" ) + self.assertTrue( debugItems[0].options == { "color":'yellow' } ) + self.assertTrue( debugItems[1].shape == 2.0 ) + self.assertTrue( debugItems[1].options == {} ) def test_build_with_empty_params(self): model = cqgi.CQModel(TESTSCRIPT) @@ -59,12 +60,12 @@ class TestCQGI(BaseTest): self.assertTrue(result.success) self.assertTrue(len(result.results) == 1) - self.assertTrue(result.results[0] == "2.0|3.0|bar|1.0") + self.assertTrue(result.results[0].shape == "2.0|3.0|bar|1.0") def test_build_with_different_params(self): model = cqgi.CQModel(TESTSCRIPT) result = model.build({'height': 3.0}) - self.assertTrue(result.results[0] == "3.0|3.0|bar|1.0") + self.assertTrue(result.results[0].shape == "3.0|3.0|bar|1.0") def test_describe_parameters(self): script = textwrap.dedent( @@ -128,8 +129,8 @@ class TestCQGI(BaseTest): model = cqgi.CQModel(script) result = model.build({}) self.assertEquals(2, len(result.results)) - self.assertEquals(1, result.results[0]) - self.assertEquals(2, result.results[1]) + self.assertEquals(1, result.results[0].shape) + self.assertEquals(2, result.results[1].shape) def test_that_assinging_number_to_string_works(self): script = textwrap.dedent( @@ -139,7 +140,7 @@ class TestCQGI(BaseTest): """ ) result = cqgi.parse(script).build( {'h': 33.33}) - self.assertEquals(result.results[0], "33.33") + self.assertEquals(result.results[0].shape, "33.33") def test_that_assigning_string_to_number_fails(self): script = textwrap.dedent( @@ -181,7 +182,7 @@ class TestCQGI(BaseTest): result = cqgi.parse(script).build() self.assertTrue(result.success) - self.assertIsNotNone(result.first_result) + self.assertIsNotNone(result.first_result.shape) def test_setting_boolean_variable(self): script = textwrap.dedent( @@ -195,7 +196,7 @@ class TestCQGI(BaseTest): result = cqgi.parse(script).build({'h': False}) self.assertTrue(result.success) - self.assertEquals(result.first_result,'*False*') + self.assertEquals(result.first_result.shape,'*False*') def test_that_only_top_level_vars_are_detected(self): script = textwrap.dedent( @@ -213,4 +214,4 @@ class TestCQGI(BaseTest): model = cqgi.parse(script) - self.assertEquals(2, len(model.metadata.parameters)) \ No newline at end of file + self.assertEquals(2, len(model.metadata.parameters))