Skip to content

Manual assembly system enhancement #543

@bernhard-42

Description

@bernhard-42

@adam-urbanczyk @jmwright
We discussed the topic of nested assemblies in #522 and I think since you started to merge #538 this will be part of the next release.

I thought it might be easier no to open a new issue to discuss the manual assemblies I introduced in #522

I took your door tutorial (added "door" as the name to the top level hierarchy to not have to deal with uuids) and used my manual approach to assemble it:

from collections import OrderedDict as odict

# add mates to the ends of the vslots
for v in ["bottom", "left", "top", "right"]:
    door.mate(f"door/{v}@faces@>Z", name=f"{v}_0", transforms=odict(rx=180))
    door.mate(f"door/{v}@faces@<Z", name=f"{v}_1", transforms=odict(rx=180))

# add mates to the connectors
for c in ["con_tl", "con_tr", "con_br", "con_bl"]:
    door.mate(f"door/{c}?X", name=f"{c}_0", transforms=odict(rz=90))
    door.mate(f"door/{c}?Z", name=f"{c}_1") 

# add mates to bottom vslot and panel
door.mate("door/panel@faces@<Z", name="panel_0", transforms=odict(rx=180, rz=90))
door.mate("door/bottom@faces@>X[-4]", name="panel_1")

# add mates to handle and one hole
door.mate("door/handle?mate1", name="handle_0")
door.mate("door/panel?hole1", name="handle_1", transforms=odict(rz=-90))

For better visibility I have spread the objects:

image

Given these mates, one can now assemble the door like one would do it in reality:

door.assemble("bottom_0", "con_bl_0")    # add bottom vslot to bottom-left connector
door.assemble("con_br_1", "bottom_1")    # add bottom-right connector to bottom vslot
door.assemble("left_1",   "con_bl_1")    # add left vslot to bottom-left connector
door.assemble("right_0",  "con_br_0")    # add right vslot to bottom-right connector
door.assemble("panel_0",  "panel_1")     # add panel
door.assemble("con_tl_0", "left_0")      # add top-left connector to left vslot
door.assemble("con_tr_1", "right_1")     # add top-right connector to right vslot
door.assemble("top_1",    "con_tl_1")    # add top vslot to top-left connector
door.assemble("handle_0", "handle_1")    # add handle

By the way, since I don't want to use Threejs animation system, there is no need to relocate the objects.

Full code can be found here

Would you be interested in a pull request? It would be the file mate.py and the methods

  • mate
  • _relocate
  • relocate
  • assemble

from massembly.py plus two properties: mates and _origin_mate

The methods mate and assemble are the core methods used in the example above. Of course, one could combine mate and assemble so that assemble gets both mate definitions, however, for me it has proven helpful to split these steps to visually analyse the mates (location and orientation) before doing the final assembly

Note: _origin_mate plus _relocate and relocate are only needed to shift the objects in space to allow the hierarchical threejs system to rotate/translate appropriately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions