Saqib_theleo Posted February 18, 2012 Posted February 18, 2012 Welcome to the forum Saqib_theleo, Looks like you heed my advice and posted your request where you got the orignal code. Now. what exactly do you need? What you're asking is not that difficult at all, only, there are a couple of codes (AlanjT/LM/Tharwat/.... ) posted on this thread, i suggest you try them all first and see what code is better suited for your needs (you know what they say about re-inventing the wheel) [bTW: who are these people they cal "THEY" ? is there a building out there with a room that says "THEY" on the door? ] Or maybe, you need an entirely different routine. Hi pBe, Thanks and yes I heeded your advice and posted my request in here. I tried those codes you suggested but they are not as good as this one (which is #09 post) I posted on my request. I don't need any different code this Lisp is good but the problem is, this is working with Line only not any PLine. I just want you to change this Lisp so that it could work with Line and PLine. (and I don't know about these people who call "THEY" or any building ) Thanks. Quote
pBe Posted February 19, 2012 Posted February 19, 2012 (edited) Hi pBe,I tried those codes you suggested but they are not as good as this one (which is #09 post) I posted on my request. I don't need any different code this Lisp is good but the problem is, this is working with Line only not any PLine. I just want you to change this Lisp so that it could work with Line and PLine. Thanks. Oh well, just so you know, the code posted on #9 requries a specific conditions from the original OP. and the rest of the codes posted on this thread has their own unique qualities depending on a given set of conditions. Anyhoo. i do believe your needs requires another approach. by combining the codes on this thread (defun c:ofn (/ ss i ent d) ;;; pBe Feb2012 ;;; ;;; kudos to Alanjt/LM/Wizman ;;; (vl-load-com) (if (and (setq dist (cond ((getdist (strcat "\nSpecify offset Distance" (if (numberp dist) (strcat " <" (rtos dist) ">: ") ": " )))) (dist))) (setq rep (cond ((getint (strcat "\nSpecify Number of offset" (if (numberp rep) (strcat " <" (itoa rep) ">: ") ": " )))) (rep))) (setq ss (ssget "_:L" '((0 . "ARC,CIRCLE,ELLIPSE,*LINE")))) ) (repeat (setq i (sslength ss)) (setq ent (ssname ss (setq i (1- i)))) (redraw ent 3) (setq sd (getpoint "\nPick Side to Offset:")) (redraw ent 4) (setq d dist) (repeat rep (command "._offset" d ent sd "") (setq d (+ d dist)) ) ) ) (princ) ) HTH Edited February 19, 2012 by pBe Quote
Saqib_theleo Posted February 19, 2012 Posted February 19, 2012 Oh well, just so you know, the code posted on #9 requries a specific conditions from the original OP. and the rest of the codes posted on this thread has their own unique qualities depending on a given set of conditions. Anyhoo. i do believe your needs requires another approach. by combining the codes on this thread (defun c:ofn (/ ss i ent d) ;;; pBe Feb2012 ;;; ;;; kudos to Alanjt/LM/Wizman ;;; (vl-load-com) (if (and (setq dist (cond ((getdist (strcat "\nSpecify offset Distance" (if (numberp dist) (strcat " <" (rtos dist) ">: ") ": " )))) (dist))) (setq rep (cond ((getint (strcat "\nSpecify Number of offset" (if (numberp rep) (strcat " <" (itoa rep) ">: ") ": " )))) (rep))) (setq ss (ssget "_:L" '((0 . "ARC,CIRCLE,ELLIPSE,*LINE")))) ) (repeat (setq i (sslength ss)) (setq ent (ssname ss (setq i (1- i)))) (redraw ent 3) (setq sd (getpoint "\nPick Side to Offset:")) (redraw ent 4) (setq d dist) (repeat rep (command "._offset" d ent sd "") (setq d (+ d dist)) ) ) ) (princ) ) HTH Hi pBe, Yes, now it is working as I want. I am thankful to you for your time and good help. *YTH* Thanks again. Take care. Quote
pBe Posted February 20, 2012 Posted February 20, 2012 Hi pBe,Yes, now it is working as I want. I am thankful to you for your time and good help. *YTH* Thanks again. Take care. Glad i could help Cheers Quote
AVS801 Posted January 2, 2020 Posted January 2, 2020 Hi, I have the following task: There is a closed polyline. I need to do OFFSET outside by a certain distance. At the moment my Lisp code is the following, but it doesn't work properly if the original polyline has counter clock wise orientation (offset goes inside not outside). Has anyone faced such a task? [LISP](defun c:offsetout (/) (while t (setq offset (getreal "\nInput offset distance :")) (while (not(setq ent_point (entsel "\nSelect an object or press ESC :")))) (setq ent (nth 0 ent_point)) (setq vla_obj (vlax-ename->vla-object ent)) (setq offsetObj1 (vla-Offset vla_obj (* -1 offset))) ;(setq offsetObj2 (vla-Offset vla_obj (* 1 offset))) (setq vla_obj1 (vlax-ename->vla-object (car(offsetObj1)))) ; (vlax-dump-object vla_obj1) ); end while ); end defun[/LISP][/CODE] Quote
BIGAL Posted January 4, 2020 Posted January 4, 2020 (edited) Offset, dist, pick pline, (getvar 'extmax) The extmax is always outside your pline or exactly on it so as a safety add say 10 to x value. This should fix inside outside. Use old fashioned (command . Edited January 4, 2020 by BIGAL Quote
dlanorh Posted January 4, 2020 Posted January 4, 2020 (edited) Try this. The Polyline must be a LWPolyline and the 'closed property set as true. It can be adjusted to compensate for open polylines where the start and end point are the same but not closed. To exit the loop just select a blank area of the screen when asked to select an object. (defun c:moff (/ o_dst sel obj n_obj) (setq o_dst (getreal "\nInput offset distance :")) (while (setq sel (entsel "\nSelect an Object : ")) (setq obj (vlax-ename->vla-object (car sel))) (cond ( (and (= (vlax-get-property obj 'objectname) "AcDbPolyline") (= :vlax-true (vlax-get-property obj 'closed)) );end_and (setq n_obj (car (vlax-invoke obj 'offset o_dst))) (cond ( (< (vlax-get n_obj 'area) (vlax-get obj 'area)) (vla-delete n_obj) (setq n_obj (vlax-invoke obj 'offset (* o_dst -1.0))) ) );end_cond ) ( (alert "NOT a Closed Polyline")) );end_cond );end_while );end_defun Edited January 4, 2020 by dlanorh clarity Quote
BIGAL Posted January 5, 2020 Posted January 5, 2020 Another, open pline still works, try it. A zig zag may give un predictable results, 3 sided seem fine. (defun c:moff (/ o_dst sel obj n_obj) (setq o_dst (getreal "\nInput offset distance :")) (while (setq sel (entsel "\nSelect an Object : ")) (setq pt (getvar 'extmax)) (setq pt (list (+ (car pt) 10.0)(+ (cadr pt) 10.0))) (command "offset" o_dst sel pt) ) ) (c:moff) 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.