Python Script Exchange

The Market Place is great…it you want to buy something. I spend a majority of my day in the designer, re-coding Python scripts I did “good enough” on or creating some new ones that might be used just once. I have a seperate windows I create buttons on for code just to test run or use once.

How about a link in the Designer that sends you to a spot in the forums, where us lame-brained, skilled just enough to be dangerous, people can share snippets of code (only code that worked, no scripting help please), where you can get real world examples people are using.

Here is an example of what I did when I used the IA Scripting Module to create 256 tags in about a second…

[code]#place under a button. Mine is called “Create #$@% Loads of OPC Tags”

#set for the first OPC address in the chain
tn = 1
fdbk = 128
tensstat = 0
spingrp = 32
rovtyp = 0

#do this for tags 1 through 64 (64 times)
for tn in range (1,65):
#create the tags
#system.tag.addTag(parentPath=“Folder”, name=“TagName”, tagType=“OPC”, dataType=“Int4”, attributes={“OPCServer”:“Ignition OPC-UA”, “OPCItemPath”:"[DeviceName]N7:0"})
system.tag.addTag(parentPath=“MAW20 S7-1200/Tension FeedBack”, name=“TensionFDBK " + str(tn), tagType=“OPC”, dataType=“Float4”, attributes={“OPCServer”:“Ignition OPC-UA Server”, “OPCItemPath”:”[MAW20_Tensioner]DB21,REAL" + str(fdbk),“FormatString”:"#,##0.#####"})
system.tag.addTag(parentPath=“MAW20 S7-1200/Tension Status”, name=“TensionStat” + str(tn), tagType=“OPC”, dataType=“Int2”, attributes={“OPCServer”:“Ignition OPC-UA Server”, “OPCItemPath”:"[MAW20_Tensioner]DB21,D" + str(tensstat)})
system.tag.addTag(parentPath=“MAW20 S7-1200/Spindle Group”, name=“SpindleT” + str(tn), tagType=“OPC”, dataType=“Int2”, attributes={“OPCServer”:“Ignition OPC-UA Server”, “OPCItemPath”:"[MAW20_Tensioner]DB20,I" + str(spingrp)})
system.tag.addTag(parentPath=“MAW20 S7-1200/Roving Type”, name=“RovingT” + str(tn), tagType=“OPC”, dataType=“Int2”, attributes={“OPCServer”:“Ignition OPC-UA Server”, “OPCItemPath”:"[MAW20_Tensioner]DB20,I" + str(rovtyp)})

#index the count. This will be the OPC addy on the machine
tn = tn + 1
fdbk = fdbk + 4
tensstat = tensstat + 2
spingrp = spingrp + 2
rovtyp = rovtyp + 2
#the code will cycle back up to the “for” and do it again for the next set of tags

#besure the parentPath DOES NOT EXIST with the name of the tags you are trying to create, it will through up an error.[/code]

To me, this is useful scripting. I learn best from DOING, reading about it OK, but you have to know what you are talking about before it will sink in.

The User Submitted Content part of the forum already exists for code snippets just like this :slight_smile: