Dear DAVID Community,

As you are probably aware, the entire DAVID company, team and product range has been integrated into HP Inc.
This forum is now read-only. Relevant content has been migrated to HP and merged into HP's Support Forums on November 1, 2016.

To start new discussions for 3D Scanning, please register and post your new topic at the HP Support Forums

DAVID 4?

Discussions about latest DAVID developments, beta versions...

Re: DAVID 4?

Postby Ingo » Mon Jul 27, 2015 9:38 pm

I use the possibility of automating shapefusion by mouse clicks now for a couple of months and it works reliably.
The only requirement is not to change the screen resolution, it might not be restored properly (happened already twice).

As I work with a turntable, I adapted the previous presented script to an alignment around the y-axis and transfered it to David 4.
AutoIt v3 script:
Code: Select all
#region --- Au3Recorder generated code Start (v3.3.9.5 KeyboardLayout=00000407)  ---

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>
#include <File.au3>
#include <Misc.au3>

HotKeySet("^x", "Abbruch") ; Überwache CTRL+x

Func Abbruch()
      MsgBox($MB_SYSTEMMODAL, "HotKeySet", "CTRL+x was pressed, therefore we will close the application.")
      Exit
EndFunc

Func _WinWaitActivate($title,$text,$timeout=0)
   WinWait($title,$text,$timeout)
   If Not WinActive($title,$text) Then WinActivate($title,$text)
   WinWaitActive($title,$text,$timeout)
EndFunc

Func _DavidWaitActive()
   Do
      Sleep(200)
      MouseClick("left",2331,208,1) ;Button "Projekt laden",
      If WinGetTitle("[active]")="Ausrichtung" Then ;Nötig, falls die Grobregistrierung keine Lösung findet
;      If WinGetTitle("[active]")="Alignment" Then ;Nötig, falls die Grobregistrierung keine Lösung findet
         WinClose("[ACTIVE]", "")
      EndIf
      If WinExists("Ausrichtung","Namespacestrukturste") then Return
;      If WinExists("Alignment","Namespacestrukturste") then Return
   Until WinExists("Projekt laden","Namespacestrukturste")
   ;   Until WinExists("Load Project","Namespacestrukturste")
   Send("{ESC}")
EndFunc

Func _CheckRotationswinkel()
   MouseClick("left",366,337,1)
   Send("u")
   Send("{ENTER}")
   If PixelGetColor(380,390)=0 Then
      MouseClick("left",37,390,1)
      Return True
   Else
      Return False
   EndIf
EndFunc

Func _UnCheckRotationswinkel()
   MouseClick("left",366,337,1)
   Send("u")
   Send("{ENTER}")
   If PixelGetColor(380,390)<>0 Then
      MouseClick("left",37,390,1)
      Return True
   Else
      Return False
   EndIf
EndFunc

Func _AusrichtungUmYEinschalten($Winkel)
   if _CheckRotationswinkel() Then
      Send("{Tab 3}")
   Else
      Send("{Tab 4}")
   EndIf
   Send("{CTRLDOWN}a{CTRLUP}")
   Send("{BACKSPACE}")
   Send($Winkel)
   Send("{TAB 3}")
   Send("{SPACE}")
EndFunc

Func _ScansLaden($ScanArray, $Path) ;multiple Scans laden, die über ein eindimensionales Array übergeben werden
   Local $sendText=Chr(034) & $ScanArray[0] & Chr(034)
   For $i=1 to UBound($ScanArray)-1
      $sendText=$sendText & " " & Chr(034) & $ScanArray[$i] & Chr(034)
   Next
   MouseClick("left",2332,464,1)
   _WinWaitActivate("Füge Scans der Scanliste hinzu","Namespacestrukturste")
;   _WinWaitActivate("Add scans to list","Namespacestrukturste")
   Send($Path)
   Send("{ENTER}")
   Sleep(200)
   Send($sendText)
   Send("{ENTER}")
   _DavidWaitActive()
EndFunc

Func _AlignStrategieUmY($NrScan1, $NrScan2)
   MouseClick("left",2300,Round(26.26*($NrScan2)+394.56),1) ;Scan2 an_
   MouseClick("left",2300,Round(26.26*($NrScan1)+394.56),1) ;Scan1 ausrichten
   _DavidWaitActive()
   _WinWaitActivate("DAVID 3D SCANNER Pro v4.1.17","")
EndFunc
;----------------------------------------------------------------------------------------------------------------------------------
Local $sControlFile = $CmdLine[1] ;Steuerdatei und Pfad, wird über Kommandozeile übergeben, in Entwicklungsumgebung (SciTE) über View->Parameters (Shift+F8) eingeben
Local $sFilePath = $CmdLine[2]
Local $Rotationswinkel=$CmdLine[3]

Local $arrayScans[1][2] ;Array für die Scans, 1 Element, 2 Kamerawinkel, wird in _FileReadToArray redimensioniert

If Not _FileReadToArray($sControlFile, $arrayScans, Default, ";") Then ;Einlesen der Steuerdatei, 2D-Array, Trennzeichen ";", 1. Spalte: nix, 2. Spalte: Scans System 1, 3. Spalte: Scans System 2
   MsgBox($MB_SYSTEMMODAL, "Error loading file", "An error occurred when reading the control file. Script execution stopped!")
   Exit
EndIf

_WinWaitActivate("DAVID 3D SCANNER Pro v4.1.17","")
Local $aExtract = _ArrayExtract($arrayScans, 1, UBound($arrayScans)-1, 1, 1) ;Überführen der Daten in ein 1D-Array (nur Scans System 1)

_ScansLaden($aExtract, $sFilePath) ;max 35 Scans, ansonsten gibt es Darstellungsverschiebungen

_WinWaitActivate("DAVID 3D SCANNER Pro v4.1.17","")
;Sleep(200) ; nötig, sonst funktioniert der Rest nicht sicher
MouseClick("left",47,285,1) ;Ordne sichtbare Scans an 2D

_AusrichtungUmYEinschalten(-$Rotationswinkel)
For $i=1 to Round((UBound($arrayScans)-1)/2)-1
   _AlignStrategieUmY($i, $i+1) ;übergebene Parameter für die Position der Scans
Next
Send("{ESC}")
_AusrichtungUmYEinschalten($Rotationswinkel)
_AlignStrategieUmY(1, UBound($arrayScans)-1)
For $i=UBound($arrayScans)-1 to Round((UBound($arrayScans)-1)/2)+3 Step -1
   _AlignStrategieUmY($i, $i-1) ;übergebene Parameter für die Position der Scans
Next
Send("{ESC}")
MouseClick("left",2226,Round(26.26*(Round((UBound($arrayScans)-1)/2))+394.56),1) ;Scan vorher selektieren
MouseClick("left",2226,Round(26.26*(Round((UBound($arrayScans)-1)/2)+2)+394.56),1) ;Scan nachher selektieren
MouseClick("right",2300,Round(26.26*(Round((UBound($arrayScans)-1)/2)+2)+394.56),1) ;Kontextmenü auswählen
MouseClick("left",1900,Round(26.26*(Round((UBound($arrayScans)-1)/2)+2)+415.56),1) ;Scans gruppieren

_UnCheckRotationswinkel()
MouseClick("left",120,525,1)
MouseClick("left",2300,Round(26.26*(Round((UBound($arrayScans)-1)/2)+1)+394.56),1) ;Scan an_
MouseClick("left",2300,Round(26.26*(Round((UBound($arrayScans)-1)/2))+394.56),1) ;Gruppe ausrichten

_DavidWaitActive()
_WinWaitActivate("DAVID 3D SCANNER Pro v4.1.17","")
Send("{ESC}")
MouseClick("right",2300,Round(26.26*(Round((UBound($arrayScans)-1)/2))+394.56),1) ;Kontextmenü auswählen
MouseClick("left",1900,Round(26.26*(Round((UBound($arrayScans)-1)/2))+458.56),1) ;Scans ungruppieren

;alle Scans speichern
Sleep(200)
MouseClick("left",2226,385,1) ;alle Scans selektieren
MouseClick("left",2512,Round(26.26*(UBound($arrayScans)-1)+434.8),1) ;Button "Schnelles Speichern/Überschreiben"
_WinWaitActivate("Bitte Ordner zum Speichern aller Scans auswählen","")
;_WinWaitActivate("Please choose the save folder for all scans","")
Send($sFilePath)
Send("{ENTER}")
Sleep(200)
Send("{ENTER}")
Sleep(200)
_WinWaitActivate("Speichern","")
;_WinWaitActivate("Save","")
Send("{TAB}")
Sleep(200)
Send("{ENTER}")
MouseClick("left",2376,Round(26.26*(UBound($arrayScans)-1)+434.8),1) ;Button "Entferne selectierte Scans"
Sleep(200)
Send("{ENTER}")

#endregion --- Au3Recorder generated code End ---

To show the workflow, I uploaded a video on youtube:
https://youtu.be/Yop3Ld3QXmE

Thanks to Svens comment I could retrieve some information on David controls.
On autoitscript.com there is a very interesting project by junkew, who achieved the accessibility of WPF-controls under AutoIt:
https://www.autoitscript.com/forum/topic/153520-iuiautomation-ms-framework-automate-chrome-ff-ie/?

With those ideas I started to rewrite the above presented script to be independent from cursor coordinates and screen resolutions.
So far I could access a lot of the needed controls, but did not have the time to finish the project. I am not sure, if all controls will be accessible by this method, but it might reduce the necessity for adapting coordinates on every system significantly.

The AutoIt script looks like:
Code: Select all
#region --- Au3Recorder generated code Start (v3.3.9.5 KeyboardLayout=00000407)  ---

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>
#include <File.au3>
#include <Misc.au3>
#include "UIAWrappers.au3"

#AutoIt3Wrapper_UseX64=Y  ;Should be used for stuff like tagpoint having right struct etc. when running on a 64 bits os

Global Const $sAnwendungsname="DAVID 3D SCANNER Pro v4.1.17"
;Global Const $sAnwendungsname="DAVID 3D SCANNER Trial v4.1.17"
;Global Const $sAnwendungsname="DAVID 3D SCANNER Pro v4.2.0"
Global Const $iMouseClickSpeed=10
Global $oPx=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=" & $sAnwendungsname & ";controltype:=UIA_WindowControlTypeId;class:=Window", $treescope_children)

HotKeySet("^x", "Abbruch") ; Überwache CTRL+x

Func Abbruch()
      MsgBox($MB_SYSTEMMODAL, "HotKeySet", "CTRL+x was pressed, therefore we will close the application.")
      Exit
EndFunc

Func _WinWaitActivate($title,$text,$timeout=0)
   WinWait($title,$text,$timeout)
   If Not WinActive($title,$text) Then WinActivate($title,$text)
   WinWaitActive($title,$text,$timeout)
EndFunc

Func _DavidWaitActive()
   Local $oUIElement, $fSelected

   Do
      $oUIElement=_UIA_getFirstObjectOfElement($oPx,"name:=" & "Scans", $treescope_subtree)
      $oUIElement.GetCurrentPropertyValue($UIA_IsEnabledPropertyId, $fSelected)
      Sleep(50)
      If WinGetTitle("[active]")="Ausrichtung" Then ;Nötig, falls die Grobregistrierung keine Lösung findet
;      If WinGetTitle("[active]")="Alignment" Then ;Nötig, falls die Grobregistrierung keine Lösung findet
         WinClose("[ACTIVE]", "")
      EndIf
   Until $fSelected
EndFunc

Func _CheckRotationswinkel()
   Local $oCheckBox, $fSelected

   $oCheckBox=_UIA_getFirstObjectOfElement($oPx,"name:=" & "Rotationswinkel", $treescope_subtree)
   $oCheckBox.GetCurrentPropertyValue($UIA_LegacyIAccessibleDefaultActionPropertyId, $fSelected)
   If $fSelected="Aktivieren" Then ;Aktivieren
      _UIA_Action($oCheckBox,"activate")
      Send("{SPACE}")
      Return True
   Else
      _UIA_Action($oCheckBox,"activate")
      Send("{SPACE}")
      Send("{SPACE}")
      Return False
   EndIf
EndFunc

Func _UnCheckRotationswinkel()
   Local $oCheckBox, $fSelected

   $oCheckBox=_UIA_getFirstObjectOfElement($oPx,"name:=" & "Rotationswinkel", $treescope_subtree)
   $oCheckBox.GetCurrentPropertyValue($UIA_LegacyIAccessibleDefaultActionPropertyId, $fSelected)
   If $fSelected="Deaktivieren" Then ;Deaktivieren
      _UIA_Action($oCheckBox,"activate")
      Send("{SPACE}")
      Return True
   Else
      _UIA_Action($oCheckBox,"activate")
      Send("{SPACE}")
      Send("{SPACE}")
      Return False
   EndIf
EndFunc

Func _AusrichtungUmYEinschalten($Winkel)
   _CheckRotationswinkel()
   Send("{Tab 3}")
   Send("{CTRLDOWN}a{CTRLUP}")
   Send("{BACKSPACE}")
   Send($Winkel)
   Send("{TAB 3}")
   Send("{SPACE}")
EndFunc

Func _ScansLaden($ScanArray, $Path) ;multiple Scans laden, die über ein eindimensionales Array übergeben werden
   Local $sendText=Chr(034) & $ScanArray[0] & Chr(034)
   Local $oCheckBox, $fSelected

   For $i=1 to UBound($ScanArray)-1
      $sendText=$sendText & " " & Chr(034) & $ScanArray[$i] & Chr(034)
   Next
   $oCheckBox=_UIA_getFirstObjectOfElement($oPx,"name:=" & "Scanliste", $treescope_subtree)
   _UIA_Action($oCheckBox,"activate")
   Send("{Tab 2}")
   Send("{ENTER}")
   _WinWaitActivate("Füge Scans der Scanliste hinzu","Namespacestrukturste")
;   _WinWaitActivate("Add scans to list","Namespacestrukturste")
   Send($Path)
   Send("{ENTER}")
   Sleep(200)
   Send($sendText)
   Send("{ENTER}")
   _DavidWaitActive()
EndFunc

Func _AlignStrategieUmY($NrScan1, $NrScan2)
   MouseClick("left",2300,Round(26.26*($NrScan2)+394.56),1,$iMouseClickSpeed) ;Scan2 an_
   MouseClick("left",2300,Round(26.26*($NrScan1)+394.56),1,$iMouseClickSpeed) ;Scan1 ausrichten
   _DavidWaitActive()
   _WinWaitActivate($sAnwendungsname,"")
EndFunc
;----------------------------------------------------------------------------------------------------------------------------------
Local $sControlFile = $CmdLine[1] ;Steuerdatei und Pfad, wird über Kommandozeile übergeben, in Entwicklungsumgebung (SciTE) über View->Parameters (Shift+F8) eingeben
Local $sFilePath = $CmdLine[2]
Local $Rotationswinkel=$CmdLine[3]

Local $arrayScans[1][2] ;Array für die Scans, 1 Element, 2 Kamerawinkel, wird in _FileReadToArray redimensioniert

If Not _FileReadToArray($sControlFile, $arrayScans, Default, ";") Then ;Einlesen der Steuerdatei, 2D-Array, Trennzeichen ";", 1. Spalte: nix, 2. Spalte: Scans System 1, 3. Spalte: Scans System 2
   MsgBox($MB_SYSTEMMODAL, "Error loading file", "An error occurred when reading the control file. Script execution stopped!")
   Exit
EndIf

_WinWaitActivate($sAnwendungsname,"")
Local $aExtract = _ArrayExtract($arrayScans, 1, UBound($arrayScans)-1, 1, 1) ;Überführen der Daten in ein 1D-Array (nur Scans System 1)

_ScansLaden($aExtract, $sFilePath) ;max 35 Scans, ansonsten gibt es Darstellungsverschiebungen

_WinWaitActivate($sAnwendungsname,"")
Sleep(200) ; nötig, sonst funktioniert der Rest nicht sicher
MouseClick("left",47,285,1,$iMouseClickSpeed) ;Ordne sichtbare Scans an 2D

_AusrichtungUmYEinschalten(-$Rotationswinkel)

;-----------------------------------
For $i=1 to Round((UBound($arrayScans)-1)/2)-1
   _AlignStrategieUmY($i, $i+1) ;übergebene Parameter für die Position der Scans
Next
Send("{ESC}")
_AusrichtungUmYEinschalten($Rotationswinkel)
_AlignStrategieUmY(1, UBound($arrayScans)-1)
For $i=UBound($arrayScans)-1 to Round((UBound($arrayScans)-1)/2)+3 Step -1
   _AlignStrategieUmY($i, $i-1) ;übergebene Parameter für die Position der Scans
Next
Send("{ESC}")
MouseClick("left",2226,Round(26.26*(Round((UBound($arrayScans)-1)/2))+394.56),1,$iMouseClickSpeed) ;Scan vorher selektieren
MouseClick("left",2226,Round(26.26*(Round((UBound($arrayScans)-1)/2)+2)+394.56),1,$iMouseClickSpeed) ;Scan nachher selektieren
MouseClick("right",2300,Round(26.26*(Round((UBound($arrayScans)-1)/2)+2)+394.56),1,$iMouseClickSpeed) ;Kontextmenü auswählen
MouseClick("left",1900,Round(26.26*(Round((UBound($arrayScans)-1)/2)+2)+415.56),1,$iMouseClickSpeed) ;Scans gruppieren

_UnCheckRotationswinkel()
MouseClick("left",120,525,1,$iMouseClickSpeed)
MouseClick("left",2300,Round(26.26*(Round((UBound($arrayScans)-1)/2)+1)+394.56),1,$iMouseClickSpeed) ;Scan an_
MouseClick("left",2300,Round(26.26*(Round((UBound($arrayScans)-1)/2))+394.56),1,$iMouseClickSpeed) ;Gruppe ausrichten

_DavidWaitActive()
_WinWaitActivate($sAnwendungsname,"")
Send("{ESC}")
MouseClick("right",2300,Round(26.26*(Round((UBound($arrayScans)-1)/2))+394.56),1,$iMouseClickSpeed) ;Kontextmenü auswählen
MouseClick("left",1900,Round(26.26*(Round((UBound($arrayScans)-1)/2))+458.56),1,$iMouseClickSpeed) ;Scans ungruppieren

;alle Scans speichern
Sleep(200)
MouseClick("left",2226,385,1,$iMouseClickSpeed) ;alle Scans selektieren
MouseClick("left",2512,Round(26.26*(UBound($arrayScans)-1)+434.8),1,$iMouseClickSpeed) ;Button "Schnelles Speichern/Überschreiben"
_WinWaitActivate("Bitte Ordner zum Speichern aller Scans auswählen","")
;_WinWaitActivate("Please choose the save folder for all scans","")
Send($sFilePath)
Send("{ENTER}")
Sleep(200)
Send("{ENTER}")
Sleep(200)
_WinWaitActivate("Speichern","")
;_WinWaitActivate("Save","")
Send("{TAB}")
Sleep(200)
Send("{ENTER}")
MouseClick("left",2376,Round(26.26*(UBound($arrayScans)-1)+434.8),1,$iMouseClickSpeed) ;Button "Entferne selectierte Scans"
Sleep(200)
Send("{ENTER}")

#endregion --- Au3Recorder generated code End ---

Again a youtube video:
http://youtu.be/GMUIDTKIkgQ

Sorry for not presenting it in an english David version and also leaving the comments in german, but as I had no response on my previous post, I did not invest that much work in the presentation.

As some previous comments in this thread dealt with automation and inspired me to work on scripting some automation tools, I would be glad to get some response.
Probably a lot of users are already using the SDK for automation pusposes. So please state this too.
As the SDK is surely reasonably priced for a commercial environment, I think it is to expensive for non-commercial users.

A question to the David-Team:
Do you plan to sell the SDK or a slimmed down version for less for non-commercial users?

Best regards
Ingo
SLS-1
SLS-2
Turntable
Ingo
 
Posts: 29
Joined: Thu Jan 15, 2015 12:02 pm
Location: Germany

Previous

Return to DAVID Development

Who is online

Users browsing this forum: No registered users and 2 guests