Jump to content

Extract the location (latitude-longitude) from the position marker


Recommended Posts

Posted (edited)

Is there something that can help me extract the location(latitude-longitude) from the position marker? I have maybe 20-30 position marker in every dwg file. image.png.eaba5168bc7e3d51f6650bad5d48a0ee.png

Edited by fuccaro
Thread name was "I need help"
Posted

Can you attached example drawing 

  • fuccaro changed the title to Extract the location (latitude-longitude) from the position marker
Posted

@vindicate

Welcome in the forum!

Please use relevant names when you start new threads. It will help people with similar problems to find their solution faster.

Posted
11 minutes ago, fuccaro said:

@vindicate

Welcome in the forum!

Please use relevant names when you start new threads. It will help people with similar problems to find their solution faster.

Oh. Sorry. I am new here hehe

Posted

I attached an example. I put manually the position markers because I need the coordinates(lat-long) on each of the marks.

sample.dwg

Posted

You may need to be in CIV3D to export direct Lat Long, or else will export X Y and you need another program to convert to Lat Long, do you understand world zones for lat long conversion.

Posted

entget ((-1 . <Entity name: 20484b4e3f0>) (0 . "POSITIONMARKER") (330 . <Entity name: 204e6d9e1f0>) (5 . "5B7") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (62 . 1) (100 . "AcDbGeoPositionMarker") (90 . 0) (10 3584.9 1434.64 0.0) (40 . 5.0) (1 . "") (40 . 2.5) (290 . 0) (280 . 0) (290 . 0))

Posted
3 hours ago, BIGAL said:

You may need to be in CIV3D to export direct Lat Long, or else will export X Y and you need another program to convert to Lat Long, do you understand world zones for lat long conversion.

oh i see. Thanks

Posted
4 minutes ago, Danielm103 said:

entget ((-1 . <Entity name: 20484b4e3f0>) (0 . "POSITIONMARKER") (330 . <Entity name: 204e6d9e1f0>) (5 . "5B7") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (62 . 1) (100 . "AcDbGeoPositionMarker") (90 . 0) (10 3584.9 1434.64 0.0) (40 . 5.0) (1 . "") (40 . 2.5) (290 . 0) (280 . 0) (290 . 0))

may I know how to use this? thanks

Posted
(defun c:11 (/)
 (setq ent (vlax-ename->vla-object (car (entsel)))
       lat (vla-get-latitude ent)
       lon (vla-get-longitude ent)
 )
 (alert (strcat "Latitude = " lat "\nLongitude = " lon))
)

 

  • Like 3
Posted
21 minutes ago, vindicate said:

may I know how to use this? thanks

Sorry, I miss read it, ‘58s is a better approach 

  • Confused 1
Posted
3 minutes ago, 1958 said:
(defun c:11 (/)
 (setq ent (vlax-ename->vla-object (car (entsel)))
       lat (vla-get-latitude ent)
       lon (vla-get-longitude ent)
 )
 (alert (strcat "Latitude = " lat "\nLongitude = " lon))
)

 

It works! Thanks on this. But is there anything that we can extract 2 or more position marker to text file or excel?

Posted

Something like this:

 

(defun C:POSM-TO-CSV ( / doc fil sel lst hdr )

  (vl-load-com)

  (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))

  (cond


    ((null
       (setq
	 fil (getfiled "Save CSV:"
		       (if (= 1 (getvar 'dwgtitled))
			 (strcat (getvar 'dwgprefix)
				 (vl-filename-base (getvar 'dwgname))
			 )
			 (strcat "C:\\" (vl-filename-base (getvar 'dwgname)))
		       )
		       "csv"
		       1
	     )
       )
     )
     (princ "\n*Cancel*")
    )

    ((null (ssget '((0 . "POSITIONMARKER"))))(princ "\nInvalid Selection."))

    ( t

     (vlax-for x (setq sel (vla-get-ActiveSelectionSet doc))
      (setq lst (cons (list (vla-get-latitude x)(vla-get-longitude x)) lst))
     )

     (setq lst (mapcar '(lambda ( x ) (list (car x) (cadr x))) lst))
     (setq hdr (cons (list "<Latitude>" "<Longitude>") hdr))

     (LM:WriteCSV (setq lst (append hdr lst)) fil)
     (princ "\nPlease Wait, Opening CSV File in Excel...")
     (startapp "Explorer" fil)

     (vla-delete sel)

    )

  )

  (princ)

)

 

Requires Lee Mac's WriteCSV

  • Like 1
  • Thanks 1
Posted
21 minutes ago, mrharris78 said:

Something like this:

 

(defun C:POSM-TO-CSV ( / doc fil sel lst hdr )

  (vl-load-com)

  (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))

  (cond


    ((null
       (setq
	 fil (getfiled "Save CSV:"
		       (if (= 1 (getvar 'dwgtitled))
			 (strcat (getvar 'dwgprefix)
				 (vl-filename-base (getvar 'dwgname))
			 )
			 (strcat "C:\\" (vl-filename-base (getvar 'dwgname)))
		       )
		       "csv"
		       1
	     )
       )
     )
     (princ "\n*Cancel*")
    )

    ((null (ssget '((0 . "POSITIONMARKER"))))(princ "\nInvalid Selection."))

    ( t

     (vlax-for x (setq sel (vla-get-ActiveSelectionSet doc))
      (setq lst (cons (list (vla-get-latitude x)(vla-get-longitude x)) lst))
     )

     (setq lst (mapcar '(lambda ( x ) (list (car x) (cadr x))) lst))
     (setq hdr (cons (list "<Latitude>" "<Longitude>") hdr))

     (LM:WriteCSV (setq lst (append hdr lst)) fil)
     (princ "\nPlease Wait, Opening CSV File in Excel...")
     (startapp "Explorer" fil)

     (vla-delete sel)

    )

  )

  (princ)

)

 

Requires Lee Mac's WriteCSV

Wow! It works. This will do. Thanks a lot!

Posted

You can also write direct to Excel, how much do you know about lisp.

  • 3 weeks later...
Posted
On 2/7/2024 at 1:14 PM, mrharris78 said:

Something like this:

 

(defun C:POSM-TO-CSV ( / doc fil sel lst hdr )

  (vl-load-com)

  (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))

  (cond


    ((null
       (setq
	 fil (getfiled "Save CSV:"
		       (if (= 1 (getvar 'dwgtitled))
			 (strcat (getvar 'dwgprefix)
				 (vl-filename-base (getvar 'dwgname))
			 )
			 (strcat "C:\\" (vl-filename-base (getvar 'dwgname)))
		       )
		       "csv"
		       1
	     )
       )
     )
     (princ "\n*Cancel*")
    )

    ((null (ssget '((0 . "POSITIONMARKER"))))(princ "\nInvalid Selection."))

    ( t

     (vlax-for x (setq sel (vla-get-ActiveSelectionSet doc))
      (setq lst (cons (list (vla-get-latitude x)(vla-get-longitude x)) lst))
     )

     (setq lst (mapcar '(lambda ( x ) (list (car x) (cadr x))) lst))
     (setq hdr (cons (list "<Latitude>" "<Longitude>") hdr))

     (LM:WriteCSV (setq lst (append hdr lst)) fil)
     (princ "\nPlease Wait, Opening CSV File in Excel...")
     (startapp "Explorer" fil)

     (vla-delete sel)

    )

  )

  (princ)

)

 

Requires Lee Mac's WriteCSV

do you have something that can also get the content text on each position marker together with the coordinates?

Posted

like the numbers on each position marker

image.png

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...