TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: zombies640 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:
(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)
)
-
Quick untested example to look at...
(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*))
)
)
)
-
This thread discussed here also have almost the same request here :
http://www.cadtutor.net/forum/showthread.php?98272-Info-by-cogo-point
-
Thanks, alanjt!
-
Thanks, alanjt!
HOpe it helps.