transcad Posted March 28, 2012 Posted March 28, 2012 How can i determine y coordinate for a point on a lwpolyline, if i know his x coordinates? Quote
Tharwat Posted March 28, 2012 Posted March 28, 2012 can you show us how did you get his x coordinate ? Quote
ketxu Posted March 28, 2012 Posted March 28, 2012 You just find inters of LWPline with a xline // OY and has same x coord, then delete xline ^^ Quote
MSasu Posted March 28, 2012 Posted March 28, 2012 Just draw a vertical line on that particular X coordinate and use the intersection functions shared by LeeMac to find the intersection point with your polyline. Regards, Mircea Quote
MSasu Posted March 28, 2012 Posted March 28, 2012 can you show us how did you get his x coordinate ? That make no difference; for example he may want to get the elevation on a given profile at a given station. Regards, Mircea Quote
transcad Posted March 28, 2012 Author Posted March 28, 2012 I'm trying to do this (intest of a poly with xline), but ...something wrong... (defun c:ii () (vl-load-com) (setq util (vla-get-utility (vla-get-activedocument (vlax-get-acad-object)))) (vla-getentity util 'obj1 'ip "\nSelect First Object: ") (vla-getentity util 'obj2 'ip "\nSelect Second Object: ") (setq int (vla-IntersectWith obj1 obj2 acExtendBoth)) (princ int) (setq p (vlax-safearray->list (vlax-variant-value int))) (princ) );defun Quote
MSasu Posted March 28, 2012 Posted March 28, 2012 If will replace with the code from Lee's function, that will return the point: (setq int (vlax-invoke obj1 'IntersectWith obj2 acExtendBoth)) Regards, Mircea Quote
Tharwat Posted March 28, 2012 Posted March 28, 2012 Check this one now ... (defun c:TesT (/ obj1 obj2 int p) (vl-load-com) (if (and (progn (prompt " Select First Object: ") (setq obj1 (ssget "_+.:S" '((0 . "*POLYLINE")))) ) (progn (prompt " Select Second Object : ") (setq obj2 (ssget "_+.:S" '((0 . "*POLYLINE")))) ) ) (if (and (not (vlax-curve-isclosed (ssname obj1 0))) (not (vlax-curve-isclosed (ssname obj2 0))) ) (progn (setq int (vla-IntersectWith (vlax-ename->vla-object (ssname obj1 0)) (vlax-ename->vla-object (ssname obj2 0)) acExtendBoth ) ) (princ (setq p (vlax-safearray->list (vlax-variant-value int ) ) ) ) ) (princ "\n One of Polylines is closed ") ) (princ) ) (princ) ) Quote
transcad Posted March 28, 2012 Author Posted March 28, 2012 Maybe my variable are not ok, but the intersection point is ALWAYS close to the real intersection point... Quote
Tharwat Posted March 28, 2012 Posted March 28, 2012 (defun c:ii () ... .... [b][color="red"](princ[/color][/b] (setq p (vlax-safearray->list (vlax-variant-value int)))) ..... ..... It worked for me ... Quote
MSasu Posted March 28, 2012 Posted March 28, 2012 @transcad: I took the liberty to adjust a little your code: (defun c:ii () (vl-load-com) (setq util (vla-get-utility (vla-get-activedocument (vlax-get-acad-object)))) (vla-getentity util 'obj1 'ip "\nSelect First Object: ") (if (and obj1 (setq xCoord (getpoint "\nPick X ccordinate: "))) (progn (entmakex (list '(0 . "LINE") (cons 10 (polar xCoord (* -0.5 pi) 1.0)) (cons 11 (polar xCoord (* 0.5 pi) 1.0)))) (setq obj2 (vlax-ename->vla-object (setq tmpEnt (entlast)))) (setq int (vlax-invoke obj1 'IntersectWith obj2 acExtendBoth)) (princ int) (entdel tmpEnt) ) ) (princ) ) ;defun Regards, Mircea Quote
transcad Posted March 28, 2012 Author Posted March 28, 2012 It's ok guys, thanks! My mistake... 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.