Best practice for hierarchial design
See original GitHub issueI have migrated a design for a coffeetable from plain freecad python script into a cadquery/cqparts script.
I wonder what the best practice is to pass values between parts in an assembly.
Some of the dimensions for the parts depend on each other. The coffee table assembly needs only length, width and height but calculates some other variables that are used for other parts of the table.
When I did the design I studied your ball bearing script in parallell. You collect variables for the ball bearing assy like so:
outer_diam = PositiveFloat(30, doc="outer diameter")
and then you pass them to the components, like so:
def make_components(self):
return {
'outer_ring': _Ring(
outer_radius=self.outer_diam / 2,
inner_radius=(self.outer_diam / 2) - self.outer_width,
width=self.width,
ball_radius=(self.ball_diam / 2) + self.tolerance,
rolling_radius=self.rolling_radius,
),
and then the subcomponents need to collect the variables again in the same way as the assembly did.
outer_radius = PositiveFloat(10, doc="outside radius")
Doesnt this feel like duplicated effort?
Wouldnt it be possible for a subcomponent to get the variables directly from the parent?
My suggestion is to use for example super.outer_diam
in the subcomponent, is there something inherently bad with this approach?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (7 by maintainers)
Top GitHub Comments
@fragmuffin I have now uploaded the design files for the coffee table I mentioned to here https://github.com/gnhdesign/ct1
I have also written a blog post about it on my website https://www.gntech.se/en/projects/ct1/
@gntech that is so cool!