Nowaday, I build c# UI and application to answer to designer's needs.
In order to keep our application as independant as possible, i would like to run scripts contained into a given model from those application.
Do any elements exist to do so?
Solved! Go to Solution.
Hi Kael,
Sorry for the delay.
I finally found a solution wich maybe could help the comunity. This solution is not as simple as I expected but works fine.
This is what i have done :
1. get the script object present in your model (A), especially the script text.
2. concat the script text with the following script (B)
Dim CurrentObject, Dictionary
Sub Main()
On Error Resume Next
Set Studio = CreateObject("Studio.Editor")
Set Projects = CreateObject("OMTE.Projects")
if Err.Number > 0 then
Studio.DisplayOutputWindowMessage Err.Description & " " & Err.Source & vbcrlf
Err.Clear
end if
On Error Resume Next
Call Studio.OpenModel("%_PROJ_NAME_%")
modRef = Studio.GetCurrentModelReference()
Set Project = Projects.Item("Reference", modRef)
Set CurrentObject = Project.ItemByID("%_PKG_ID_%")
Set Dictionary = CurrentObject.Item("Dictionary")
if Err.Number > 0 then
Studio.DisplayOutputWindowMessage Err.Description & " " & Err.Source & vbcrlf
Err.Clear
else
if RunUtilityUI then
Project("Transaction") = "Begin"
On Error Resume Next
CommitUtility
if Err.Number > 0 then
Project("Transaction") = "Abort"
else
Project("Transaction") = "Commit"
end if
end if
end if
End Sub
Call Main()
This script open the model in wich the modification should be done, call the utilityUI method of the retreive script text.
3. Once the concatenation is done, save it into a temporary vbscript file.
4. Create a process wich execute the CSCript exe, and execute the temporary script previously created.
5. Finally, observe the modifications.
This method is a complex one but allow to execute a given script from outside of a model.
Hope this could help.
Regards
Hello Stephane Dumon,
I don't have a direct answer for your question, but I'm wondering if this information might be helpful?:
Which release of Integrity are you using?
Kind Regards,
Kael
Hi Kael,
Sorry for the delay.
I finally found a solution wich maybe could help the comunity. This solution is not as simple as I expected but works fine.
This is what i have done :
1. get the script object present in your model (A), especially the script text.
2. concat the script text with the following script (B)
Dim CurrentObject, Dictionary
Sub Main()
On Error Resume Next
Set Studio = CreateObject("Studio.Editor")
Set Projects = CreateObject("OMTE.Projects")
if Err.Number > 0 then
Studio.DisplayOutputWindowMessage Err.Description & " " & Err.Source & vbcrlf
Err.Clear
end if
On Error Resume Next
Call Studio.OpenModel("%_PROJ_NAME_%")
modRef = Studio.GetCurrentModelReference()
Set Project = Projects.Item("Reference", modRef)
Set CurrentObject = Project.ItemByID("%_PKG_ID_%")
Set Dictionary = CurrentObject.Item("Dictionary")
if Err.Number > 0 then
Studio.DisplayOutputWindowMessage Err.Description & " " & Err.Source & vbcrlf
Err.Clear
else
if RunUtilityUI then
Project("Transaction") = "Begin"
On Error Resume Next
CommitUtility
if Err.Number > 0 then
Project("Transaction") = "Abort"
else
Project("Transaction") = "Commit"
end if
end if
end if
End Sub
Call Main()
This script open the model in wich the modification should be done, call the utilityUI method of the retreive script text.
3. Once the concatenation is done, save it into a temporary vbscript file.
4. Create a process wich execute the CSCript exe, and execute the temporary script previously created.
5. Finally, observe the modifications.
This method is a complex one but allow to execute a given script from outside of a model.
Hope this could help.
Regards