motee-z Posted February 23, 2013 Share Posted February 23, 2013 hello i have polyline i want to make it start from end point and leave it if it is start from same picked point i mean reverse the polyline if i pick end point of it and leave it if i pick start point of it any help will be appreciated thank you Quote Link to comment Share on other sites More sharing options...
Stefan BMR Posted February 23, 2013 Share Posted February 23, 2013 (defun C:PLREV ( / s e p p1) (if (and (setq s (entsel)) (wcmatch (cdr (assoc 0 (entget (setq e (car s))))) "*POLYLINE") ) (progn (setq p (vlax-curve-getParamAtPoint e (vlax-curve-getClosestPointTo e (trans (cadr s) 1 0))) ; or (trans (osnap (cadr s) "_nea") 1 0) - for any view and UCS p1 (vlax-curve-getEndParam e) ) (if (> p (/ p1 2.0)) (vl-cmdf "_PEDIT" e "_R" "") ;will convert 2dPolyline to LWpolyline ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
motee-z Posted February 23, 2013 Author Share Posted February 23, 2013 thank stefan i don't know to use your routin what i want the sequence of command line select polyline choose a point to be start point result polyline change its direction if picked point is the end of polyline and stay as is if it picked point is the start of polyline Quote Link to comment Share on other sites More sharing options...
Stefan BMR Posted February 23, 2013 Share Posted February 23, 2013 thank stefani don't know to use your routin what i want the sequence of command line select polyline choose a point to be start point result polyline change its direction if picked point is the end of polyline and stay as is if it picked point is the start of polyline Hi motee-z, My routine combine first two steps. So when you are prompted to select object, just click on a polyline near to the desired end. Quote Link to comment Share on other sites More sharing options...
MSasu Posted February 23, 2013 Share Posted February 23, 2013 (edited) Motee-z, you didn't listed in your profile the software/version you are currently using. Please note that the built-in PEDIT command have - starting with version 2010, I believe - an option named Reverse that seems exactly what you were looking for. Edited February 23, 2013 by MSasu Quote Link to comment Share on other sites More sharing options...
motee-z Posted February 23, 2013 Author Share Posted February 23, 2013 thank you stefan now every thing clear thank you for illustration Quote Link to comment Share on other sites More sharing options...
Stefan BMR Posted February 23, 2013 Share Posted February 23, 2013 You are welcome motee-z. I just realized that parameter of pline is not the correct way to establish what end you've picked. So I've switched to distance and added some new features. Now it becomes: (defun C:PLREV (/ *error* acDoc msg s e en d d1 l) (setq acDoc (vla-get-activedocument (vlax-get-acad-object))) (vla-StartUndoMark acDoc) (defun *error* (msg) (and msg (not (eq msg "Function cancelled")) (princ msg)) (vla-EndUndoMark acDoc) ) (while (progn (setvar 'errno 0) (or (progn (initget "Undo") (setq s (entsel "\nSelect a polyline [undo] <Exit>: ")) ) (= (getvar 'errno) 7) ) ) (cond ((eq s "Undo") (if l (progn (vl-cmdf "_PEDIT" (car l) "_R" "") (setq l (cdr l)) ) (princ "\nNothing to undo") ) ) ((and (setq msg "\nNothing selected. Try again") s (setq msg "\nPlease select a polyline") (wcmatch (cdr (assoc 0 (setq en (entget (setq e (car s)))))) "*POLYLINE") (setq msg "\nObject is on a locked layer") (zerop (logand (cdr (assoc 70 (tblsearch "layer" (cdr (assoc 8 en))))) 4)) ) (setq d (vlax-curve-getDistAtPoint e (vlax-curve-getClosestPointTo e (trans (cadr s) 1 0))) d1 (vlax-curve-getDistAtPoint e (vlax-curve-getEndPoint e)) ) (if (> d (/ d1 2.0)) (progn (vl-cmdf "_PEDIT" e "_R" "") (setq l (cons e l)) ) (princ "\nPick the other end to reverse") ) ) (T (princ msg)) ) ) (*error* nil) (princ) ) Quote Link to comment Share on other sites More sharing options...
motee-z Posted February 23, 2013 Author Share Posted February 23, 2013 can we extract (s) variable from dxf of polyline (setq plDxf(entget(car(entsel"\pick polyline")))) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 23, 2013 Share Posted February 23, 2013 can we extract (s) variable from dxf of polyline(setq plDxf(entget(car(entsel"\pick polyline")))) What variables you are indicating to ? Quote Link to comment Share on other sites More sharing options...
motee-z Posted February 23, 2013 Author Share Posted February 23, 2013 hello tharwat variable mentioned in stefan routine (setq s (entsel "\nSelect a polyline [undo] : ")) Quote Link to comment Share on other sites More sharing options...
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.