Make pen name different than tag name from tag browser drag and drop

Vision 7.9
When dragging and dropping tags from the tag browser to the pen list on an easy chart I don't get to edit the name. and because I use UDTs. All my tags have the same name. See below:

Is there a way i can change the pen name from the designer permanently?

You will need to use Scripting. Take a look at the Scripting Functions User Manual Page for the component you are working with - Easy Chart - Scripting Functions | Ignition User Manual

There is an example script that demonstrates:

#This will take a tag that gets dropped from a Tag Browse Tree set in Realtime Tag Tree mode,
#and will replace the underscores in the name of the tag "_" and replace them with spaces.

I do this with custom properties on any tag that has history enabled.
Custom property: PenName

def customChartTagsDropped(self, paths):
	'''
		Add drag/dropped tag pen trend to easy chart from tag tree.
		
		Args:
			self			(Easy Chart obj)	:	Easy chart object where tag history pens are to be displayed.
			paths			(sting(s))			:	string (or list of string) tags to add to easy chart.
			
		Returns:
			n/a
			*self.tagPens	(dataset)			:	Easy chart "tagPens" property is updated to included the added tag pen
	'''
	
	#headers - for reference
	#headers = [	'NAME',					'TAG_PATH',				'AGGREGATION_MODE',	'AXIS',			'SUBPLOT',
	#				'ENABLED',				'COLOR',				'DASH_PATTERN',		'RENDER_STYLE',	'LINE_WEIGHT',
	#				'SHAPE',				'FILL_SHAPE',			'LABELS',			'GROUP_NAME',	'DIGITAL',
	#				'OVERRIDE_AUTOCOLOR',	'HIDDEN',				'USER_SELECTABLE',	'SORT_ORDER',	'USER_REMOVABLE'
	#			]
				
	#default row - configure as desired for default trend appearance
	defaultRow = [		'Name',				'[Provider]Path',		'Average',			'Default Axis',	1,
						True,				'color(255,0,0,255)',	'',					0,				1,
						0,					True,					False,				'',				False,
						False,				False,					True,				'',				True
				 ]
	
	#initialize empty tagPaths list
	tagPaths = []
	tagNamePaths = []
	
	#for each path in the list of dropped tags
	for path in paths:
	
		#build tag path from historic tag path. each tag provider is formatted as "area_xx" find the first occurance of the tag provider name
		pathStartIndex = path.find("area_")
		
		#check for tag in the default provider if the "area" provider is not found
		if pathStartIndex == -1:
			pathStartIndex = path.find("default")
		
		#make sure provider was found
		if pathStartIndex != -1:
		
			#get the tag path from the proivder to the end and format to read the custom PenName property from the tag
			tagPath = "["+path[pathStartIndex:]+'.PenName'
			tagNamePath = "["+path[pathStartIndex:]+'.Name'
			
			#add the tagPath to the list
			tagPaths.append(tagPath)
			tagNamePaths.append(tagNamePath)
			
		#tag provider not found, append empty string to keep accurate parallel lists
		else:
			tagPaths.append('')
			
	penNames = system.tag.readBlocking(tagPaths)
	tagNames = system.tag.readBlocking(tagNamePaths)
	
	
	#for each pen name in the list of read pen names
	for count, penName in enumerate(penNames):
	
		#skip any tags where the provider was not found
		if tagPaths[count] != '':
		
			#create default row
			newRow = defaultRow
			
			#if PenName custom prop does not exist or is empty
			if penName.quality.isBad() or penName.value is None or str(penName.value) == '':
			
				#assign tag name to row name
				newRow[0] = str(tagPaths[count].rsplit(']')[1][:-len('.PenName')])
				#newRow[0] = str(tagNames[count].value)
				
			#good PenName found
			else:
			
				#assign PenName to row name
				newRow[0] = str(penName.value)
				
			#assign history path to row path
			newRow[1] = paths[count]
			
			#update tagPens with the new row
			self.tagPens = system.dataset.addRow(self.tagPens, self.tagPens.rowCount, newRow)

You'll have to adjust this for your tag provider(s)

2 Likes