[Program Object] Photocopier

Overview

The is a quick and effective program object that will clone objects (components) from location to many locations.

image

:file_folder: Photocopier.bog (17.8 KB)

How to use the Photocopier?

It’s really simple. First paste the bog that contains the program object somewhere in your station. The location really isn’t very important, just make sure you know where to find it later!

Self-Sign the Photocopier

If you’re using a version greater than 4.8 you will be required to sign all program object before they can be executed in the station.

Right-Click -> Views -> Program Editor

image

Next click the save and compile icon and follow the prompts.

:warning: I am not covering creating self-signed certificates in this guide, this will come in the form of its own guide soon.

image

If successful, you will now see a green dot

image

Photocopier Configuration

It is very simple, there are two ord slots:

  • compToCopy: In this slot enter the ord of the component you’d like to copy. A component is anything that extends BComponent and therefore is not limited to a single point. In fact the best usecase for the Photocopier is copying an entire folder of logic to many folders.

    • By Default, when the compToCopy is duplicated all incoming links are retained. You could disable this by editing this line params.add("keepAllLinks", (BValue) BBoolean.make(true)); and setting the BBoolean to false.
  • copyTo: In this slot enter the Ord or BQL Query of where you want to copy the compToCopy too.

    • Note: If the useQuery boolean is set false, the copyTo Ord must be the absolute ord of the target. In most cases you will be bulk copying logic from on location to many and will be using BQL to return the target ords. useQuery must be set true in order for BQL to work.

Once you have configured the photocopier, Right-click and invoke the action photocopy.

Example

In this example I have 6 Air Handling Unit folders and a Template folder. The template folder is a duplicate of the Air Handling folder. In here I’m going to introduce some new logic that I want to copy to all my other Air Handlers.

Right-click and open image in new tab to view the gif in full screen.

photocopier

:partying_face: As simple as that we have copied a folder of logic to many folders! Notice that the position of the of the component on the wiresheet is also duplicated.

Now you’re probably asking yourself. @Giantsbane this is great, but the logic is pretty useless if nothing is linked to it.

Well kids, I have a program for automating the linking too which I’ll link here once I’ve written a guide.

3 Likes

Very interesting. Assuming it’s possible, would there be any merit in turning this into a component?

Over time some of these will be included in the module as a plugin engineering tools. I have many programs for different bulk tasks, however time is of the essence. Currently the focus is getting the core module built and continuing with the skill labs. If we get some more contributors onboard that will free me up :smiley:

1 Like

I’m sure as my skills progress these tools to reduce manual input will become more and more important. Thank you for access to this tool. Of course, when I saved and compiled, the radio button did not stay red or turn green, it turned yellow! I’m sure it’s the curse of being a beginner.

After 4.8 Niagara started enforcing code-signing. Which is a way of validating that the code came from who it says it does… and that it is trusted. In Niagara, you can create yourself a self-signed code-signing certificate to get around this. Alternatively, one could pay for a code-signing certificate. But they aint cheap!

This is certainly a guide I’m wanting to write when I get the time :slight_smile: so stay tuned.

1 Like

I’m happy to work on making this into a component in its own right.

Can the keepAllLinks option be user selectable in the same way as the useQuery?

1 Like

Everyone is welcome and encouraged to contribute :slight_smile: If your up to the task please go for it!.

100%, it takes a BBoolean value. This could just be another property on the component that can be toggled, like the useQuery.

So I found some time and managed to convert this to a component module and add the ‘keepAllLinks’ as a option :grinning:

Will likely add it to my build at some point.

1 Like