Title: Feature Request: Some way to inline literal OpenSCAD code · Issue #178 · SolidCode/SolidPython · GitHub
Open Graph Title: Feature Request: Some way to inline literal OpenSCAD code · Issue #178 · SolidCode/SolidPython
X Title: Feature Request: Some way to inline literal OpenSCAD code · Issue #178 · SolidCode/SolidPython
Description: With the impending arrival (fingers crossed) of Customizer support for #61, some features of SolidPython won't play nicely with customizer values. For example: from solid import cube, scad_render_to_file from solid.utils import right fro...
Open Graph Description: With the impending arrival (fingers crossed) of Customizer support for #61, some features of SolidPython won't play nicely with customizer values. For example: from solid import cube, scad_render_t...
X Description: With the impending arrival (fingers crossed) of Customizer support for #61, some features of SolidPython won't play nicely with customizer values. For example: from solid import cube, scad_rend...
Opengraph URL: https://github.com/SolidCode/SolidPython/issues/178
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Feature Request: Some way to inline literal OpenSCAD code","articleBody":"With the impending arrival (fingers crossed) of Customizer support for #61, some features of SolidPython won't play nicely with customizer values. For example:\r\n\r\n``` python\r\nfrom solid import cube, scad_render_to_file\r\nfrom solid.utils import right\r\nfrom solid.customizer import CustomizerSliderFloat\r\nobject_count = CustomizerSlider('objects', 2, 1, 10, step=1)\r\nside = 2\r\nobjs = [right(2*i*side)(cube(side)) for i in range(object_count)] # we want this to use a reactive slider value but it can't :-/\r\nall_objs = union()(objs)\r\nscad_render_to_file(all_objs, 'customizer_fail.scad')\r\n\r\n```\r\n\r\nThis will create an OpenSCAD file with a slider, `objects` from 1 to 10. But, because the list comprehension (`objs = [right(...]`) happens only in Python code, the SCAD file will only use the initial value of the slider no matter how a user changes the slider in OpenSCAD. \r\n\r\nIf we want a row of cubes that reacts to the OpenSCAD slider, we need to run the object connection loop in OpenSCAD itself. One way to do this would be a dedicated `scad_loop()` function we could add. But we might also add a `scad_inline()` function that would just paste an OpenSCAD string directly into the output `.scad` file without translating at all. That should make us able to use Customizer values anywhere, however we like. \r\n\r\nProposed fix: \r\n``` python\r\nfrom solid import cube, scad_render_to_file, scad_inline\r\nfrom solid.utils import right\r\nfrom solid.customizer import CustomizerSliderFloat\r\nobject_count = CustomizerSlider('objects', 2, 1, 10, step=1)\r\nside = 2\r\nobjs = scad_inline('''\r\nfor (i = [1:objects]){\r\n translate([2*i*side,0,0]){\r\n cube(side);\r\n }\r\n}\r\n''')\r\n\r\nall_objs = union()(objs)\r\nscad_render_to_file(all_objs, 'customizer_fail.scad')\r\n\r\n```\r\n\r\nI'm not sure how I should build this yet, but I don't think it should take *too* much work\r\n\r\n\r\n","author":{"url":"https://github.com/etjones","@type":"Person","name":"etjones"},"datePublished":"2021-05-30T23:34:55.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/178/SolidPython/issues/178"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:0a641be1-c0c4-4fcd-e79c-653ee5714643 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CC94:10503:68EA5A:86AF64:696AEA05 |
| html-safe-nonce | 3866829ebaa5e8a98b6fb90cd7f840486ea142d8cc88585c0756e378dcf1ac8d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQzk0OjEwNTAzOjY4RUE1QTo4NkFGNjQ6Njk2QUVBMDUiLCJ2aXNpdG9yX2lkIjoiMzA2NDEyMjkxNDQ3NTAxMDU2NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c4d19466f7d236543beed1ddcfe5bef5a2ac0931ff1a4e692f8598a5d56b760a |
| hovercard-subject-tag | issue:906915153 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/SolidCode/SolidPython/178/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1caa38fe5a27d3e1577c11b2d2b8807d23f90828107318233c9645f25731ca1b/SolidCode/SolidPython/issues/178 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1caa38fe5a27d3e1577c11b2d2b8807d23f90828107318233c9645f25731ca1b/SolidCode/SolidPython/issues/178 |
| og:image:alt | With the impending arrival (fingers crossed) of Customizer support for #61, some features of SolidPython won't play nicely with customizer values. For example: from solid import cube, scad_render_t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | etjones |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/SolidCode/SolidPython git https://github.com/SolidCode/SolidPython.git |
| octolytics-dimension-user_id | 622839 |
| octolytics-dimension-user_login | SolidCode |
| octolytics-dimension-repository_id | 1377446 |
| octolytics-dimension-repository_nwo | SolidCode/SolidPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1377446 |
| octolytics-dimension-repository_network_root_nwo | SolidCode/SolidPython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width