BIGAL Posted Saturday at 11:48 PM Posted Saturday at 11:48 PM Working on civil projects it was a daily task to set out points in the field. We would download the points into the gps receiver, and follow the arrow to the actual point. You may need a XYZ to lat long program, as the GPS will normally accept Latitude and Longitude values. You need a version of this conversion software that matches where you are in the world. I know with Google maps you can enter a lat long as a search point and it displays based on that point, AI hints can ask for directions. So if you make the correct point list even some fishing and hiking hand held gps may have ability to use a USB connection to upload points. They have arrows etc to show direction to travel in. Using the idea of a constant display in Acad you still need software that exports out the GNSS data, get that and I think the rest can be done. Else I think we are all going around in circles. Just a ps when you take a photo with your mobile phone it can store the lat long in the photo so you can insert the photo into your dwg at the correct location. Yes have code for that. Quote
GLAVCVS Posted 1 hour ago Posted 1 hour ago (edited) Here's a simple Lisp routine for obtaining data from an integrated GNSS receiver. It works by sending a small script to PowerShell, which writes the data to a file named 'pos.txt' saved in the Documents folder. I've only tested it on a single device, but it should work on any device equipped with an integrated GNSS receiver. The data is stored in latitude/longitude format, so each user will need to transform those coordinates into the desired coordinate reference system. To stop logging the data, simply close the PowerShell window This is just a starting point for anyone who wants to adapt it to their own needs. ;************************ G L A V C V S ************************* ;************************** F E C I T *************************** ;;;THIS CODE STARTS GNSS RECEIVER AND WRITES DATA TO A FILE CALLED 'pos.txt' IN THE My Docments FOLDER (defun startGNSS (/ cmd sh dir cad ur) (setq dir (VL-REGISTRY-READ "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders" "Personal" ) ) (if (setq sh (vlax-create-object "WScript.Shell")) (progn (if (and (or (setq ur (getint "\nUpdate rate (milliseconds) <1000>/2000/3000/5000 : ")) (not ur)) (member ur '(nil 1000 2000 3000 5000))) (progn (setq cad (strcat "Add-Type -AssemblyName System.Device" (chr 13) (chr 10) "# 1) Conectar con AutoCAD abierto" (chr 13) (chr 10) "$outFile = \'" dir "\\pos.txt\'" (chr 13) (chr 10) "try {" (chr 13) (chr 10) " $acad = [Runtime.InteropServices.Marshal]::GetActiveObject(\'AutoCAD.Application." (itoa (atoi (getvar "ACADVER"))) "\')" (chr 13) (chr 10) "}" (chr 13) (chr 10) "catch {" (chr 13) (chr 10) " Add-Type -AssemblyName System.Windows.Forms" (chr 13) (chr 10) " [System.Windows.Forms.MessageBox]::Show(" (chr 13) (chr 10) " \'Por alguna razón no se pudo conectar con AutoCAD mediante COM.\' + [Environment]::NewLine + $_.Exception.Message," (chr 13) (chr 10) " \'GNSS-}AutoCAD: Error de conexión\'," (chr 13) (chr 10) " [System.Windows.Forms.MessageBoxButtons]::OK," (chr 13) (chr 10) " [System.Windows.Forms.MessageBoxIcon]::Error" (chr 13) (chr 10) " )" (chr 13) (chr 10) " exit" (chr 13) (chr 10) "}" (chr 13) (chr 10) "# 2) Crear y arrancar receptor de ubicación Windows/GNSS" (chr 13) (chr 10) "$w = New-Object System.Device.Location.GeoCoordinateWatcher" (chr 13) (chr 10) "$w.Start()" (chr 13) (chr 10) "# 3) Bucle continuo: comprobar estado, obtener posición y escribir en USERS5" (chr 13) (chr 10) "while ($true) {" (chr 13) (chr 10) " $doc = $acad.ActiveDocument" (chr 13) (chr 10) " $status = $w.Status" (chr 13) (chr 10) " $p = $w.Position.Location" (chr 13) (chr 10) " $time = Get-Date -Format \'dd-MM-yyyy HH:mm:ss\'" (chr 13) (chr 10) " if ($status -eq \'Disabled\') {" (chr 13) (chr 10) " $line = \'*** GNSS ERROR: GNSS disabled ***\';;;;;;\"" (chr 13) (chr 10) " }" (chr 13) (chr 10) " elseif ($status -eq \'Initializing\') {" (chr 13) (chr 10) " $line = \'*** GNSS ERROR: Searching... ***\';;;;;;\"" (chr 13) (chr 10) " }" (chr 13) (chr 10) " elseif ($status -eq \'NoData\') {" (chr 13) (chr 10) " $line = \'*** GNSS ERROR: Without data ***\';;;;;;\"" (chr 13) (chr 10) " }" (chr 13) (chr 10) " elseif ($p.IsUnknown) {" (chr 13) (chr 10) " $line = \'*** ERROR GNSS: Unknown position ***\';;;;;;\"" (chr 13) (chr 10) " }" " else {" (chr 13) (chr 10) " $line = $p.Latitude + ';' + $p.Longitude + ';' + $p.Altitude + ';' + $p.HorizontalAccuracy + ';' + $p.VerticalAccuracy" (chr 13) (chr 10) " }" (chr 13) (chr 10) " try {" (chr 13) (chr 10) " Set-Content -Path $outFile -Value $line" (chr 13) (chr 10) " }" (chr 13) (chr 10) ;;; " catch {" ;;; (chr 13) ;;; (chr 10) ;;; " Write-Host 'ERROR escribiendo...: $($_.Exception.Message)'" ;;; (chr 13) ;;; (chr 10) ;;; " }" (chr 13) (chr 10) (strcat " Start-Sleep -Milliseconds " (if ur (itoa ur) "1000")) (chr 13) (chr 10) "}" ) cmd (strcat "powershell.exe -NoProfile -ExecutionPolicy Bypass -NoExit -Command \"" cad "\"" ) ) (vlax-invoke-method sh 'Run cmd 1 :vlax-false) (grtext -1 "*** GNSS writing file \'pos.txt\' ***") ) (alert "ERROR: \nUpdate rate should be 1000, 2000, 3000 or 5000\n\nExiting...") ) (vlax-release-object sh) ) ) ) Edited 1 hour ago by GLAVCVS Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.