Change Net colors to match wires

Script : Change Net connections to the color of the wire

 

Attached is a simple script example that can be added to the Trigger Afterwireconnected

When the wire is placed, the trigger will fire and determine the wire color test defined in the wire and then change the net to the color pallet number that matches.

THIS SCRIPT IS PROVIDED FOR REFERENCE AND IS NOT GUARANTEED TO FUNCTION. IT IS NOT SUPPORTED BY ZUKEN.

Dim ModifiedItems
Dim App, Job, Wire, Pin, Net, Cabs
Dim EachWire, NetIds, NetSegment, TotalNetSegmentIds
Dim WireColor, NewColor
Dim ShowMessage : ShowMessage = False
Dim UpdateWireColor : UpdateWireColor = True ' Update Wire Color on connect line
'
Set App = ConnectToE3
Set Job = App.CreateJobObject
Set Wire = Job.CreatePinObject
Set Pin = Job.CreatePinObject
Set Net = Job.CreateNetSegmentObject
Set Cabs = Job.CreateDeviceObject

Modified = Job.GetLastModifiedItems(ModifiedWireIds, 22): ChangeWireDisplay ModifiedWireIds
Modified = Job.GetLastModifiedItems(ModifiedWireIds, 39): ChangeWireDisplay ModifiedWireIds

Set Job = Nothing
Set App = Nothing
Wscript.Quit

Sub ChangeWireDisplay( ModifiedItems )
For EachWire = 1 To UBound(ModifiedItems)
'
Wire.Setid ModifiedItems(EachWire)
TotalNetSegments = Wire.GetNetSegmentIds(NetIds)
WireColor = Wire.GetColourDescription
NewColor = ScreenWireColor(WireColor)
If (ShowMessage) then Msgbox "Color " & NewColor & " - " & WireColor
For NetSegment = 1 To TotalNetSegments
Net.setid NetIds(NetSegment)
if Net.GetLineColour <> NewColor then
if (UpdateWireColor) then
Net.SetLineColour NewColor
End If
end if
Next
Next
End Sub

Function ScreenWireColor (WireColor)
' Match the wire color to the screen display colors
'
ScreenWireColor = 1

select case WireColor
case "Black" ScreenWireColor = 1
case "Purple" ScreenWireColor = 165
case "Violet" ScreenWireColor = 165
case "Green" ScreenWireColor = 75
case "Pink" ScreenWireColor = 18
case "Blue" ScreenWireColor = 232
case "Light Green" ScreenWireColor = 73
case "Grey" ScreenWireColor = 12
case "Red", "RED" ScreenWireColor = 26
case "Yellow" ScreenWireColor = 16
case "White" ScreenWireColor = 20
case "Tan" ScreenWireColor = 49
case "Brown" ScreenWireColor = 47
case "Orange" ScreenWireColor = 58
End Select
ScreenWireColor = ScreenWireColor -1

End Function

Function ConnectToE3
if InStr(WScript.FullName, "E³") then
set ConnectToE3 = WScript ' internal
else
strComputer = "."
set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set colItems = objWMIService.ExecQuery("Select * from Win32_Process",,48)
ProcessCnt = 0
for each objItem in colItems
if InStr(objItem.Caption, "E3.series") then ProcessCnt = ProcessCnt + 1
next
set objWMIService = Nothing
set colItems = Nothing
if ProcessCnt > 1 then
MsgBox "More than one E3-Application running. Script can't run as external program." & vbCrLf &_
"Please close the other E3-Applications.", 48
WScript.Quit
else
set ConnectToE3 = CreateObject ("CT.Application") ' external
end if
end if
End Function

 

 

Paul Harvell

 

0

Comments

0 comments

Please sign in to leave a comment.

Didn't find what you were looking for?

New post