Jump to content

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


vindicate

Recommended Posts

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"
Link to comment
Share on other sites

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

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

(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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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!

Link to comment
Share on other sites

  • 3 weeks later...
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?

Link to comment
Share on other sites

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