notview Posted April 26, 2015 Posted April 26, 2015 Hi guys, is there a way to remove or erase portion of polyline in shortest way by lisp, as shown at the figure attached.. Quote
Lee Mac Posted April 26, 2015 Posted April 26, 2015 You can use the TRIM command to erase the segment. Quote
notview Posted April 26, 2015 Author Posted April 26, 2015 Thank you LM. TRIM command is done well in figure at left, but figure at right will not erase, only trim portion. Figure at right is polyline with two vertex. Is this possible to make lisp routine, if select two vertex polyline it will erase, combining to TRIM. The figure shown above is only portion of my work, sometimes many polyline crossing each other, TRIM command alone will not solve my problem. Thank you for your help! Quote
Tharwat Posted April 27, 2015 Posted April 27, 2015 Try this : (defun c:Test (/ s o a b c) ;;; Tharwat 27.4.2015 ;;; (if (and (setq s (entsel "\n Select a Polyline to trim segment :")) (wcmatch (cdr (assoc 0 (entget (setq o (car s))))) "*POLYLINE") ) (cond ((= (cdr (assoc 90 (entget o))) 2) (entdel o)) (t (setq a (fix (vlax-curve-getparamatpoint o (vlax-curve-getclosestpointto o (cadr s)))) b (vlax-curve-getpointatparam o a) c (vlax-curve-getpointatparam o (1+ a)) ) (command "_.Break" o "_none" b "_none" c "") ) ) ) (princ) ) Quote
notview Posted April 27, 2015 Author Posted April 27, 2015 It's great!! Tharwat. It help me a lot.. Only command at a time, can you make this continue until escape and, or, select more than one then trim/erase the selected segments. Thank you Tharwat!! It solved my problem.. hahaha.. Quote
Tharwat Posted April 27, 2015 Posted April 27, 2015 It's great!! Tharwat.Thank you Tharwat!! It solved my problem.. hahaha.. Excellent , happy to hear that It help me a lot.. Only command at a time, can you make this continue until escape and, or, select more than one then trim/erase the selected segments. No you can not use multiple selection with this task but if you wan to keep the program running until you hit enter , just replace the IF function with while . Try not to use Escape button for any command unless you have no way to , so hit enter would avoid errors messages and exit commands safely ( in general ) . Good luck . Quote
notview Posted April 27, 2015 Author Posted April 27, 2015 Thank you to advice and to your time of this code, it save me a lot of time. Superb! Everything is fine. Thank you Tharwat! Quote
Tharwat Posted April 27, 2015 Posted April 27, 2015 Thank you to advice and to your time of this code, it save me a lot of time. Superb! Everything is fine. Thank you Tharwat! You are welcome anytime . Quote
martinle Posted April 28, 2015 Posted April 28, 2015 Hello Tharwat. I have problems when I'm out in the BCS with this Lisp. There it did not work. Could you gaze again what could be missing here? Martin Quote
Tharwat Posted April 28, 2015 Posted April 28, 2015 Hello Tharwat. I have problems when I'm out in the BCS with this Lisp. There it did not work. Could you gaze again what could be missing here? Martin Hi Martin , happy to see you posting again Yeah, I guess the routine works only with WCS . Can you upload a sample drawing to allow me to try it out with that system ? Quote
martinle Posted April 28, 2015 Posted April 28, 2015 Hello Tharwat, unfortunately I do not know how you attach a file. Martin Quote
Tharwat Posted April 28, 2015 Posted April 28, 2015 Take a look at the right side hand down of the forum and there must be a button called Go Advanced , hit the button then you should be able to find the attach button and lots of other interesting things Quote
Tharwat Posted April 28, 2015 Posted April 28, 2015 Unfortunately I could not make it working on other than WCS , I am sorry Quote
Tharwat Posted April 28, 2015 Posted April 28, 2015 If you transfer your drawing into WCS , the program should work as expected otherwise no luck with it . Quote
Lee Mac Posted April 28, 2015 Posted April 28, 2015 The following modifications should enable UCS compatibility: (defun c:test ( / a e s x ) ;;; Tharwat 27.4.2015 ;;; (if (and (setq s (entsel "\nSelect polyline to trim segment: ")) (setq e (car s) x (entget e) ) (= "LWPOLYLINE" (cdr (assoc 0 x))) ) (if (= 2 (cdr (assoc 90 x))) (entdel e) (progn (setq a (fix (vlax-curve-getparamatpoint e (vlax-curve-getclosestpointto e (trans (cadr s) 1 0))))) (command "_.break" s "_f" "_non" (trans (vlax-curve-getpointatparam e a) 0 1) "_non" (trans (vlax-curve-getpointatparam e (1+ a)) 0 1) ) ) ) ) (princ) ) Good solution Tharwat 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.