Skip to content

How to create assemblies with empty spacing (fillers) between parts? #868

@alikureishy

Description

@alikureishy

I won't go into too much detail about why I need this, but I am looking to create an assembly wherein a couple of the parts are separated by empty spaces (i.e, not connected to other parts). If it was possible to create a virtual 3D part that could be used purely as a filler, but not get embedded into the final assembly's toCompound() method, that would have been ideal, but I couldn't find any way to do that (Maybe I missed something?).

To elaborate, here's an example. Let's say I'd like to add two rectangular solids -- 'a' and 'b' -- to my assembly, and make them stand straight, with some space between them (i.e, not in direct contact), as below:
image

One way that seems to work (though not very convenient) is by adding a 2D shape (let's call it 'spacing') with pending edges into the assembly, and then mating that spacing's vertices with parts 'a' and 'b' in such a way as to create that separation. For example:

a = cq.Workplane("XY").rect(xLen=1, yLen=2).extrude(5)
b = cq.Workplane("XY").rect(xLen=2, yLen=1).extrude(10)
spacing = cq.Workplane("XY").rect(xLen=3, yLen=2, forConstruction=True)

# Tagging a and b
a.faces("<X").tag("attach")
b.faces(">X").tag("attach")

# Tagging vertices and edges of the spacing
spacing.vertices(">X and <Y").tag("left_vertex")
spacing.vertices("<X and >Y").tag("right_vertex")
spacing.edges("|Y and >X").tag("left_side")
spacing.edges("|Y and <X").tag("right_side")

assembly = (
    cq.Assembly(a, name="a", color=cq.Color("red"))
        .add(b, name="b", color=cq.Color("green"))
        .add(spacing, name="spacing", color=cq.Color("blue"))
)

(
    assembly
    .constrain("spacing?left_vertex", "a?attach", "PointInPlane")
    .constrain("spacing?right_vertex", "b?attach", "PointInPlane")
    .constrain("a?attach", "spacing?left_side", "Axis")
    .constrain("b?attach", "spacing?right_side", "Axis")
)
assembly.solve()

This creates the assembly shown above, without including the 2D part. However, it is a convoluted process and seems more like a hack. For more complex spacing requirements, such reliance on pending 2D objects would become messy. Furthermore, I'd consider it even more messy to have to specify absolute locations (in WCS) to mimic that spacing between parts.

So:

  • Are there any cleaner and more powerful/expressive mechanisms available to achieve the same thing? Maybe using 3d objects as fillers to mate with the real parts (without including the fillers into the assembly's output)?
  • If I'd have to write a custom constraint, is there any documentation about how to extend constraints? Constraint extensibility, particularly in relation to its use by the assembly solver -- isn't documented anywhere, and the code isn't straightforward.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions