aaryan Posted July 7, 2012 Posted July 7, 2012 Hi All, Back again with new query. Please help or guide me through. Any autolisp or visual lisp command which filters object closest to selected polyline. Basically i have an xyz file, i want to filter points from file very close to selected polyline. Please reply if need more explanation. Thanks in advance. Regards Aaryan. Quote
Stefan BMR Posted July 7, 2012 Posted July 7, 2012 I can not write a whole routine since I don't know the format of the source file. Try this ;p - a point (x y z) ;e - polyline ename ;d - control distance (<= (distance p (vlax-curve-GetClosestPointTo e p)) d) Quote
pBe Posted July 7, 2012 Posted July 7, 2012 GetClosestTextTo sub-functionby RenderMan This can easily be expanded, or modified to _GetClosest*To pretty much any entity, and should make for a good starting point..... HTH EDIT: Try this ;p - a point (x y z) ;e - polyline ename ;d - control distance (<= (distance p (vlax-curve-GetClosestPointTo e p)) d) What he said.. Quote
Stefan BMR Posted July 7, 2012 Posted July 7, 2012 If your post is related to this, here is a quick modification: (defun C:TEST ( / cross_prod ss1 ss2 e1 e2 p1 p2 i v tg d) (defun cross_prod (a b) (list (- (* (cadr a) (caddr b)) (* (caddr a) (cadr b))) (- (* (caddr a) (car b)) (* (car a) (caddr b))) (- (* (car a) (cadr b)) (* (cadr a) (car b))) ) ) (if (and (princ "\nSelect polyline: ") (setq ss1 (ssget ":E:S" '((0 . "LWPOLYLINE,SPLINE")))) (princ "\nSelect circles: ") (setq ss2 (ssget '((0 . "CIRCLE")))) (setq d (getdist "\nEnter gap distance: ")) ) (progn (setq e1 (ssname ss1 0)) (repeat (setq i (sslength ss2)) (setq e2 (ssname ss2 (setq i (1- i))) p2 (cdr (assoc 10 (entget e2))) p1 (vlax-curve-GetClosestPointTo e1 p2) v (mapcar '- p1 p2) tg (vlax-curve-GetFirstDeriv e1 (vlax-curve-GetParamAtPoint e1 p1)) ) (if (<= (distance p1 p2) d) (vla-put-Color (vlax-ename->vla-object e2) (if (minusp (caddr (cross_prod v tg))) acRed acYellow)) ) ) ) ) (princ) ) Quote
aaryan Posted July 7, 2012 Author Posted July 7, 2012 Thank You So much Stefan.. This is what i was looking for. One last question can i do it from XYZ file while importing 3d points. But for now this should be enough for me to play around. Thanks again Regards Aaryan. Quote
Stefan BMR Posted July 7, 2012 Posted July 7, 2012 Thank You So much Stefan..This is what i was looking for. You're welcome aaryan One last question can i do it from XYZ file while importing 3d points.Of course you can ;file - opened txt file ;e - polyline ename ;d - control distance (while (setq str (read-line file)) ;.... ;setq p str->x,y,z acording to file format ;.... (if (<= (distance p (vlax-curve-GetClosestPointTo e p)) d) (entmake (list '(0 . "POINT") (cons 10 p))) ) ) Quote
Recommended Posts
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.