Skip to main content
1-Visitor
February 27, 2017
Solved

How to assign ThingShape via script

  • February 27, 2017
  • 4 replies
  • 3090 views

Hi, I am having some difficulties to figure something out.

I have things based on my lets say: myTemplate_01. Some of these things should contain some ThingShape and others not (or different).

As far as I can tell, there is no service setThingShape on some Thing.

Is there a way how to achieve this?

Thanks

Best answer by posipova

Hi,

You may use the snippets AddShapeToThing and AddShapeToThingTemplate

4 replies

posipova20-TurquoiseAnswer
20-Turquoise
February 27, 2017

Hi,

You may use the snippets AddShapeToThing and AddShapeToThingTemplate

tcoufal1-VisitorAuthor
1-Visitor
February 27, 2017

Hi,

Thanks a lot, Honestly I was not thinking about EntityServices, I was looking directly at the Thing level thinking that there would be such a service.

1-Visitor
February 27, 2017

Just for the record, after Adding Thing Shape, if on the same code execution thread you want to use the new shape on the given Things, you should get a new reference to the Thing again ( as the Thing will restart ).

For instance if you add a ThingShape to yourself:

Resources["EntityServices"].AddShapeToThing({ name: me.name, thingShapeName: "whatevershape" });

// -- Now if you want to call a service or a property don't use me.propertyName or me.serviceName

// -- you should use Things[me.name].propertyName and/or Things[me.name].serviceName

// -- but you can't use me.name , then you should save previously your ThingName to a temp Variable

// -- Things[thingName].propertyName

tcoufal1-VisitorAuthor
1-Visitor
February 27, 2017

Hi Carles,

good to know. Thanks for the tip.

I was just about to doing that