3 ms·
Tell me. How has software engineering solved a long time ago how to select the single segment shown here? The one marked yellow is selected. https://i.imgur.com
by injidup 5y ago
Tell me. How has software engineering solved a long time ago how to select the single segment shown here? The one marked yellow is selected. https://i.imgur.com/rbGDsvF.png https://i.imgur.com/rbGDsvF.png I just picked this with my mouse within OnShape and it took me one only second to robustly pick it.
If you look under the hood as see how OnShape generates robust picking selectors it is not something you really want to try coding by hand. You can do it but it is non trivial.
Read
https://www.onshape.com/en/resource-center/tech-tips/tech-tip-how-to-use-query-explorer-in-featurescript https://www.onshape.com/en/resource-center/tech-tips/tech-ti...
and
https://cad.onshape.com/FsDoc/library.html#module-query.fs https://cad.onshape.com/FsDoc/library.html#module-query.fs
if you want to learn more how it is done. It is super awesome but not trivial to use.
Featurescript is designed to be used in within a GUI environment where you pick something specific and then a new custom feature is added to the feature tree. It is a hybrid code / no-code solution. The end user still performs the typical pick and configure workflow.
- duped 5y agoTypically we'd call this feature "goto definition"
- injidup 5y agoAnd how would you implement "Goto definition?" For a line segment that you didn't directly create and is an incidental artifact of a sequence of CSG operations. The line segment is not "defined" like a variable. There is no line in the code that gives you a declaration. It is a build artifact.
- duped 5y agoWith a table that stores the source locator of the operation that generated the visualization and a program to query this table. A rendering is not a build artifact except in the purest sense, it's just a different view into the source code. If you want to transition back to code you store the information required for it, it's not terribly difficult. Another analogous feature is setting a breakpoint. They're not exactly equivalent, but depending on how the visualization is treated by the programming environment it covers what you're talking about.
- injidup 5y agoOh. You mean with a vtable. Like with OO languages and virtual functions. And it would be just like that except perhaps with borrow checking. ,#rust
- duped 5y agoNot really, vtables are a way to implement dynamic dispatch. A "table" is just a key/value store (in a vtable, the key is a function/method identifier and the value is the function itself). In this case the key is the geometry and the value is the code that created it. But the real trick is to make sure the opposite is true, so you can go from code -> visualization and visualization -> code without a ton of difficulty.
- injidup 5y agoVtables are the digital analogue of signed distance fields. That is the trick. Rust gets this right. It is why most rust developers use text editors instead of UML diagrams. We can do the same with CAD. Instead of using a transformer network put the whole geometric inversion in level 1 cache and dispatch through the vtable. The borrow checker does the rest for you. No need to use the mouse anymore. The geometry inversions are now just a keyboard press away.
- duped 5y agoRust doesn't use vtables by and large - like I said it's a technique for implementing dynamic dispatch (call a function with a different implementation based on the type of one argument, aka single dispatch). Notably, Rust does not rely on it for most cases (Rust uses type classes aka traits which are monomorphized - unless you explicitly use the `dyn` keyword to use a vtable implementation that incurs a slight performance penalty). Not sure what they have to do with signed distance fields. It's just an implementation detail for single dispatch. What's the analog?
- injidup 5y ago
- phkahler 5y agoThe definition isn't explicit. That curve - and several other - is the result of a single CSG operation. It might be possible to describe it in terms of the things that generated it, but that's way harder to do than selecting it with a mouse.
- duped 5y agoYou wouldn't replace clicking stuff with a mouse?