Title: ScadInterface · Issue #181 · SolidCode/SolidPython · GitHub
Open Graph Title: ScadInterface · Issue #181 · SolidCode/SolidPython
X Title: ScadInterface · Issue #181 · SolidCode/SolidPython
Description: #scad_interface.py from .solidpython import OpenSCADObject class ConstantOpenSCADObject(OpenSCADObject): def __init__(self, code): super().__init__("not valid openscad code !?!?!", {}) self.code = code def _render(self, render_holes=42):...
Open Graph Description: #scad_interface.py from .solidpython import OpenSCADObject class ConstantOpenSCADObject(OpenSCADObject): def __init__(self, code): super().__init__("not valid openscad code !?!?!", {}) self.code = ...
X Description: #scad_interface.py from .solidpython import OpenSCADObject class ConstantOpenSCADObject(OpenSCADObject): def __init__(self, code): super().__init__("not valid openscad code !?!?!", {}) se...
Opengraph URL: https://github.com/SolidCode/SolidPython/issues/181
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ScadInterface","articleBody":"```python\r\n#scad_interface.py\r\nfrom .solidpython import OpenSCADObject\r\nclass ConstantOpenSCADObject(OpenSCADObject):\r\n def __init__(self, code):\r\n super().__init__(\"not valid openscad code !?!?!\", {})\r\n self.code = code\r\n\r\n def _render(self, render_holes=42):\r\n return self.code\r\n\r\nclass ScadInterface:\r\n def __init__(self):\r\n self.header = ''\r\n\r\n def register_customizer_var(self, name, value, options=''):\r\n self.header += f'{name} = {value}; //{options}\\n'\r\n\r\n def set_global_var(self, name, value):\r\n self.header += f'{name} = {value};\\n'\r\n\r\n def get_header_str(self):\r\n return self.header\r\n\r\n def register_font(self, filename):\r\n self.header += f'use \u003c{filename}\u003e\\n'\r\n\r\n @staticmethod\r\n def get(name):\r\n return self.inline(name)\r\n\r\n @staticmethod\r\n def inline(code):\r\n return scad_inline(code)\r\n\r\ndef scad_inline(code):\r\n return OpenSCADConstant(code)\r\n\r\n#scad_render\r\ndef scad_render(root, file_header = '', scad_interface=None):\r\n [...]\r\n if scad_interface != None:\r\n file_header += scad_interface.get_header_str()\r\n\r\n return file_header + includes + scad_body \\\r\n + extensions_footer_str\r\n\r\n```\r\n\r\nThese 50 lines are able to close #180, #178, #165 and #61.\r\n\r\nIf possible I would **not** let OpenSCADConstant inherit from OpenSCADObject and use duck typing instead. But since the master is full of \"typing-stuff\" I'm afraid it'll crash it.\r\n\r\nExample usage of the Interface:\r\n[customizer support](https://github.com/jeff-dh/SolidPython/blob/exp_solid/solid/examples/10-customizer.py)\r\n[fonts](https://github.com/jeff-dh/SolidPython/blob/exp_solid/solid/examples/11-fonts.py)\r\n[animation](https://github.com/jeff-dh/SolidPython/blob/exp_solid/solid/examples/12-animation.py)\r\n\r\nThis can also be used to set global `$fn, $fa, $fs`.\r\n\r\nAnd I guess it would make the `header` parameter for `scad_render` obsolete, right?\r\nAny thing else you would like to *inject* into the header can be done trough the `ScadInterface`.","author":{"url":"https://github.com/jeff-dh","@type":"Person","name":"jeff-dh"},"datePublished":"2021-06-01T22:50:45.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/181/SolidPython/issues/181"}
| 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:7131eea2-8468-29a5-d654-843be72a39df |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D928:D7362:E5F38E:13557DC:696ACC7D |
| html-safe-nonce | 378612279850b44e04fd7518d1d3842b3e1a8273f6ddeada146a9a689334cb30 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTI4OkQ3MzYyOkU1RjM4RToxMzU1N0RDOjY5NkFDQzdEIiwidmlzaXRvcl9pZCI6IjIwNzcxNTYwNjcyOTUxMDAxMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 28c4fe26c8a14b1e44cb0af46dbea0d3380c647e335472a6b8653bef4d5bf342 |
| hovercard-subject-tag | issue:908792245 |
| 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/181/issue_layout |
| twitter:image | https://opengraph.githubassets.com/13f3dd5d898e093459643cc2a8d715c4614d847b1770b74978cc63a6fed8123b/SolidCode/SolidPython/issues/181 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/13f3dd5d898e093459643cc2a8d715c4614d847b1770b74978cc63a6fed8123b/SolidCode/SolidPython/issues/181 |
| og:image:alt | #scad_interface.py from .solidpython import OpenSCADObject class ConstantOpenSCADObject(OpenSCADObject): def __init__(self, code): super().__init__("not valid openscad code !?!?!", {}) self.code = ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jeff-dh |
| hostname | github.com |
| expected-hostname | github.com |
| None | c785f4ce187e9e7331257791b36ddee01625bb8e292a9b4fe2c16d4c006abf5d |
| 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 | c718a376fcf780eb22089171adb84a543f660bf7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width