Hi Oli - this took a little while - I needed to go back and find a script that could help you - then I had to understand my own script again ;-)
What I did back then was to exploit the event called ActivateView2 Event (Application Object) (see DxDEsigenr Automation Ref Manual (Pg 113/114) for details.
My script had the purpose to open a specific Todo.txt file (with Wordpad) after DxDesigner was started, but only if the file existed...
The skeleton of the script itself is fairly simple :
Scripting.Dontexit = True
'Do your stuff
I can post the full script here if you are interested (86 lines)
One more remark - I seem to remember playing with AfterDocumentOpened event also, and looking at the above mentioned document, there are three required parameters :
Sub Application_AfterDocumentOpened(ByVal DocumentType As VdDataType, ByVal
LibraryAlias As String, ByVal Name As String)
Specifies the document type. This argument takes the form of VdDataType Enum.
This is a string that corresponds to the library alias.
This is the name of the document.
I am unsure what the Library alias should be. The name of the document would have to be extracted with automation , probably Application.GetActiveDesign - but I haven't tried...
just want to update on this for all who are interested in this function. Unfortunately this Sub is called for every opened sheet, not just on project start / schematic opened / first sheet load. Means, it triggers an action every time it displays a new sheet.
Anyhow, here is the correct statement:
Sub Application_AfterDocumentOpened(docType, LibraryAlias, Name)
docType = 0 ( means VDDT_SCHEMATIC?)
LibraryAlias = empty (in my case)
Name = Top (Schematic Name)
Does anyone have an idea how to start a one-time action when design is loaded?
Yes, please post that code. Would be great
Hi - below please find my script. I ran a quick check - it will show the file in question also when switching between multiple boards inside the same project - just so you are aware...
I can't seem to find the 'attach button', so I'll just paste in here....
---- XXXX ----
Dim openfile, filename, path
Dim patharray, p
Dim OldTop, CurrTop
Set DxDapp = Application
'Main routine : only event handler is used. When project is opened, file is opened.
' Set the Scripting.DontExit property to true to keep the script running.
Scripting.DontExit = True
OldTop = ""
If OldTop="" Then
End If 'OldTop=""
If CurrTop<>OldTop Then
End If ' CurrTop<>OldTop
'filename = "ToDo.rtf"
filename = "ToDo.txt"
path = DxdApp.GetProjectData.GetPCBDesignPath(DxDApp.GetActiveDesign(), True) 'path to PCB including pcb file name
' we need to strip away the filename *.pcb
patharray = split(path,"\")
for p = 0 to ubound(patharray)-1
path = path + patharray(p)
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(path & "\doc\"&filename)) Then
Set wscript = CreateObject ("Wscript.shell")
wscript.Run ("wordpad.exe " & Path & "\doc\" & filename)
End Sub 'FileOpen