Creating ITO JavaScript Columns using AI
-
Here is an example of creating ITO JavaScript Columns using AI.
I wanted to list Assemblies and include “Tekla Common.Class” property from the related Beam on the same row.Prompt for Gemini 3 Pro:
See https://solibri.github.io/Developer-Platform/latest/javadoc/index.html Implement Solibri ITO JavaScript column that finds related beams and reads property "Class" value from "Tekla Common" property set of the beam. The functions base is this. Assume only one component as param. function getValue(row, components) { return ""; }The result worked out of the box:
/* * Solibri ITO Column Script * Function: Find related Beam and read 'Tekla Common' > 'Class' */ function getValue(row, components) { // 1. Basic validation: Ensure there is a component to check if (components.isEmpty()) { return ""; } // Get the first component (assuming one component per row as per parameter) var component = components.iterator().next(); // 2. Find the related Beam var relatedBeam = findRelatedBeam(component); if (relatedBeam != null) { // 3. Read "Class" property from "Tekla Common" property set return getProperty(relatedBeam, "Tekla Common", "Class"); } return ""; // Return empty string if no related beam is found } /* * Helper function to iterate through relations and find a Beam. * Checks CONNECTS (e.g., connection parts) and DECOMPOSES (e.g., assemblies) relations. */ function findRelatedBeam(component) { // Import necessary Solibri API classes var Relation = Packages.com.solibri.smc.api.model.Relation; var ComponentType = Packages.com.solibri.smc.api.model.ComponentType; // Define the relations to check. // We check both FORWARD and BACKWARD directions to cover various modeling scenarios // (e.g., a plate connected to a beam, or a sub-part of a beam assembly). var relationsToCheck = [ Relation.of(Relation.Type.CONNECTS, Relation.Direction.FORWARD), Relation.of(Relation.Type.CONNECTS, Relation.Direction.BACKWARD), Relation.of(Relation.Type.DECOMPOSES, Relation.Direction.FORWARD), Relation.of(Relation.Type.DECOMPOSES, Relation.Direction.BACKWARD) ]; for (var i = 0; i < relationsToCheck.length; i++) { var relation = relationsToCheck[i]; // Get all components related by this specific relation var relatedComponents = component.getRelated(relation); var iterator = relatedComponents.iterator(); while (iterator.hasNext()) { var relComp = iterator.next(); // Check if the related component is strictly of type BEAM if (relComp.getComponentType() == ComponentType.BEAM) { return relComp; } } } return null; } /* * Helper function to safely get a property value as a String */ function getProperty(component, psetName, propName) { // Get all property sets matching the name var psets = component.getPropertySets(psetName); var psetIter = psets.iterator(); while (psetIter.hasNext()) { var pset = psetIter.next(); // Get the specific property var prop = pset.getProperty(propName); // Check if the property exists and has a value // Solibri API returns an Optional<Property> if (prop.isPresent()) { return prop.get().getValueAsString(); } } return ""; }
Copyright © 2025 Solibri Inc. | Powered by NodeBB