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 Solved General Discussion
6 Posts 3 Posters 2.8k 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 on 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
    2
    • N Offline
      N Offline
      Nuno
      wrote on last edited by Nuno
      #2

      Hi,

      Is JavaScript still working? I’ve been using it for years in Solibri Office and it desapeared recently from my ITO Columns menu:

      image.png

      I even tryed to set “-Ddisable-javascript-running=false” but it doesn’t work. I’m using now the version 25.3.2.65.

      Regards

      Nuno

      JSNJ MattiM 2 Replies Last reply
      0
      • JSNJ Offline
        JSNJ Offline
        JSN
        replied to Nuno on last edited by JSN
        #3

        @Nuno

        Hi, it is there in the latest version but it was disabled for a while during the last update and licence migration phase to the Solution Center. Probably best to write them an mail as replies here are not very common …

        https://society.solibri.com/topic/3325/solibri-25-3-2-hotfix-has-been-released/11?_=1754042778432

        1 Reply Last reply
        0
        • MattiM Offline
          MattiM Offline
          Matti Solibrians
          replied to Nuno on last edited by
          #4

          @Nuno said in Solibri API - Solibri JavaScript API:

          I’m using now the version 25.3.2.65.

          JavaScript is enabled publicly in Solibri 25.6.0: See https://society.solibri.com/topic/3367/solibri-25-6-0-has-been-released

          1 Reply Last reply
          1
          • N Offline
            N Offline
            Nuno
            wrote on last edited by
            #5

            Thanks @Matti and @JSN !

            After installing the new version 25.6.0, Javascrit was available again.

            1 Reply Last reply
            0
            • MattiM Matti marked this topic as a question on
            • MattiM Matti has marked this topic as solved on
            • MattiM Matti unlocked this topic on
            • MattiM Offline
              MattiM Offline
              Matti Solibrians
              wrote on last edited by
              #6

              Small example of getting issue counts for the components:

              function getValue(row, components) {
              	var allResults = Packages.com.solibri.smc.api.SMC.getChecking().getResults();
              	var cIterator = components.iterator();
              	var issueCount = 0;
              	while (cIterator.hasNext()) {
              		var component = cIterator.next();
              		var iterator = allResults.iterator();
              		while (iterator.hasNext()) {
              			var r = iterator.next();
              			if (r.getInvolvedComponents().contains(component)) {
              				issueCount++;	
              			}
              		}
              	}
              	return issueCount;
              }
              

              d7e1ff94-a61c-41ed-8df7-6d4b57b4b9bf-image.png

              4bb0f6b5-54fc-4ed5-bee9-168ff6fc9d5f-image.png

              1 Reply Last reply
              3
              • tonigyllenbergT tonigyllenberg pinned this topic on
              • tonigyllenbergT tonigyllenberg referenced this topic on

              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