Get Parent (or Parent of Parent) Relative Tag Name

In Ignition, is there a way to get the Parent Tag name?

Suppose I have a Tag: (1) A/B0/C and (2) A/B1/C, can I get A/B0 path and A/B1 path from C with the same script (scripted in its UDT class)?

Or else, is there any way to get Parent (or Parent of Parent) Relative Tag Parameter?

Here is for illustration:

I have tags with paths like:

A/B0/C/D
A/B1/C/D
A/B2/C/D
A/B3/C/D

Thus, I only need to put Number in my B tags as Data Type Parameter. However, I do not know how to access B Data Type Parameter from D. I could easily get D’s (assuming D is Expression Tag) Data Type Parameters in its Expression like this {Number}, but how to get C’s or B’s?

Since each C is another UDT owned by each B, I don’t know if we could get relative parent Parameters. I know that we could get our own custom parameters which are very useful indeed. But how to get the parent’s (or the parent’s parent’s). Is there a way to automatically pass down this custom parameter to all its children and its children’s children? Like inheritance protected concept in OOP like C# or Java I mean.

Any workaround? :frowning:

I am trying to clarify the question here even further (hope it may help. Better question format can be seen here.):

In Ignition, is there a way to get Parent and Parent of Parent relative tag names from an Expression Tag who is a member of a UDT tag in its definition?

Here is the case, I have a UDT tag which contain some other built-in tags, and one of them is an Expression Tag, but the UDT tag is owned by some other higher UDT tag

Something like this (note: all these are in the UDT definition/“template”, not UDT instance):

MyBaseUDTTag
--MyExpressionTag
--SomeOtherTag    

And then the MyBaseUDTTag is owned by some other UDT tag

MyAdvanceUDTTag
--MyBaseUDTTagMember
--MyOtherTagMemberInAdvanceUDT

Then, in the MyExpressionTag of MyBaseUDTTag I want to create an expression which is based on its Parent of Parent (that is MyAdvanceUDTTag) custom properties, because in the Tag Browser I have instances of the MyAdvanceUDTTag whose paths are something like this:

BaseFolder/MyAdvanceUDTTagInstance0
BaseFolder/MyAdvanceUDTTagInstance1
BaseFolder/MyAdvanceUDTTagInstance2
BaseFolder/MyAdvanceUDTTagInstance3

Note that there are running numbers from 0-3 there. And I want to make those running number part of the Expression in MyExpressionTag, which - in term of tag paths - are the “child of child” of a particular MyAdvanceUDTTagInstance:

BaseFolder/MyAdvanceUDTTagInstance0/MyBaseUDTTagMember/MyExpressionTag
BaseFolder/MyAdvanceUDTTagInstance1/MyBaseUDTTagMember/MyExpressionTag
BaseFolder/MyAdvanceUDTTagInstance2/MyBaseUDTTagMember/MyExpressionTag
BaseFolder/MyAdvanceUDTTagInstance3/MyBaseUDTTagMember/MyExpressionTag

And so, to avoid definition for each individual tag, I want to make one Expression in the MyExpressionTag Definition/Template instead.

Here, I realize that we could get:

  1. Parent UDT Custom Parameters + InstanceName + TagName
  2. Fellow child’s tag value (that is: SomeOtherTag value)
  3. A particular tag instance value - by specifying the path (which is quite close!)

Option 3. is actually quite close, but unfortunately not what I am looking for. Since what I look for is the name of that Tag - that is, MyAdvanceUDTTagInstance0 name, instead of MyAdvanceUDTTagInstance0 value.

Is there any way to do this in Ignition? I use Ignition v7.8.1 if that matters.

I only need to get Parent path/instance name (as string):

BaseFolder/MyAdvanceUDTTagInstance0/MyBaseUDTTagMember

And (more especially) parent of parent path/instance name:

BaseFolder/MyAdvanceUDTTagInstance0

Having OOP programming background with tools like WinForm, typically there is a way to get Parent Control and its name, and so I am hoping that there might be a similar approach to Ignition Tags too - which I am yet to know.

You can use the split and rsplit functions to parse your string into a dataset and then reference the different parts. You can use slicing if you know the lengths too.

There isn’t anything built-in that will do what you want I don’t thing.

s='BaseFolder/MyAdvanceUDTTagInstance0/MyBaseUDTTagMember/MyExpressionTag'

print 'rsplit result'
print s.rsplit("/",1)
print s.rsplit("/",2)
print s.rsplit("/",3)

print 'cutting result'
print s[0:54]
print s[0:10]

There is probably a million ways to parse strings in Python.

1 Like

@MMaynardUSG

That seems to be the answer I am looking for! :smiley: thanks, I will check it out.

Is there a way to get a Parent Parameter when defining the Child UDT tag?
For instance i have a parameter “Tag Name” on both UDT’s, but i want to access the PARENT “Tag Name” parameter not the Child.

In the parent UDT make an expression tag that contains what you need in the child udt tag.
If that is tag name, you can use “{InstanceName}” so it is dynamic and isn’t actually set with a parameter.

Then from the child UDT you can create an expression tag that references {[.]…/parentUDTtagname}

1 Like

So you’d have to create an expression tag for every Parent UDT Parameter you are interested in accessing in the Child? That seems pretty excessive when the parameters are already defined.