Skip to main content
13-Aquamarine
July 19, 2024
Solved

How to get implemented shapes from a thing shape without knowing a thing name

  • July 19, 2024
  • 1 reply
  • 1916 views

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?

Best answer by Velkumar

@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

1 reply

19-Tanzanite
July 19, 2024

Hi @JK_10744682 

 

You can use the below code to get implemented Thing Names

 

// result: INFOTABLE dataShape: "RootEntityList"
let result = ThingShapes["SHAPENAME"].GetImplementingThings();

 

/VR

13-Aquamarine
July 19, 2024

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)

19-Tanzanite
July 19, 2024

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 :

 

Velkumar_0-1721408036479.png

 

 

/VR