GithubHelp home page GithubHelp logo

Comments (7)

jmwright avatar jmwright commented on June 18, 2024 1

@cactorium You could consider developing this as a plugin. https://github.com/CadQuery/cadquery-plugins

from cadquery.

cactorium avatar cactorium commented on June 18, 2024 1

Well, I ended up with this in case anyone wants to take a look/give feedback: https://github.com/cactorium/cadquery-plugins/blob/main/plugins/localselectors/localselectors.py I'll work on cleaning it up over the weekend and seeing if it could be added to cadquery-plugins

from cadquery.

adam-urbanczyk avatar adam-urbanczyk commented on June 18, 2024

Not planned, but you can relatively easily implement custom selectors. Some examples can be found here: https://github.com/michaelgale/cq-kit/blob/master/cqkit/cq_selectors.py

Also, based on your description I'm not sure that this would be optimal. Did you look into assemblies and constraints?

from cadquery.

cactorium avatar cactorium commented on June 18, 2024

Yeah I've thought about using constraints, but that seems more heavy-handed than necessary for my use case; I know exactly how each part needs to bolt onto the others so it's been really easy just to pass workplanes around instead of trying to set up constraints, my code basically boils down to something like:

class BaseStruct:
  def __init__(self, w):
    self.solid = ....
    self.wp_face = ....

def StackableThing:
  def __init__(self, w):
    self.solid = ....
    self.wp_face1 = ...
    self.wp_face2 = ....

b = Base(cq.Workplane())
s1 = StackableThing(b.wp_face1)
s2 = StackableThing(b.wp_face2)
s3 = StackableThing(s2.wp_face2)

Thanks for the link! Would there be any interest in adding such a feature? I'd be willing to work on it, if not I'll probably write some rough selectors just to use for myself

from cadquery.

adam-urbanczyk avatar adam-urbanczyk commented on June 18, 2024

I still think that you are approaching it in a sub-optimal way. If you know exactly the desired locations, you can use static assemblies and specify the locations. NB: you can add sub-assemblies to an assembly and thus compose the relative locations. Alternatively, you can compose the locations themselves.

If you still want some use-case specific selectors, simply develop it as a separate project (like cq-kit).

from cadquery.

cactorium avatar cactorium commented on June 18, 2024

Thank you guys for the feedback, I'll write a plugin for it

from cadquery.

adam-urbanczyk avatar adam-urbanczyk commented on June 18, 2024

@cactorium if you really think you need this, IMO this would be the best way to approach such a functionality.

Selectors are not specific to cq.Workplane (they are also used by cq.Shape, cq.Sketch and cq.Assembly), so probably it is better to define a special method(s)/kw arg specifically for cq.Workplane that would apply inverse location of the current workplane, do the selection, and than reapply the original location again to the selected objects. This way you would not need to modify all the existing selectors.

from cadquery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.