Jump to content

List of coordinates cogo point


dilan

Recommended Posts

Hello.

Trying to make a function that will return a list of coordinates of all selected cogo points.

But I can not understand how to add to the list the coordinates of all points. The coordinate of only one point is added.

Please help me understand.
Thank.

(defun cogo_list_coor ( / descr eastng idx northng pnt pntobj ss elev numb )
(vl-load-com)
  (if (setq ss (ssget '((0 . "AECC_COGO_POINT"))))
    (progn
      (setq idx -1)
      (while
	  (setq pnt (ssname ss (setq idx (1+ idx))))
	  (setq pntobj (vlax-ename->vla-object pnt))
	  (setq 
	   descr   (vlax-get pntobj 'fulldescription)
	   numb    (vlax-get pntobj 'Number)
	   eastng  (vlax-get pntobj 'easting)
	   northng (vlax-get pntobj 'northing)
	   elev    (vlax-get pntobj 'Elevation)
      )
      (list numb eastng northng elev)
	); end of while
   ); end of progn
  ); end of if
); end of cogo_list_coor

 

Link to comment
Share on other sites

Is this what you are after? It returns a list of lists. You are also extracting the description but not using it.

 

(defun cogo_list_coor ( / descr eastng idx northng pnt pntobj ss elev numb p_lst)
(vl-load-com)
  (cond ( (setq ss (ssget '((0 . "AECC_COGO_POINT"))))
          (setq p_lst nil)
          (repeat (setq idx (sslength ss))
            (setq pntobj (vlax-ename-vla-obj (ssname ss (setq idx (1- idx))))
                  descr   (vlax-get pntobj 'fulldescription);;;;!!Why? Never Used
                  numb    (vlax-get pntobj 'Number)
                  eastng  (vlax-get pntobj 'easting)
                  northng (vlax-get pntobj 'northing)
                  elev    (vlax-get pntobj 'Elevation)
                  p_lst (cons (list numb eastng northng elev) p_lst)
            );end_setq
          );end_repeat
        )
  );end_cond
  p_lst
); end of cogo_list_coor

 

Edited by dlanorh
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

FWIW, rather than defining separate variables for each retrieved property, you can use a single mapcar expression to return the desired sublist:

(defun cogo_list_coor ( / i l o s )
    (if (setq s (ssget '((0 . "AECC_COGO_POINT"))))
        (repeat (setq i (sslength s))
            (setq i (1- i)
                  o (vlax-ename->vla-object (ssname s i))
                  l (cons (mapcar '(lambda ( p ) (vlax-get o p)) '(number easting northing elevation)) l)
            )
        )
    )
    l
)

 

  • Like 1
Link to comment
Share on other sites

4 hours ago, Lee Mac said:

FWIW, rather than defining separate variables for each retrieved property, you can use a single mapcar expression to return the desired sublist:


(defun cogo_list_coor ( / i l o s )
    (if (setq s (ssget '((0 . "AECC_COGO_POINT"))))
        (repeat (setq i (sslength s))
            (setq i (1- i)
                  o (vlax-ename->vla-object (ssname s i))
                  l (cons (mapcar '(lambda ( p ) (vlax-get o p)) '(number easting northing elevation)) l)
            )
        )
    )
    l
)

 

thank Lee

Link to comment
Share on other sites

Great idea as usual Lee often getting multiple details from an object using VL-get, can see it as a library defun passing list of item names, so not hard coded.

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