In this chapter, we're going to create our first assembly. In this example, we will use the flange part from the chapter before to create an assembly. We will add the flange twice to the assembly and add a bolt and a nut. Both parts come from a library and already contain coordinate systems for assembling. Create a copy of templateCreator.ts in the history folder and name it.
So let's start coding!
- Create the root assembly and load products
- Add the products to the assembly
- Adding constraints to the instances
First, we create an empty assembly; it will be the root assembly. As explained in the beginning, we will add the flange twice, then a bolt and a nut. So we need to load these products into the assembly as arraybuffer. The bolt and the nut can be found in buerli-examples in the folder client/src/resources/history/Flange. Next, add the flange part saved in native file format to this directory. Use the following snippet in your template.
You won't see anything on the screen; we just loaded the products but didn't add any instance yet. So let's go to the next chapter.
Next, we add two instances of the flange part, then an instance of the bolt, and finally a nut instance to the assembly. We then retrieve the necessary work coordinate systems (WCS) from the parts to connect the instances using 3d constraints. Coordinate systems, also called mates, are used for positioning the instances in the assembly relative to each other. Copy the following code snippet to your template.
As result you should see the following graphics. All instances have been added to the origin. We can't even see the two flanges, because they have exactly the same position.
As you probably expect, we have to fix the postions by adding constraints to the instances.
Depending on the constraints we set, the instances will have different degrees of freedom. In our example we will simply use the fastened origin and the fastened constraint. We will follow the next steps to constrain the whole assembly.
- Create a fastened origin constraint to fasten the first flange to the origin
- Create a fastened constraint between the first and the second flange
- Create a fastened constraint between the bolt and the first flange
- Create a fastened constraint between the nut and the second flange
Now we should have an assembly which is fully constrained. Save the assembly like we did with the part and open it in buerligons to see what we have created.