Showing posts with label API. Show all posts
Showing posts with label API. Show all posts

Friday, 3 February 2017

MapGuide - renderMap - transparency

The RenderMap functions takes a MgColor object in order to set the background color of the map.
I wanted to have a transparent background - according to the API docs you can create a MgColor object by providing values for RGB and alpha:

MgColor(int red, int green, int blue, int alpha);

Problem is, the map background wont show up transparent. In order to have the background transparent MgColor needs to be called by passing hexvalues instead:

MgColor("ffffff00");

AIMS 2017

Wednesday, 16 April 2014

Start external application from form

From a waste water industry model form we want to launch an external application with certain parameters. In Map form designer you can add a button with VB.net script. Map API provides a function called OpenURL which seemed to be a good starting point. 

Map API Industry Model Docs

 The following script will open Notepad++:

Public Overrides Sub Button_Click()
      Me.Application.OpenUrl("C:\Program Files (x86)\Notepad++\notepad++.exe")
End Sub


It doesn't just open Notepad++. Notepad++ also tries to open a file C:\0:


Notepad++ message when called from Map form
It seems Map adds a parameter to the call which Notepad++ interprets as a reference to a file to be opened. Unfortunately I was not able to call Notepad++ with further parameters - such as a specific file name.

I couldn't figure out whether OpenURL is a suitable function for calling external apps or not. Instead of using Map API one can use the .Net Framework functionality as well. The following VB.net script launches the external app including certain startup parameters:

Public Overrides Sub Button_Click()   

 'Haltung auslesen
 dim d as Autodesk.Map.IM.Forms.DialogControls.TextBox
 dim name_number as String
 d = Me.Dialog.Controls.Item("NAME_NUMBER")
 name_number = d.Value
 dim parameter as String =  " /p Q:\KINS\Daten\öffKanal/h " + name_number

 'Msgbox( "Aufruf von:C:\Program Files (x86)\KINS\KINS.EXE " + parameter)
 'Aufruf
   
 Dim startInfo As New System.Diagnostics.ProcessStartInfo
 startInfo.FileName = "C:\Program Files (x86)\KINS\KINS.EXE"
 startInfo.Arguments = parameter
 Dim pro As New System.Diagnostics.Process
 pro.Start(startInfo)

End Sub

 
Map 2013 SP2


Externes Programm aus Formular starten

Wir müssen aus dem Abwasser-Haltungsformular eine Applikation mit Parametern - unter anderem die aktuelle Haltungsnummer - aufrufen. Im Formular kann man einen "Button" einbinden und mit VB.Net Script hinterlegen. In der Map API gibt es eine Funktion, die für einen Aufruf vom Namen her "passen"  könnte - OpenURL.

Map API Dokumentation

Damit lässt sich tatsächlich ein Programm starten, z.B. so:

Public Overrides Sub Button_Click()
      Me.Application.OpenUrl("C:\Program Files (x86)\Notepad++\notepad++.exe")
End Sub


Beim Aufruf von Notepad++ erscheint jedoch folgende Meldung:




Meldung in Notepad++ nach Aufruf aus Map
Es scheint, dass beim Aufruf schon ein Parameter angehängt wird den Notepad++ als Verweis auf eine bestimmte Datei interpretiert. Legt man eine Datei mit dem Namen "0" im Root Verzeichnis von C: an, öffnet Notepad++ die Datei auch beim Aufruf.

Es hat nicht funktioniert, das Programm mit eigenen Parametern aufzurufen - z.B. mit einem bestimmten Dateinamen.

Eine Datei - die mit einem Programm verknüpft ist - liess sich nicht öffnen:

Public Overrides Sub Button_Click()
      Me.Application.OpenUrl(" C:\Temp\testdatei.txt")
End Sub


Um ein Programm zu starten kann man die Funktionalität des .Net Frameworks nutzen:

Public Overrides Sub Button_Click()   

 'Haltung auslesen
 dim d as Autodesk.Map.IM.Forms.DialogControls.TextBox
 dim name_number as String
 d = Me.Dialog.Controls.Item("NAME_NUMBER")
 name_number = d.Value
 dim parameter as String =  " /p Q:\KINS\Daten\öffKanal/h " + name_number

 'Msgbox( "Aufruf von:C:\Program Files (x86)\KINS\KINS.EXE " + parameter)
 'Aufruf
   
 Dim startInfo As New System.Diagnostics.ProcessStartInfo
 startInfo.FileName = "C:\Program Files (x86)\KINS\KINS.EXE"
 startInfo.Arguments = parameter
 Dim pro As New System.Diagnostics.Process
 pro.Start(startInfo)

End Sub


Map 2013, SP2