@dan-natu
Out of the box without using the API, you aren’t able to create a single row in ITO to extract the description of the type. You’ll need to use either a Javascript ITO or an Information API jar.
If you look at the Type 1.4 or Type 2015 ITOs that are part of the COBie UK Resources of the COBie extension, it uses a Javascript ITO Column to extract the description Identification property from the the component.
There is a video on this extension here:
https://www.youtube.com/watch?v=uH_KTavsEZU
More information on the Javascript ITO can be found here:
https://society.solibri.com/category/23/javascript-api
You can also use the Info API to create a .jar file to place in the lib folders that creates a Custom Info properties in the information of the component. More information on the information API can be found here: https://society.solibri.com/topic/563/information-api
I attached such in a zip that contains the information API project along with the “smc-api-info-TypeDescription-1.0.0.jar” you can place in the lib folder of the Solibri program files. There is also a “Type Desc.ito” that has a javascript ITO that extracts the description of the type of a component if it exists.
smc-api-info-TypeDescription.zip
08c89199-0778-4f31-b538-d70925d17aec-image.png
The code for the information API is below:
package com.solibri.info;
import java.util.Optional;
import java.util.Collection;
import com.solibri.smc.api.info.Information;
import com.solibri.smc.api.model.Component;
import com.solibri.smc.api.model.PropertyType;
import com.solibri.smc.api.model.Relation;
/**
* This example custom information returns the description of a components type
* if it exists.
*
*/
public class TypeDescription implements Information<String> {
@Override
public String getUniqueId() {
return "TypeDescription";
}
@Override
public Optional<String> getInformation(Component component) {
Optional<String> oInfo = null;
Component typeComponent = getTypeComponent(component);
if (typeComponent != null) {
if (typeComponent.getDescriptionText().isPresent()) {
oInfo = typeComponent.getDescriptionText();
}
}
return oInfo;
}
@Override
public PropertyType getType() {
return PropertyType.STRING;
}
private Component getTypeComponent(Component component) {
Collection<Component> col = component
.getRelated(Relation.of(Relation.Type.DEFINES_BY_TYPE, Relation.Direction.BACKWARD));
if (!col.isEmpty()) {
return (Component) col.iterator().next();
} else {
return null;
}
}
}
The code for the JavaScript ITO is below:
importClass(com.solibri.smc.api.model.Relation)
importClass(com.solibri.smc.api.model.ComponentType)
importClass(java.util.HashSet)
function getValue(row, components) {
var typeDescSet = new HashSet();
for (var iterator = components.iterator(); iterator.hasNext();) {
var component = iterator.next();
var typeComponent = getTypeComponent(component);
if (typeComponent != null) {
if (typeComponent.getDescriptionText().isPresent()) {
typeDescSet.add(typeComponent.getDescriptionText().get());
}
}
}
return getSetAsString(typeDescSet);
}
function getTypeComponent(component) {
var col = component.getRelated(Relation.of(Relation.Type.DEFINES_BY_TYPE, Relation.Direction.BACKWARD));
if (!col.isEmpty()) {
return col.iterator().next();
} else {
return null;
}
}
function getSetAsString(set) {
var returnString = "";
var setIterator = set.iterator();
if (setIterator.hasNext()) {
returnString = setIterator.next();
}
while (setIterator.hasNext()) {
returnString += ", " + setIterator.next();
}
return returnString;
}