Buffer Exchange

In the latest LPub3D version 2.4 this feature is completely revised and now called Build Modifications. Detailed documentation will follow as soon as v2.4.1 is available which should solve some bugs in this new feature.

To understand how to use Buffer Exchange you can best study the LDraw source code.

To use red arrows like shown in the original instruction image below, you can download and install these in your LDraw library. How this is done is explained in the lesson Using custom parts.

You will now learn how to recreate the step as shown below.

Original instructions image © LEGO®

Buffer Exchange is not specifically an LPub3D feature but originally introduced in MLCad, one of the first next-generation LDraw editors. Some other LDraw software, like the modern generation editor LDCad, does support it too.

The way it works is illustrated here:

  • The white 2x2 plate is in the correct place

  • The hovering 1x2 dark bluish grey plate and 2 red arrows in step 1 in the callout of the submodel are rendered and stored in the buffer

  • In step 2 this buffer is restored to where the 1x2 plate has to be in this step and the 2 arrows are removed

  • In step 2 one of the blue 1x3 curved bricks and the red arrow are stored

  • The third step is not shown but is in fact removing the hovering 1x3 brick, putting it at the correct position, and removes the red arrow.

To understand how this is done in LDraw and thus rendered in LPub3D read on:

  • Download the prepared LDraw file with arrows and Buffer Exchange here.

  • Go to page 19

  • Note that the PLI count is incorrect and that submodel in the callout has 3 steps

  • To hide the third step, right-click on the assembly image of step 3 and choose <Don't Show This Page>

  • This will in fact not render the 3rd step in the callout

  • Correct the callout pointer by clicking on the handle and reattach it to the border of the callout

  • Left-click the assembly image of step 1 to "zoom in" on the code of this submodel

Study this piece of code to understand the working of Buffer Exchange:

  • Line 6 means start storing all parts after this line in the buffer until the STEP command is reached. The bricks you want to store should always be at the last line(s) of the LDraw code in the active step

  • Line 7 is the dark bluish grey 1x2 plate hovering above the white 2x2 plate (line 5)

  • Included in the buffer are the (red) arrow helper parts HasvL2 (lines 8 and 9)

  • Then in line 11, right after the step in line 10 retrieve the buffer and render the assembly with the parts following this line. In this case, only line 12 and 13.

  • In line 12 the 1x2 plate is in place

  • Again, in line 14 store the hovering dark azure curved 1x3 brick (line 15) in the buffer

  • Line 18 tells LPub3D not to render the last step (which was explained above)

  • Line 19 retrieves the buffer again and renders the assembly with all parts in place (in line 20 the 1x3 curved brick is in place)

Now note that the part count in the PLI is not right. To correct this you should exclude the bricks that are retrieved by the buffer exchange. The easiest way is to hide the bricks and remove the code from the bricks that need to be counted in the PLI.

  • Right click the azure blue 1x3 curved brick in the PLI and choose <Hide Part from Parts List>

  • Left click the assembly image of step in in the callout again to show the LDraw code

  • Delete lines 13 and 17 (0 !LPUB PLI BEGIN IGN) and line 15 and 19 (0 !LPUB PLI END) from the code

  • Refresh the page by navigating one page forward and back

  • Do the same for one of the 1x2 plates

  • The code and the layout of the page should now resemble something like shown below

Note lines 12 to 14 and lines 22 to 24. These say to ignore (IGN) the brick(s) enclosed by the Begin and End command. In other words read line 12 like "LPub should not count the following bricks in the PLI" and line 14 says "Stop ignoring previous bricks and start counting following bricks again in the PLI".

The same goes for lines 22 and 24. These commands also make sure the ignored bricks are not counted in the BOM.

Multiple buffers and buffers over more the one step

Even more advanced is the usage of a buffer exchange with multiple buffers or over more than one step.

These techniques are used in the showcase model of set 42061.

Multiple buffers on page 49

More than one step on page 51