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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

How to modify property units by script ?

fserre
1-Newbie

How to modify property units by script ?

Thanks to the community I found how to get the units of a property by script.

But now, I am trying to edit it and I cannot find the good API call to do it.

Does anybody know if it is possible and how to do it?

6 REPLIES 6

I don't think there's a snippet to do it, you may call the same REST API which calls Composer when you edit units... ( but I think that on this case, it's modifying the entire entity ).

For this reason, I've implemented my own Units system, which it's more flexible, but It would be good if they allow easily to modify units ( but should be on a Thing Basis, not ThingTemplate/ThingShape ).

Thanks Carles for your answer. That make sense. May I ask you how do you have implemented your units system?

I don't know how to add properties on top on properties, the only way I can think is to create a infotable property in the thing which could contains all custom property fields.

Hi Fabien,

Our Units system it's rather complicated.. something like:

  • We usually don't define "Raw" units for Properties ( Units Value ) , we define Units Class, for instance ( Temperature, Currency, Thermal Energy, Electrical Energy,... ). This is the type of units we usually define on a property ( ThingTemplate /ThingShape )
  • Then Based on the Things Hierarchy ( a network ) the Thing inherit the Units Value ( Celsius/Fahrenheit, €/$/..., kWh,... ) from a Units Setters Thing.
  • Optionally we can have a service which returns the Unit Type or Unit Value for a property, or for a given property we can have also Units Value
  • Optionally we can set the Units on the Thing Instance using our custom Aspects solution
  • TW Units field on our solution looks like this custom notation:
    • (service_name) --> service_name will be called in order to recover units_name
    • [literal_name] --> Raw units ( Units Value ), sample: [€]
    • units_name --> Units Type ( Units Class ), sample: currency --> Will inherit Raw units from Hierarchy Units Setter.
    • Aspect --> We have a custom aspect feature on our solution, which allows as on a Thing instance set custom property aspects ( which are implemented on Dynamic Properties created on the Thing instance ) , where we can set Custom Units on a Thing Instance.
  • We have data tables defining Units Value and Units Class ( for Localization purposes, and for easy input ), units value it's not like €, it's more like currencyEUR



Best Regards,

Carles

Hi Carles,

Many thanks for all these details. That gives me very good inputs to find my own solution.

Best regards,

Fabien

sharmon
12-Amethyst
(To:CarlesColl)

@Carles - are you coming to LiveWorx? If so, I'd love to sit down with you and check out your units implementation. It sounds great.

Hi Stephen,

I would love to share with you the details for Units ( and for sure you will like to see the rest of our solution, Units it's just a small part of it ), but we can afford traveling to LiveWorx -  we are Spain based -.

Best Regards,

Carles.

Top Tags