Hi Dojo,
Does someone has some sample code for assigning a visual to a view from in a script? I had a look in the Class Library but couldn't find a method/property on the IDmsView class.
Hi Jens,
I have found this piece of code that I used, probably it can be improved by checking the response.
AssignVisioToView(eurView.Id, "Europe View.vsdx", engine);
private void AssignVisioToView(int viewId, string viewVDX, Engine engine)
{
engine.SendSLNetSingleResponseMessage(new AssignVisualToViewRequestMessage(viewId, viewVDX));
}
Regards,
Moderator note: This is an internal call and we do not recommend using this, as it is not officially supported and we cannot guarantee that it will still work in the future. As a rule, you should avoid using SLNet calls, as these are subject to change without notice.
Hi Jens,
Response of Klaas should do it. I'll post a snippet from our RT manager framework, on behalf of completeness: how to create a Visio file + how to set active page on Visio file
private void CreateAndAssignVisioFile(IEngine engine, int viewId, string VisioFile) { if (CreateVisioFile(engine, $@"C:\\RTManager\\TestDependencies\{VisioFile}", VisioFile)) { var assignRequest = new AssignVisualToViewRequestMessage(viewId, VisioFile) { ActiveValue = "Active", Page = "1", }; // There is no way of knowing if this succeeded engine.SendSLNetSingleResponseMessage(assignRequest); } } private bool CreateVisioFile(IEngine engine, string filePath, string VisioFile) { CreateProtocolFileMessage createProtocolFileMessage = new CreateProtocolFileMessage { What = 7, Ba = new BA(System.IO.File.ReadAllBytes(filePath)), Sa = new SA(new string[1] { VisioFile }) }; CreateProtocolFileResponse createProtocolFileResponse = engine.SendSLNetSingleResponseMessage(createProtocolFileMessage) as CreateProtocolFileResponse; if (createProtocolFileResponse == null || createProtocolFileResponse.ErrorCode != 0) { engine.ExitFail("Could not upload visio file. " + ((createProtocolFileResponse == null) ? "response was null" : $"errocode was {createProtocolFileResponse.ErrorCode}")); return false; } return true; }