Author Topic: How to pick a specific cogo point  (Read 2352 times)

0 Members and 1 Guest are viewing this topic.

zombies640

  • Guest
How to pick a specific cogo point
« on: September 26, 2016, 01:47:38 PM »
Been trying to figure this out for a few hours but can't quite seem to get it. As my LISP is going through all the selected coco points, it will stop at points that have a certain description. Once it's found that point, I need to get the X&Y coordinates for the next 2 point numbers.

So for instance, it will go through the points until it finds a point description matching "DEC" and that point is 1400. Now it needs to find the X&Y properties of points 1401 and 1402.

I've commented out the spot I'm needing this in the code below:
Code: [Select]
(defun c:desc2 (/ ss x northng pnt eastng descr dist hndl eastng1 eastng2 northng1 northng2)
   (vl-load-com)
   (if (ssget ":S:E" '((0 . "AECC_COGO_POINT")))
      (progn
         (vlax-for x
            (setq ss (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))))
            (setq pnt (vlax-get x 'number)
               eastng (vlax-get x 'easting)
               northng (vlax-get x 'northing)
               descr (vlax-get x 'rawdescription)
               hndl (vlax-get x 'handle)
            );END setq
            (if
               (= 0 (vl-string-search "DEC" descr))
                  (progn
                     (command "text" "c" (list eastng northng) 0.5 0 descr)
                     (command  "_insert" "nf_shrub_decid" (list eastng northng) "" "" "")
                     (setq pnt1 (+ 1 pnt)
                           pnt2 (+ 2 pnt)
                     )
              ;; ***** This is where I need to find the next 2 sequential points
                  );END if TRUE
                  (progn
                     (if
                        (= 0 (vl-string-search "CNF" descr))
                           (progn
                              (command "text" "c" (list eastng northng) 0.5 0 descr)
                              (command  "_insert" "nf_shrub_conifer" (list eastng northng) "" "" "")
                           );END if TRUE
                     );END if
                  );END if FALSE
            );END if
         );END vlax-for
      );END progn
   );END if
   (princ)
)

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: How to pick a specific cogo point
« Reply #1 on: September 26, 2016, 03:15:07 PM »
Quick untested example to look at...

Code: [Select]
(defun c:desc2 (/ ss lst i o lst2)

  (if (setq ss (ssget '((0 . "AECC_COGO_POINT"))))
    (progn
      (vlax-for p (vlax-get (AT:AeccDoc) 'Points) ; step through points in drawing
        (setq lst (cons (cons (vlax-get p 'Number) p) lst)) ; create dotted pair list
      )
      (setq lst (vl-sort lst (function (lambda (a b) (< (car a) (car b)))))) ; sort by point number

      (repeat (setq i (sslength ss))
        (setq o (vlax-ename->vla-object (ssname ss (setq i (1- i)))))

        (if (and (eq (strcase (vlax-get o 'RawDescription)) "DEC") ; match raw description
                 (>= (length (setq lst2 (cdr (member (assoc (vlax-get o 'Number) lst) lst)))) 2) ; find points following selected point in list
                 (eq (strcase (vlax-get (cdar lst2) 'RawDescription)) "CNF") ; check if next matches description
                 (eq (strcase (vlax-get (cdadr lst2) 'RawDescription)) "CNF") ; check if next next matches description
            )
          (foreach x (list o (cdar lst2) (cdadr lst2)) ; step through list of three points and label
            (command "_.text"
                     "_c"
                     "_non"
                     (reverse (cdr (reverse (trans (vlax-get x 'Location) 0 1))))
                     0.5
                     0.
                     (vlax-get o 'RawDescription)
            )
          )
        )
      )
    )
  )
  (princ)
)


(defun AT:AeccDoc (/ c)
  ;; Return and set (as global variable *AeccDoc*) Civil 3D Aecc Document object
  ;; (will also set global variables for acad object *Acad* and c3d aecc application *AeccApp*)
  ;; Alan J. Thompson, 2013.11.27, 2014.03.20, 2016.08.12
  (cond (*AeccDoc*)
        ((and (setq c (vl-registry-read
                        (strcat "HKEY_LOCAL_MACHINE\\"
                                (if vlax-user-product-key
                                  (vlax-user-product-key)
                                  (vlax-product-key)
                                )
                        )
                        "Release"
                      )
              )
              (setq c (substr c 1 (vl-string-search "." c (+ (vl-string-search "." c) 1))))
              (setq *AeccApp* (vla-getinterfaceobject
                                (cond (*Acad*)
                                      ((setq *Acad* (vlax-get-acad-object)))
                                )
                                (strcat "AeccXUiLand.AeccApplication." c)
                              )
              )
         )
         (setq *AeccDoc* (vla-get-activedocument *AeccApp*))
        )
  )
)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ribarm

  • Gator
  • Posts: 3265
  • Marko Ribar, architect
Re: How to pick a specific cogo point
« Reply #2 on: September 26, 2016, 03:24:49 PM »
This thread discussed here also have almost the same request here :
http://www.cadtutor.net/forum/showthread.php?98272-Info-by-cogo-point
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

zombies640

  • Guest
Re: How to pick a specific cogo point
« Reply #3 on: September 27, 2016, 08:37:57 AM »
Thanks, alanjt!

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: How to pick a specific cogo point
« Reply #4 on: September 27, 2016, 08:45:57 AM »
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox