# Reading OPCTag Scale Mode

**URL:** <https://forum.inductiveautomation.com/t/reading-opctag-scale-mode/99734>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [December 12, 2024, 7:24am UTC](https://forum.inductiveautomation.com/t/reading-opctag-scale-mode/99734 "2024-12-12T07:24:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Geoff\_Dodds](https://avatars.discourse-cdn.com/v4/letter/g/6f9a4e/32.png) [@Geoff\_Dodds](https://forum.inductiveautomation.com/u/Geoff_Dodds)\
**Post date:** [December 12, 2024, 7:24am UTC](https://forum.inductiveautomation.com/t/reading-opctag-scale-mode/99734/1 "2024-12-12T07:24:15Z")

</div>

I am new to Ignition and having a little trouble with a tag builder I am creating.  
I am trying to set a checkbox when the scale mode is set to BitInversion however the if statement always returns false regardless of the scale mode.

I am writing the scale mode to the checkbox text and seem to be using correct text value just no checkbox selection.

Can anyone give me some hints?

Thanks  
Geoff

```python
	tagPath = self.view.params.fullPath + "/MonitoredValue"
	OpcItemMode = system.tag.getAttribute(tagPath, "ScaleMode")
	self.getChild("root/Invert Value").props.text = OpcItemMode
	if OpcItemMode == "BitInversion":
		self.getChild("root/Invert Value").props.selected = bool(1)

```

---

<div class="post-metadata">

**Author:** ![mpoulsen921](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@mpoulsen921](https://forum.inductiveautomation.com/u/mpoulsen921)\
**Post date:** [December 12, 2024, 8:52am UTC](https://forum.inductiveautomation.com/t/reading-opctag-scale-mode/99734/2 "2024-12-12T08:52:57Z")

</div>

Hi,  
I think you are overcomplicating this.  
If you want to indicate if the scale mode of a tag is set to bitInversion or not using a checkbox, you can do it like this.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/6/36660ec01f082dbaa45b8b16ab007c3e1c00ef1c.png)

This binding should be added to the selected property of the checkbox.

---

<div class="post-metadata">

**Author:** ![Geoff\_Dodds](https://avatars.discourse-cdn.com/v4/letter/g/6f9a4e/32.png) [@Geoff\_Dodds](https://forum.inductiveautomation.com/u/Geoff_Dodds)\
**Post date:** [December 12, 2024, 9:39pm UTC](https://forum.inductiveautomation.com/t/reading-opctag-scale-mode/99734/3 "2024-12-12T21:39:45Z")

</div>

Hi,

Thanks for the reply. I should have provided more context on what I am trying to do. I am loading the values in the onStartup event of a popup form, the user can then change settings and either click save or cancel. For this reason I do not use bindings as I might not want the changes to apply to the tag.

I have done a bit more testing and found that the system.tag.getAttribute(tagPath, "ScaleMode") returns a value of type com.inductiveautomation.ignition.common.sqltags.model.types.ScaleMode which is why I believe my if statement fails. Any idea how I can test the string type from a class?

Thanks  
Geoff

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [December 12, 2024, 9:43pm UTC](https://forum.inductiveautomation.com/t/reading-opctag-scale-mode/99734/4 "2024-12-12T21:43:52Z")

</div>

Maybe something like:

```python
toString({value}) = 'BitInversion'

```

edit: oops, that's more a modification to what @mpoulsen921 suggested.

If you're doing this in scripting just use `str()` on the ScaleMode enum value you have.

---

<div class="post-metadata">

**Author:** ![Geoff\_Dodds](https://avatars.discourse-cdn.com/v4/letter/g/6f9a4e/32.png) [@Geoff\_Dodds](https://forum.inductiveautomation.com/u/Geoff_Dodds)\
**Post date:** [December 12, 2024, 9:50pm UTC](https://forum.inductiveautomation.com/t/reading-opctag-scale-mode/99734/5 "2024-12-12T21:50:39Z")

</div>

Thanks Kevin,

Using str() has solved my problem.

Geoff
