cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

How to assign ThingShape via script

tcoufal
13-Aquamarine

How to assign ThingShape via script

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

ACCEPTED SOLUTION

Accepted Solutions
posipova
20-Turquoise
(To:tcoufal)

Hi,

You may use the snippets AddShapeToThing and AddShapeToThingTemplate

View solution in original post

4 REPLIES 4
posipova
20-Turquoise
(To:tcoufal)

Hi,

You may use the snippets AddShapeToThing and AddShapeToThingTemplate

tcoufal
13-Aquamarine
(To:posipova)

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.

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

tcoufal
13-Aquamarine
(To:CarlesColl)

Hi Carles,

good to know. Thanks for the tip.

I was just about to doing that

Announcements


Top Tags