Jump to content

Recommended Posts

Posted

Hi mates,

any idea to get the geo-coordinates of a Position Marker (new entity in Autocad 2016)?

 

I tried to extract like a block attributes, but it doesn't work.

 

Thanks in advance.

Posted (edited)
(vl-load-com)

(defun c:test ()
 (setq p (getPositionMarkerCoords))
 (princ (strcat "\nNorthing: " (rtos (cadr p) 2 3)
	 "\nEasting: " (rtos (car p) 2 3)))
 (princ)
 )

(defun getPositionMarkerCoords (  / ad s ds ts rp le ln p)
 (setq ad (_GetAeccDocument))
 (setq s (vlax-get-property ad 'Settings))
 (setq ds (vlax-get-property s 'DrawingSettings))
 (setq ts (vlax-get-property ds 'TransformationSettings))
 (setq rp (vlax-get-property ts 'ReferencePoint))
 (setq le (vlax-get-property rp 'LocalEasting))
 (setq ln (vlax-get-property rp 'LocalNorthing))
 (setq p (list le ln))
 )

(defun _GetAeccDocument ()
 ((lambda (vrsn)
    (if
      (setq vrsn
             (cond
	((vl-string-search "21.0" vrsn) "11.0")                 ; 2017
               ((vl-string-search "20.1" vrsn) "10.5")                 ; 2016
               ((vl-string-search "20.0" vrsn) "10.4")                 ; 2015
               ((vl-string-search "19.1" vrsn) "10.3")                 ; 2014
               ((vl-string-search "19.0" vrsn) "10.0")                 ; 2013
               ((vl-string-search "18.2" vrsn) "9.0")                  ; 2012
               ((vl-string-search "18.1" vrsn) "8.0")                  ; 2011
               ((vl-string-search "18.0" vrsn) "7.0")                  ; 2010
               ((vl-string-search "17.2" vrsn) "6.0")                  ; 2009
               ((vl-string-search "17.1" vrsn) "5.0")                  ; 2008
             )
      )
       (setq *AeccDoc*
              (vlax-get
                (cond (*AeccApp*)
                      ((setq *AeccApp*
                              (vla-getinterfaceobject
                                (cond (*Acad*)
                                      ((setq *Acad* (vlax-get-acad-object)))
                                )
                                (strcat "AeccXUiLand.AeccApplication." vrsn)
                              )
                       )
                      )
                )
                'ActiveDocument
              )
       )
    )

  )
   (if vlax-user-product-key                                           ; If 2013+
     (vlax-user-product-key)                                           ; Use new function
     (vlax-product-key)                                                ; Use legacy function
   )
 )
)

Edited by Hippe013
Code Tags (My Bad) - Added / to make variables local
Posted

Hi Hippe013,

 

 

Thanks for posting the code. However in order to make it work I had to add a "/" to the local variables area of the getpositionmarkercoords function because they look like arguments as you posted it. Also, in the same function you are declaring the variable "ne" as local, but I think you mean for that to be "ln".

 

 

Thanks again,

 

 

Steve

Posted

Steve,

 

Thanks for the catch. I threw this together rather quickly from other code that I had. I will update my code above.

 

regards,

 

Hippe013

Posted

Hippe013 thanks for the 2017 vrsn saves me from finding it, if we ever got to 2017 more likely 2018.

Posted

:beer:

 

 

 

 

 

Please lengthen your message to at least 10 characters.

Posted

Thanks for the code vdub, but when I execute it on autocad, return me the next error: "; error: Automation Error. Problem in loading application".

 

I've check the lisp and I think that the problem is on "getPositionMarkerCoords" function that it doesn't run. (I've Autocad 2016 release)

 

Thanks a lot for your support,

Greetings.

Posted

Ups... It's true, I'm sorry Hippe, I was confused!

 

I hope you can help me to run your routine.

 

Thanks.

Posted

The routine that I created above works only with Civil 3D with the versions stated above. As of right now I am not certain how to gain access to the geo-location data (using visual lisp) without using Aecc. I should be able to write a lisp function using vb.net to expose the geo-location data without the use of Aecc (Civil 3D). This may take a little while depending on how well exposed you need it. ie. Just retrieve data vs. setting data.

 

regards,

 

Hippe013

Posted

Re-reading the OP, it sounds like you just want the coordinates of the Position Marker Entity that's similar to a multileader, correct? If so, the following should do it (you can select as many of them as you want). I wasn't sure if you wanted the LatLongs, or Cartesian coordinates, so it displays both.

 

 

HTH

 

 

;;Get Position Marker Geo-Coordinates
;;
;;By Steve Carson
;;
(vl-load-com)
(defun c:PMCoords ( / ss obj)
(setq ss (ssget '((0 . "POSITIONMARKER"))))
(repeat (setq i (sslength ss))
   (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
   (princ (strcat "\n" (vla-get-TextString obj)))
   (princ (strcat "\nNorthing: " (rtos (cadr (vlax-safearray->list 
                                                 (vlax-variant-value 
                                                     (vla-get-Position obj)
                                                 )
                                             )
                                       )
                                  2 ))
   (princ (strcat "\nEasting: " (rtos (car (vlax-safearray->list 
                                                 (vlax-variant-value 
                                                     (vla-get-Position obj)
                                                 )
                                             )
                                       )
                                  2 ))
   (princ (strcat "\nLatitude: " (vla-get-Latitude obj)))
   (princ (strcat "\nLongitude: " (vla-get-Longitude obj)))
   (princ "\n")
)
(textscr)
(princ)
)

 

 

Steve

Posted

I was under the understanding that the OP wanted the GEO-Location position rather than the location of a position marker. Your code works fine for this. I would be curious as to how extract the location of the GeoMarker (Red Dot) without the benefits of the Aecc document. I've attached an image showing the Geo-Location Marker that I was referring to.

 

GeoMarker.jpg

  • 4 years later...
Posted

Hippe013,

 

Just doing some digging into this today, I know I'm a few years late, but it may benefit somebody still.

 

Best,

~DD

 

(defun GetGeoData ( / )
  (dictsearch
    (cdr (assoc 360 (entget (cdr (assoc 330 (entget (tblobjname "BLOCK" "*Model_Space")))))))
    "ACAD_GEOGRAPHICDATA"
  );dictsearch
);defun

(defun c:TEST ( / geoData ptGeo)
  (if (and (setq geoData (GetGeoData))
           (not (zerop (getvar 'TILEMODE))))
    (progn
      (setq ptGeo (cdr (assoc 10 geoData)))
      (command "_.CIRCLE" "non" ptGeo (* 0.15 (getvar 'VIEWSIZE)))
      (prompt "\nA circle was created at the point: ") (princ ptGeo)
    );progn
  ;else
    (prompt "\nEither No Geo Data or not in Model space...")
  );if
  (princ)
);defun

 

  • 1 year later...
Posted
On 9/6/2016 at 7:46 PM, a_67vdub said:

Re-reading the OP, it sounds like you just want the coordinates of the Position Marker Entity that's similar to a multileader, correct? If so, the following should do it (you can select as many of them as you want). I wasn't sure if you wanted the LatLongs, or Cartesian coordinates, so it displays both.

 

 

HTH

 

 

 

;;Get Position Marker Geo-Coordinates
;;
;;By Steve Carson
;;
(vl-load-com)
(defun c:PMCoords ( / ss obj)
(setq ss (ssget '((0 . "POSITIONMARKER"))))
(repeat (setq i (sslength ss))
   (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
   (princ (strcat "\n" (vla-get-TextString obj)))
   (princ (strcat "\nNorthing: " (rtos (cadr (vlax-safearray->list 
                                                 (vlax-variant-value 
                                                     (vla-get-Position obj)
                                                 )
                                             )
                                       )
                                  2 ))
   (princ (strcat "\nEasting: " (rtos (car (vlax-safearray->list 
                                                 (vlax-variant-value 
                                                     (vla-get-Position obj)
                                                 )
                                             )
                                       )
                                  2 ))
   (princ (strcat "\nLatitude: " (vla-get-Latitude obj)))
   (princ (strcat "\nLongitude: " (vla-get-Longitude obj)))
   (princ "\n")
)
(textscr)
(princ)
)
 

 

 

 

Steve

 

That code seems to be missing 2 closing ) characters, I presume at the the (princ (strcat.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...