Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
Hi,
I am trying to get the implemented shapes for a thing template. I do not have a thing created yet using this template but want to be able to call this GetImplementedShapes() service but just for the template not for a thing. Any ideas on if it is possible to get the shapes implemented on just the shape itself?
Solved! Go to Solution.
@JK_10744682 Sorry I didn't get your requirement properly
From ThingTemplate, if you want to get the list of implemented ThingShape in ThingTemplate. You can use the below code
// result: INFOTABLE dataShape: "EntityDescriptor"
let data = ThingTemplates["TEMPLATENAME"].GetOutgoingDependencies({
maxItems: undefined /* NUMBER {"defaultValue":500} */
});
let query = {
"filters": {
"type": "EQ",
"fieldName": "type",
"value": "ThingShape"
}
};
let params = {
t: data /* INFOTABLE */ ,
query: query /* QUERY */
};
// result: INFOTABLE
let result = Resources["InfoTableFunctions"].Query(params);
From ThingShape, if you want to get the list of ThingTemplate using ThingShape
// Provide your filter using the format as described in the help topic "Query Parameter for Query Services"
let query = {
"filters": {
"type": "EQ",
"fieldName": "entityType",
"value": "ThingTemplate"
}
};
// result: INFOTABLE dataShape: "RootEntityList"
let relationshipData = ThingShapes["SHAPENAME"].GetWhereUsed();
let params = {
t: relationshipData /* INFOTABLE */,
query: query /* QUERY */
};
// result: INFOTABLE
let result = Resources["InfoTableFunctions"].Query(params);
/VR
Hi @JK_10744682
You can use the below code to get implemented Thing Names
// result: INFOTABLE dataShape: "RootEntityList"
let result = ThingShapes["SHAPENAME"].GetImplementingThings();
/VR
This isn't exactly what I want. I need to be able to get the implemented thing shapes that are on a thing template, but calling GetImplementedShapes() requires a thing name (but I just want the shapes on the template, not a thing)
Hi @JK_10744682
I don't think we have a direct method to get the implemented thing template list.
You can use GetWhereUsed service to get relationship information - Using the GetWhereUsed Service (ptc.com)
Sample Code
// Provide your filter using the format as described in the help topic "Query Parameter for Query Services"
let query = {
"filters": {
"type": "EQ",
"fieldName": "entityType",
"value": "ThingTemplate"
}
};
// result: INFOTABLE dataShape: "RootEntityList"
let relationshipData = ThingShapes["SHAPENAME"].GetWhereUsed();
let params = {
t: relationshipData /* INFOTABLE */,
query: query /* QUERY */
};
// result: INFOTABLE
let result = Resources["InfoTableFunctions"].Query(params);
Output :
/VR
I see. I really just need a way to get a list of the shapes that are on a template if there is any way to do that.
@JK_10744682 Sorry I didn't get your requirement properly
From ThingTemplate, if you want to get the list of implemented ThingShape in ThingTemplate. You can use the below code
// result: INFOTABLE dataShape: "EntityDescriptor"
let data = ThingTemplates["TEMPLATENAME"].GetOutgoingDependencies({
maxItems: undefined /* NUMBER {"defaultValue":500} */
});
let query = {
"filters": {
"type": "EQ",
"fieldName": "type",
"value": "ThingShape"
}
};
let params = {
t: data /* INFOTABLE */ ,
query: query /* QUERY */
};
// result: INFOTABLE
let result = Resources["InfoTableFunctions"].Query(params);
From ThingShape, if you want to get the list of ThingTemplate using ThingShape
// Provide your filter using the format as described in the help topic "Query Parameter for Query Services"
let query = {
"filters": {
"type": "EQ",
"fieldName": "entityType",
"value": "ThingTemplate"
}
};
// result: INFOTABLE dataShape: "RootEntityList"
let relationshipData = ThingShapes["SHAPENAME"].GetWhereUsed();
let params = {
t: relationshipData /* INFOTABLE */,
query: query /* QUERY */
};
// result: INFOTABLE
let result = Resources["InfoTableFunctions"].Query(params);
/VR