Jojo Posted September 26 Author Posted September 26 3 hours ago, marko_ribar said: Also I've made few changes to original code... (added - (initget) before (getstring) which is changed to (getkword)) and (atof (strcat dir (cdr (assoc 1 data)))) Not tested though... (Pozdrav, Saxlle...) ; ***************************************************************************************************************** ; Functions : MOBT ; Description : Offset LINE or POLYLINE multiple times based on text or mtext in choosen direction ; Author : SAXLLE ; Date : September 14, 2024 ; Update 1.0 : Solved a problem when LINE or POLYLINE has been drawn from bottom-to-top or top-to-bottom ; where the user can choose to reverse the drawing direction or not ; Update date : September 15, 2024 ; ***************************************************************************************************************** (prompt "\nTo run a LISP type: MOBT") (princ) (defun c:MOBT (/ ename spt ept answ dir ss len i data) (or (not (vl-catch-all-error-p (vl-catch-all-apply (function vlax-get-acad-object) nil))) (vl-load-com)) (setq old_osm (getvar "osmode")) (setvar "osmode" 0) (setq ename (car (entsel "\nSelect LINE or POLYLINE to offset:"))) (princ) (while (not (or (= "LINE" (cdr (assoc 0 (entget ename)))) (= "LWPOLYLINE" (cdr (assoc 0 (entget ename)))))) (prompt "\nSelected entity must be LINE or POLYLINE. Try again...") (setq ename (car (entsel "\nSelect LINE or POLYLINE to offset:"))) (princ) ) (cond ((= "LINE" (cdr (assoc 0 (entget ename)))) (setq spt (vlax-curve-getStartPoint (vlax-ename->vla-object ename))) (setq ept (vlax-curve-getEndPoint (vlax-ename->vla-object ename))) (if (> (cadr ept) (cadr spt)) (progn (initget 1 "Y N y n Yes No yes no YES NO") (setq answ (getkword "\nThe selected entity has been drawn from bottom-to-top. Do you want to reverse direction? [Yes/No]")) (if (or (= answ "Y") (= answ "y") (= answ "Yes") (= answ "yes") (= answ "YES")) (progn (command "._reverse" ename "") (princ "\nThe selected entity has changed direction from top-to-bottom.") (princ) (initget 1 "- +") (setq dir (getkword "\nChoose a side for offset [- Left/+ Right]:")) (princ) (prompt "\nSelect the TEXT or MTEXT with numbers for offset:") (terpri) (setq ss (ssget '((0 . "TEXT,MTEXT")))) (setq len (sslength ss)) (setq i 0) (while (< i len) (setq data (entget (ssname ss i))) (vla-Offset (vlax-ename->vla-object ename) (atof (strcat dir (cdr (assoc 1 data))))) (setq i (1+ i)) ) ) (progn (prompt "\nThe selected entity retains the current direction from bottom-to-top.") (princ) (initget 1 "- +") (setq dir (getkword "\nChoose a side for offset [+ Left/- Right]:")) (princ) (prompt "\nSelect the TEXT or MTEXT with numbers for offset:") (terpri) (setq ss (ssget '((0 . "TEXT,MTEXT")))) (setq len (sslength ss)) (setq i 0) (while (< i len) (setq data (entget (ssname ss i))) (vla-Offset (vlax-ename->vla-object ename) (atof (strcat dir (cdr (assoc 1 data))))) (setq i (1+ i)) ) ) ) ) (progn (initget 1 "Y N y n Yes No yes no YES NO") (setq answ (getkword "\nThe selected entity has been drawn from top-to-bottom. Do you want to reverse direction? [Yes/No]")) (if (or (= answ "Y") (= answ "y") (= answ "Yes") (= answ "yes") (= answ "YES")) (progn (command "._reverse" ename "") (princ "\nThe selected entity has changed direction from bottom-to-top.") (princ) (initget 1 "- +") (setq dir (getkword "\nChoose a side for offset [+ Left/- Right]:")) (princ) (prompt "\nSelect the TEXT or MTEXT with numbers for offset:") (terpri) (setq ss (ssget '((0 . "TEXT,MTEXT")))) (setq len (sslength ss)) (setq i 0) (while (< i len) (setq data (entget (ssname ss i))) (vla-Offset (vlax-ename->vla-object ename) (atof (strcat dir (cdr (assoc 1 data))))) (setq i (1+ i)) ) ) (progn (prompt "\nThe selected entity retains the current direction from top-to-bottom.") (princ) (initget 1 "- +") (setq dir (getkword "\nChoose a side for offset [- Left/+ Right]:")) (princ) (prompt "\nSelect the TEXT or MTEXT with numbers for offset:") (terpri) (setq ss (ssget '((0 . "TEXT,MTEXT")))) (setq len (sslength ss)) (setq i 0) (while (< i len) (setq data (entget (ssname ss i))) (vla-Offset (vlax-ename->vla-object ename) (atof (strcat dir (cdr (assoc 1 data))))) (setq i (1+ i)) ) ) ) ) ) ) ((= "LWPOLYLINE" (cdr (assoc 0 (entget ename)))) (setq spt (vlax-curve-getStartPoint (vlax-ename->vla-object ename))) (setq ept (vlax-curve-getEndPoint (vlax-ename->vla-object ename))) (if (> (cadr ept) (cadr spt)) (progn (initget 1 "Y N y n Yes No yes no YES NO") (setq answ (getkword "\nThe selected entity has been drawn from bottom-to-top. Do you want to reverse direction? [Yes/No]")) (if (or (= answ "Y") (= answ "y") (= answ "Yes") (= answ "yes") (= answ "YES")) (progn (command "._reverse" ename "") (princ "\nThe selected entity has changed direction from top-to-bottom.") (princ) (initget 1 "- +") (setq dir (getkword "\nChoose a side for offset [+ Left/- Right]:")) (princ) (prompt "\nSelect the TEXT or MTEXT with numbers for offset:") (terpri) (setq ss (ssget '((0 . "TEXT,MTEXT")))) (setq len (sslength ss)) (setq i 0) (while (< i len) (setq data (entget (ssname ss i))) (vla-Offset (vlax-ename->vla-object ename) (atof (strcat dir (cdr (assoc 1 data))))) (setq i (1+ i)) ) ) (progn (prompt "\nThe selected entity retains the current direction from bottom-to-top.") (princ) (initget 1 "- +") (setq dir (getkword "\nChoose a side for offset [- Left/+ Right]:")) (princ) (prompt "\nSelect the TEXT or MTEXT with numbers for offset:") (terpri) (setq ss (ssget '((0 . "TEXT,MTEXT")))) (setq len (sslength ss)) (setq i 0) (while (< i len) (setq data (entget (ssname ss i))) (vla-Offset (vlax-ename->vla-object ename) (atof (strcat dir (cdr (assoc 1 data))))) (setq i (1+ i)) ) ) ) ) (progn (initget 1 "Y N y n Yes No yes no YES NO") (setq answ (getkword "\nThe selected entity has been drawn from top-to-bottom. Do you want to reverse direction? [Yes/No]")) (if (or (= answ "Y") (= answ "y") (= answ "Yes") (= answ "yes") (= answ "YES")) (progn (command "._reverse" ename "") (princ "\nThe selected entity has changed direction from bottom-to-top.") (princ) (initget 1 "- +") (setq dir (getkword "\nChoose a side for offset [- Left/+ Right]:")) (princ) (prompt "\nSelect the TEXT or MTEXT with numbers for offset:") (terpri) (setq ss (ssget '((0 . "TEXT,MTEXT")))) (setq len (sslength ss)) (setq i 0) (while (< i len) (setq data (entget (ssname ss i))) (vla-Offset (vlax-ename->vla-object ename) (atof (strcat dir (cdr (assoc 1 data))))) (setq i (1+ i)) ) ) (progn (prompt "\nThe selected entity retains the current direction from top-to-bottom.") (princ) (initget 1 "- +") (setq dir (getkword "\nChoose a side for offset [+ Left/- Right]:")) (princ) (prompt "\nSelect the TEXT or MTEXT with numbers for offset:") (terpri) (setq ss (ssget '((0 . "TEXT,MTEXT")))) (setq len (sslength ss)) (setq i 0) (while (< i len) (setq data (entget (ssname ss i))) (vla-Offset (vlax-ename->vla-object ename) (atof (strcat dir (cdr (assoc 1 data))))) (setq i (1+ i)) ) ) ) ) ) ) ) (setvar "osmode" old_osm) (princ (strcat "\nThe " (cdr (assoc 0 (entget ename))) " is offseted " (rtos len 2 0) " times.")) (princ) ) Marko. It works!!!! I'm so HAPPY...........Thank you Marko and thank everybody. Video attached. Recording 2024-09-26 .mp4 Quote
Saxlle Posted September 27 Posted September 27 16 hours ago, marko_ribar said: Also I've made few changes to original code... (added - (initget) before (getstring) which is changed to (getkword)) and (atof (strcat dir (cdr (assoc 1 data)))) Not tested though... (Pozdrav, Saxlle...) ; ***************************************************************************************************************** ; Functions : MOBT ; Description : Offset LINE or POLYLINE multiple times based on text or mtext in choosen direction ; Author : SAXLLE ; Date : September 14, 2024 ; Update 1.0 : Solved a problem when LINE or POLYLINE has been drawn from bottom-to-top or top-to-bottom ; where the user can choose to reverse the drawing direction or not ; Update date : September 15, 2024 ; ***************************************************************************************************************** (prompt "\nTo run a LISP type: MOBT") (princ) (defun c:MOBT (/ ename spt ept answ dir ss len i data) (or (not (vl-catch-all-error-p (vl-catch-all-apply (function vlax-get-acad-object) nil))) (vl-load-com)) (setq old_osm (getvar "osmode")) (setvar "osmode" 0) (setq ename (car (entsel "\nSelect LINE or POLYLINE to offset:"))) (princ) (while (not (or (= "LINE" (cdr (assoc 0 (entget ename)))) (= "LWPOLYLINE" (cdr (assoc 0 (entget ename)))))) (prompt "\nSelected entity must be LINE or POLYLINE. Try again...") (setq ename (car (entsel "\nSelect LINE or POLYLINE to offset:"))) (princ) ) (cond ((= "LINE" (cdr (assoc 0 (entget ename)))) (setq spt (vlax-curve-getStartPoint (vlax-ename->vla-object ename))) (setq ept (vlax-curve-getEndPoint (vlax-ename->vla-object ename))) (if (> (cadr ept) (cadr spt)) (progn (initget 1 "Y N y n Yes No yes no YES NO") (setq answ (getkword "\nThe selected entity has been drawn from bottom-to-top. Do you want to reverse direction? [Yes/No]")) (if (or (= answ "Y") (= answ "y") (= answ "Yes") (= answ "yes") (= answ "YES")) (progn (command "._reverse" ename "") (princ "\nThe selected entity has changed direction from top-to-bottom.") (princ) (initget 1 "- +") (setq dir (getkword "\nChoose a side for offset [- Left/+ Right]:")) (princ) (prompt "\nSelect the TEXT or MTEXT with numbers for offset:") (terpri) (setq ss (ssget '((0 . "TEXT,MTEXT")))) (setq len (sslength ss)) (setq i 0) (while (< i len) (setq data (entget (ssname ss i))) (vla-Offset (vlax-ename->vla-object ename) (atof (strcat dir (cdr (assoc 1 data))))) (setq i (1+ i)) ) ) (progn (prompt "\nThe selected entity retains the current direction from bottom-to-top.") (princ) (initget 1 "- +") (setq dir (getkword "\nChoose a side for offset [+ Left/- Right]:")) (princ) (prompt "\nSelect the TEXT or MTEXT with numbers for offset:") (terpri) (setq ss (ssget '((0 . "TEXT,MTEXT")))) (setq len (sslength ss)) (setq i 0) (while (< i len) (setq data (entget (ssname ss i))) (vla-Offset (vlax-ename->vla-object ename) (atof (strcat dir (cdr (assoc 1 data))))) (setq i (1+ i)) ) ) ) ) (progn (initget 1 "Y N y n Yes No yes no YES NO") (setq answ (getkword "\nThe selected entity has been drawn from top-to-bottom. Do you want to reverse direction? [Yes/No]")) (if (or (= answ "Y") (= answ "y") (= answ "Yes") (= answ "yes") (= answ "YES")) (progn (command "._reverse" ename "") (princ "\nThe selected entity has changed direction from bottom-to-top.") (princ) (initget 1 "- +") (setq dir (getkword "\nChoose a side for offset [+ Left/- Right]:")) (princ) (prompt "\nSelect the TEXT or MTEXT with numbers for offset:") (terpri) (setq ss (ssget '((0 . "TEXT,MTEXT")))) (setq len (sslength ss)) (setq i 0) (while (< i len) (setq data (entget (ssname ss i))) (vla-Offset (vlax-ename->vla-object ename) (atof (strcat dir (cdr (assoc 1 data))))) (setq i (1+ i)) ) ) (progn (prompt "\nThe selected entity retains the current direction from top-to-bottom.") (princ) (initget 1 "- +") (setq dir (getkword "\nChoose a side for offset [- Left/+ Right]:")) (princ) (prompt "\nSelect the TEXT or MTEXT with numbers for offset:") (terpri) (setq ss (ssget '((0 . "TEXT,MTEXT")))) (setq len (sslength ss)) (setq i 0) (while (< i len) (setq data (entget (ssname ss i))) (vla-Offset (vlax-ename->vla-object ename) (atof (strcat dir (cdr (assoc 1 data))))) (setq i (1+ i)) ) ) ) ) ) ) ((= "LWPOLYLINE" (cdr (assoc 0 (entget ename)))) (setq spt (vlax-curve-getStartPoint (vlax-ename->vla-object ename))) (setq ept (vlax-curve-getEndPoint (vlax-ename->vla-object ename))) (if (> (cadr ept) (cadr spt)) (progn (initget 1 "Y N y n Yes No yes no YES NO") (setq answ (getkword "\nThe selected entity has been drawn from bottom-to-top. Do you want to reverse direction? [Yes/No]")) (if (or (= answ "Y") (= answ "y") (= answ "Yes") (= answ "yes") (= answ "YES")) (progn (command "._reverse" ename "") (princ "\nThe selected entity has changed direction from top-to-bottom.") (princ) (initget 1 "- +") (setq dir (getkword "\nChoose a side for offset [+ Left/- Right]:")) (princ) (prompt "\nSelect the TEXT or MTEXT with numbers for offset:") (terpri) (setq ss (ssget '((0 . "TEXT,MTEXT")))) (setq len (sslength ss)) (setq i 0) (while (< i len) (setq data (entget (ssname ss i))) (vla-Offset (vlax-ename->vla-object ename) (atof (strcat dir (cdr (assoc 1 data))))) (setq i (1+ i)) ) ) (progn (prompt "\nThe selected entity retains the current direction from bottom-to-top.") (princ) (initget 1 "- +") (setq dir (getkword "\nChoose a side for offset [- Left/+ Right]:")) (princ) (prompt "\nSelect the TEXT or MTEXT with numbers for offset:") (terpri) (setq ss (ssget '((0 . "TEXT,MTEXT")))) (setq len (sslength ss)) (setq i 0) (while (< i len) (setq data (entget (ssname ss i))) (vla-Offset (vlax-ename->vla-object ename) (atof (strcat dir (cdr (assoc 1 data))))) (setq i (1+ i)) ) ) ) ) (progn (initget 1 "Y N y n Yes No yes no YES NO") (setq answ (getkword "\nThe selected entity has been drawn from top-to-bottom. Do you want to reverse direction? [Yes/No]")) (if (or (= answ "Y") (= answ "y") (= answ "Yes") (= answ "yes") (= answ "YES")) (progn (command "._reverse" ename "") (princ "\nThe selected entity has changed direction from bottom-to-top.") (princ) (initget 1 "- +") (setq dir (getkword "\nChoose a side for offset [- Left/+ Right]:")) (princ) (prompt "\nSelect the TEXT or MTEXT with numbers for offset:") (terpri) (setq ss (ssget '((0 . "TEXT,MTEXT")))) (setq len (sslength ss)) (setq i 0) (while (< i len) (setq data (entget (ssname ss i))) (vla-Offset (vlax-ename->vla-object ename) (atof (strcat dir (cdr (assoc 1 data))))) (setq i (1+ i)) ) ) (progn (prompt "\nThe selected entity retains the current direction from top-to-bottom.") (princ) (initget 1 "- +") (setq dir (getkword "\nChoose a side for offset [+ Left/- Right]:")) (princ) (prompt "\nSelect the TEXT or MTEXT with numbers for offset:") (terpri) (setq ss (ssget '((0 . "TEXT,MTEXT")))) (setq len (sslength ss)) (setq i 0) (while (< i len) (setq data (entget (ssname ss i))) (vla-Offset (vlax-ename->vla-object ename) (atof (strcat dir (cdr (assoc 1 data))))) (setq i (1+ i)) ) ) ) ) ) ) ) (setvar "osmode" old_osm) (princ (strcat "\nThe " (cdr (assoc 0 (entget ename))) " is offseted " (rtos len 2 0) " times.")) (princ) ) Thank you Marko. (Hvala ti, uradio si izmenu umesto mene. Pozdrav!) Quote
Jojo Posted September 27 Author Posted September 27 On 9/26/2024 at 10:08 AM, Saxlle said: @Jojo The problem is that you type a "r" to offset. You need to enter "+" or "-", or just pick a desire direction to offset line or polyline from command line (you will see a highlighted values "+" or "-"). Best regards. Thank you Saxlle. It work awesome. much appreciated. 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.