Skip to content
  • Categories
Collapse
Solibri Society Forum
  1. Home
  2. General Discussion
  3. Solibri API - Solibri JavaScript API

Solibri API - Solibri JavaScript API

Scheduled Pinned Locked Moved General Discussion
1 Posts 1 Posters 134 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • MattiM Offline
    MattiM Offline
    Matti Solibrians
    wrote last edited by
    #1

    Solibri API - Solibri JavaScript API

    Solibri provides a JavaScript API that allows you to extend the functionality of Solibri products.
    This document outlines how to use the JavaScript API in different contexts, including Information Takeoff and Hyperlink Templates.
    Solibri’s JavaScript API is designed to be used with Solibri Office and Solibri Site.
    Solibri uses Mozilla Rhino JavaScript engine to run the scripts.

    License Requirements

    To use the JavaScript API, you must have a valid license for the Solibri product you are using.
    Editing and running scripts with the Solibri JavaScript API requires a Solibri Office license.

    How to use the JavaScript API in Information Takeoff

    1. Open the Information Takeoff view in Solibri Office.
    2. Create a new Information Takeoff or open an existing one.
    3. In the Information Takeoff view, edit existing or create new column.
    4. In the column settings dialog, select the “JavaScript” option.
    5. Enter the name for the column.
    6. In the JavaScript editor, write your script using the Solibri JavaScript API.

    Example: Hello BIM!

    function getValue(row, components) {
        return "Hello BIM!";
    }
    

    Example: Refer Other Column by Name

    function getValue(row, components) {
        var otherColumnValue = row.getValue("Column C Name");
        return otherColumnValue;
    }
    

    Example: Refer Other Column by Column Reference Letter

    function getValue(row, components) {
        var otherColumnValue = row.getValue("C");
        return otherColumnValue;
    }
    

    Example: Refer Other Column by Column Index

    function getValue(row, components) {
        var otherColumnValue = row.getValue(2);
        return otherColumnValue;
    }
    

    Example: Component Count on Row

    function getValue(row, components) {
        return components.size();
    }
    

    Example: Access Component Properties

    Component API

    function getValue(row, components) {
        if (components.isEmpty()) {
            return null;
        }
        var component = components.get(0); // Get the first component
        return component.getGUID(); // Access a property of the component
    }
    

    How to use the JavaScript API in Hyperlink Templates

    1. Open the Hyperlink Manager view in Solibri Office.
    2. In the settings window, you can specify the Hyperlink Template according to your requirements:
    • In the Filter dialog you can specify which components should be affected by the Hyperlink Template. Only the components, which are specified there, will be handled by the hyperlink definition.
    • In the JavaScript window you can define the script, which will be applied as a hyperlink.
    • Finally, you can specify what kind of hyperlink you want to use:
      • URL means, that as a result, the hyperlink forwards the user to a specified homepage when you click on the hyperlink.
      • Executable means, that as a result, a specified application is executed.
      • Stand-alone means, that the script is just executed and there no further action is taken.

    Example: URL

    function getUrl(entity) {
    	return "www.solibri.com";
    }
    

    In the shown example, the hyperlink script forwards the user for all specified components to “www.solibri.com”
    when they click on the hyperlink in the information window.
    For testing this, just select one of the specified components and check the “Hyperlinks”
    tab in the “Information” view under the “Custom” section.
    There you should see the references hyperlink now.
    By clicking on the hyperlink element, the script will be executed and
    e.g. forward you to the specified URL - in this case “www.solibri.com”.

    JVM Options for JavaScript

    This option allows the user to disable JavaScript editing in the Solibri desktop application.
    Default value is false, which means JavaScript editing is enabled.

    -Ddisable-javascript-editing=true
    

    This option allows the user to disable JavaScript running in the Solibri desktop application.
    Default value is false, which means JavaScript running is enabled.

    -Ddisable-javascript-running=true
    
    1 Reply Last reply
    1

    Copyright © 2025 Solibri Inc. | Powered by NodeBB

    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories