souvik Posted October 17, 2013 Posted October 17, 2013 Hi, I am wondering if there is any lisp to align set of selected points with a line. Actually the points have XYZ value. The value should not be change. Input: ---- Output: --- Quote
pBe Posted October 17, 2013 Posted October 17, 2013 Hi,I am wondering if there is any lisp to align set of selected points with a line. Actually the points have XYZ value. The value should not be change. I guess you meant Z value should not be change, does that mean DO NOT move the points. otherwise align the LINE with the points and not the other way around. Confusing.... Quote
souvik Posted October 17, 2013 Author Posted October 17, 2013 Dear ReMark I have to align near about 5000 points so align command will take long time. Dear pBe I want to mean Don't change the labelled Z value. xy should change. only Z value is labelled with the points. That label should not change. Quote
eldon Posted October 17, 2013 Posted October 17, 2013 Are the points on a straight line anyway, so just have to be displaced a fixed distance to the line? Does the point have a Z value, or is the Z value merely annotated? Quote
ReMark Posted October 17, 2013 Posted October 17, 2013 Well the fact that you have so many points might have been a bit of useful knowledge to share with us in your very first post now wouldn't it? Are all 5000 points being aligned to the same line or multiple lines? Quote
souvik Posted October 17, 2013 Author Posted October 17, 2013 Are the points on a straight line anyway, so just have to be displaced a fixed distance to the line? Does the point have a Z value, or is the Z value merely annotated? actually the points are cross section level of a river. and the river is arround 30 km long. I have to create cross section at an interval of 200 meter. I captured only one level line. The point have true Z value and that true value is annotated. That's why the annotated Z value should not change. Quote
eldon Posted October 17, 2013 Posted October 17, 2013 So that is 150 lines with 30+ points per line. As they are cross sections, I would presume that they are not parallel. Are all the points at each cross-section displaced an equal amount from the section line? Would the movement of each point be at right angles to the line? So many questions to try and find out what the problem is and to see if a clever method of working can do the job without asking for a personal lisp. I think half a pound of elbow grease would be the solution for some requests. Quote
ReMark Posted October 17, 2013 Posted October 17, 2013 We try to work with the information we have been given which isn't necessarily the information that we need. Quote
souvik Posted October 17, 2013 Author Posted October 17, 2013 So that is 150 lines with 30+ points per line. As they are cross sections, I would presume that they are not parallel. Are all the points at each cross-section displaced an equal amount from the section line? Would the movement of each point be at right angles to the line? So many questions to try and find out what the problem is and to see if a clever method of working can do the job without asking for a personal lisp. I think half a pound of elbow grease would be the solution for some requests. No. I just need to align a set of point with a line. No need to be in equal distance and also not in right angle. Yes the points are not parallel. I just want to align the points with the annoted z value with a line. Quote
eldon Posted October 17, 2013 Posted October 17, 2013 No need to be in equal distance and also not in right angle. I am not sure that I can even understand what you are trying to do. Perhaps you could attach a drawing with one such set of points and your solution. Otherwise I will go for my siesta. Quote
steven-g Posted October 17, 2013 Posted October 17, 2013 Change your ucs so that x runs parallel to the line and the ucs is on the line, which means y=0 then select all the points and in the properties palette change the y value of the points to 0 Quote
GP_ Posted October 17, 2013 Posted October 17, 2013 Try this... (defun c:TesT (/ pp L field n fld p p_ID fc Lp p1 p2) (vl-load-com) (setq cmd (getvar 'cmdecho)) (setvar 'cmdecho 0) (command "_.undo" "_begin") (if (and (princ "\nSelect the points to align") (setq pp (ssget '((0 . "POINT")))) (setq L (car (entsel "\nSelect the reference line"))) (setq field (ssget "_X" '((0 . "MTEXT")))) ) (progn (repeat (setq n (sslength field)) (setq fld (cons (ssname field (setq n (1- n))) fld)) ) (repeat (setq n (sslength pp)) (setq p (ssname pp (setq n (1- n)))) (setq p_ID (ID (vlax-ename->vla-object p))) (mapcar '(lambda (x) (setq fc (vla-fieldcode (vlax-ename->vla-object x))) (if (vl-string-search p_ID fc) (setq Lp (cons (list p x) Lp)) ) ) fld ) ) (mapcar '(lambda (x) (setq p1 (cdr (assoc 10 (entget (car x))))) (setq p2 (vlax-curve-getClosestPointToProjection L (trans p1 1 0) '(0.0 0.0 1.0) ) ) (command "_move" (car x) (cadr x) "" "_non" p1 "_non" (list (car p2) (cadr p2) (caddr p1))) ) Lp ) ) ) (setvar 'cmdecho cmd) (command "_.undo" "_end") (princ) ) (defun ID (obj / doc) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (if (and (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE")) (vlax-method-applicable-p (vla-get-utility doc) 'getobjectidstring) ) (vla-getobjectidstring (vla-get-utility doc) obj :vlax-false) (itoa (vla-get-objectid obj)) ) ) Quote
souvik Posted October 18, 2013 Author Posted October 18, 2013 GP_ Sir, thank you. that's it. I just want this. Now will you please guide me if I want to add some more functions like, The point will align at a given distance from the center point of the lines. what should I do? Quote
GP_ Posted October 18, 2013 Posted October 18, 2013 (edited) Nice looking lisp. Thanks. ...if I want to add some more functions like, The point will align at a given distance from the center point of the lines. what should I do? This? (defun c:TesT (/ cmd pp L field n fld L1 L2 p p_ID fc Lp :p1 :p2) (vl-load-com) (setq cmd (getvar 'cmdecho)) (setvar 'cmdecho 0) (command "_.undo" "_begin") (if (and (princ "\nSelect the points to align") (setq pp (ssget '((0 . "POINT")))) (setq L (car (entsel "\nSelect the reference line"))) (= "LINE" (cdr (assoc 0 (entget L)))) (setq field (ssget "_X" '((0 . "MTEXT")))) (or oL (setq oL 0.00)) (setq oL (cond ( (getdist (strcat "\nOffset from the line <" (rtos oL 2 2) ">: ")) ) ( oL ) ) ) ) (progn (repeat (setq n (sslength field)) (setq fld (cons (ssname field (setq n (1- n))) fld)) ) (setq L1 (cdr (assoc 10 (entget L)))) (setq L2 (cdr (assoc 11 (entget L)))) (setq L1 (list (car L1) (cadr L1))) (setq L2 (list (car L2) (cadr L2))) (repeat (setq n (sslength pp)) (setq p (ssname pp (setq n (1- n)))) (setq p_ID (ID (vlax-ename->vla-object p))) (mapcar '(lambda (x) (setq fc (vla-fieldcode (vlax-ename->vla-object x))) (if (vl-string-search p_ID fc) (setq Lp (cons (list p x) Lp)) ) ) fld ) ) (mapcar '(lambda (x) (setq :p1 (cdr (assoc 10 (entget (car x))))) (setq :p1 (list (car :p1) (cadr :p1))) (setq :p2 (LM:ProjectPointToLine :p1 L1 L2)) (if (not (equal oL 0.0 1e-6)) (setq :p2 (polar :p2 (angle :p2 :p1) oL))) (command "_move" (car x) (cadr x) "" "_non" :p1 "_non" :p2) ) Lp ) ) ) (setvar 'cmdecho cmd) (command "_.undo" "_end") (princ) ) ; (defun ID (obj / doc) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (if (and (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE")) (vlax-method-applicable-p (vla-get-utility doc) 'getobjectidstring) ) (vla-getobjectidstring (vla-get-utility doc) obj :vlax-false) (itoa (vla-get-objectid obj)) ) ) ; ;; Project Point onto Line - Lee Mac ;; Projects pt onto the line defined by p1,p2 (defun LM:ProjectPointToLine ( pt p1 p2 / nm ) (setq nm (mapcar '- p2 p1) p1 (trans p1 0 nm) pt (trans pt 0 nm) ) (trans (list (car p1) (cadr p1) (caddr pt)) nm 0) ) Edited October 18, 2013 by GP_ Updated code with proposed initial offset = 0.00 Quote
souvik Posted October 18, 2013 Author Posted October 18, 2013 Thank you GP_ Sir. But when I'm trying to run this lisp my points and texts are not mooving. I have points and single line text and one line. As prompted by the lisp I'm selecting the points first then right click then selecting the reference line and again right click, but nothing happens. Am I making any mistake? Quote
GP_ Posted October 18, 2013 Posted October 18, 2013 ...and again right click... Enter offset distance... Updated code with proposed initial offset = 0.00 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.