Jojo Posted August 29 Author Share Posted August 29 I'm using Carlson Software. The lsp is awesome but instead of offsetting it one at a time, I was wondering if we could highlight all the numbers (text with different numbers) to offset a single line to a different distance. I don't want to offset the text. I really apologize for confusing you. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 30 Share Posted August 30 (edited) So take the zero line and offset it ? Need a dwg before and after, use Wblock to make a new dwg with only relevant objects. Edited August 30 by BIGAL Quote Link to comment Share on other sites More sharing options...
Jojo Posted September 4 Author Share Posted September 4 I apologize that a don't know how to make it wblock. This is before. BEFORE.dwg Quote Link to comment Share on other sites More sharing options...
Jojo Posted September 4 Author Share Posted September 4 This is after. thank you again. AFTER.dwg Quote Link to comment Share on other sites More sharing options...
Jojo Posted September 6 Author Share Posted September 6 You have a good weekend Bigal. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 6 Share Posted September 6 Added to my "to do list". fairly simple just offset or copy a line based on the chainage, will add a Horizontal scale factor. Quote Link to comment Share on other sites More sharing options...
Jojo Posted September 11 Author Share Posted September 11 On 9/6/2024 at 6:24 PM, BIGAL said: Added to my "to do list". fairly simple just offset or copy a line based on the chainage, will add a Horizontal scale factor. Good Morning Bigal. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 12 Share Posted September 12 (edited) Sorry been busy getting behind in a few things. Maybe today. Ok found some time this needs a little bit of adjustment but try it 1st. ; https://www.cadtutor.net/forum/topic/78552-offset-polyline/page/2/ (defun c:loff ( / oldsnap ss ent pt1) ; before & after dwg ;; Parses a list of numerical values from a supplied string. ;; ;;-------------------=={ Parse Numbers }==--------------------;; ;; ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; s - String to process ;; ;;------------------------------------------------------------;; ;; Returns: List of numerical values found in string. ;; ;;------------------------------------------------------------;; (defun LM:ParseNumbers ( s ) ( (lambda ( l ) (read (strcat "(" (vl-list->string (mapcar (function (lambda ( a b c ) (if (or (< 47 b 58) (and (= 45 b) (< 47 c 58) (not (< 47 a 58))) (and (= 46 b) (< 47 a 58) (< 47 c 58)) ) b 32 ) ) ) (cons nil l) l (append (cdr l) (list nil)) ) ) ")" ) ) ) (vl-string->list s) ) ) (setq oldsnap (getvar 'osmode)) (setvar 'osmode 0) (prompt "\nSelect text ") (setq ss (ssget '((0 ."TEXT")))) (setq ent (entsel "\nPick zero line ")) (repeat (setq x (sslength ss)) (setq str (cdr (assoc 1 (entget (ssname ss (setq x (1- x))))))) (setq d (car (LM:ParseNumbers str))) (command "copy" ent "" "0,0,0" (list d 0.0 0.0)) (setq pt1 (cdr (assoc 10 (entget (entlast))))) (command "text" pt1 2.5 90 str) ) (setvar 'osmode oldsanp) (princ) ) Edited September 14 by BIGAL Quote Link to comment Share on other sites More sharing options...
Jojo Posted September 12 Author Share Posted September 12 17 hours ago, BIGAL said: Sorry been busy getting behind in a few things. Maybe today. Ok found some time this needs a little bit of adjustment but try it 1st. ; https://www.cadtutor.net/forum/topic/78552-offset-polyline/page/2/ (defun c:loff ( / oldsnap ss ent pt1) ; before & after dwg ;; Parses a list of numerical values from a supplied string. ;; ;;-------------------=={ Parse Numbers }==--------------------;; ;; ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; s - String to process ;; ;;------------------------------------------------------------;; ;; Returns: List of numerical values found in string. ;; ;;------------------------------------------------------------;; (defun LM:ParseNumbers ( s ) ( (lambda ( l ) (read (strcat "(" (vl-list->string (mapcar (function (lambda ( a b c ) (if (or (< 47 b 58) (and (= 45 b) (< 47 c 58) (not (< 47 a 58))) (and (= 46 b) (< 47 a 58) (< 47 c 58)) ) b 32 ) ) ) (cons nil l) l (append (cdr l) (list nil)) ) ) ")" ) ) ) (vl-string->list s) ) ) (setq oldsnap (getvar 'osmode)) (setvar 'osmode 0) (setq ss (ssget '((0 ."TEXT")))) (setq ent (entsel "\nPick zero line ")) (repeat (setq x (sslength ss)) (setq str (cdr (assoc 1 (entget (ssname ss (setq x (1- x))))))) (setq d (car (LM:ParseNumbers str))) (command "copy" ent "" "0,0,0" (list d 0.0 0.0)) (setq pt1 (cdr (assoc 10 (entget ent2)))) (command "text" pt1 ht 90 str) ) (setvar 'osmode oldsanp) (princ) ) Yeah, this one did not work. I was just looking for a regular offset by highlighting a bunch of numbers to offset one polyline. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 12 Share Posted September 12 (edited) When you respond "did not work" it does not tell us anything, need to know did you get error messages or wrong objects drawn. Please provide more details. Edited September 12 by BIGAL 1 Quote Link to comment Share on other sites More sharing options...
Jojo Posted September 13 Author Share Posted September 13 19 hours ago, BIGAL said: When you respond "did not work" it does not tell us anything, need to know did you get error messages or wrong objects drawn. Please provide more details. I uppload the lsp and type "loff", and it just ask me to select an object to be frozen. I attached a "Recording 2" for you to see. it's not an offset. Or am I doing it wrong? Recording 2.mp4 Quote Link to comment Share on other sites More sharing options...
Jojo Posted September 13 Author Share Posted September 13 Bigal. I was wondering if you can create a lsp that will offset a line with just highlighting bunch of numbers instead of one at a time. I attached a video as a sample. Thank you in advance. Recording 1.mp4 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 14 Share Posted September 14 Not sure how but posted wrong version the repeat had 2 wrong values in it so code above is updated. Quote Link to comment Share on other sites More sharing options...
Saxlle Posted September 14 Share Posted September 14 (edited) @Jojo According to your posted video ("Recording 2") and explanation in text, try this LISP and see if it works for your neededs. ***Did a little update in code (hope it can be helpful). ; ***************************************************************************************************************** ; 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) (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 (setq answ (getstring "\nThe selected entity has been drawn from bottom-to-top. Do you want to reverse direction? [Yes/No]")) (if (or (= answ "Y") (= answ "Yes") (= answ "yes") (= answ "YES")) (progn (command "._reverse" ename "") (princ "\nThe selected entity has changed direction from top-to-bottom.") (princ) (setq dir (getstring "\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) (strcat dir (cdr (assoc 1 data)))) (setq i (1+ i)) ) ) (progn (prompt "\nThe selected entity retains the current direction from bottom-to-top.") (princ) (setq dir (getstring "\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) (strcat dir (cdr (assoc 1 data)))) (setq i (1+ i)) ) ) ) ) (progn (setq answ (getstring "\nThe selected entity has been drawn from top-to-bottom. Do you want to reverse direction? [Yes/No]")) (if (or (= answ "Y") (= answ "Yes") (= answ "yes") (= answ "YES")) (progn (command "._reverse" ename "") (princ "\nTThe selected entity has changed direction from bottom-to-top.") (princ) (setq dir (getstring "\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) (strcat dir (cdr (assoc 1 data)))) (setq i (1+ i)) ) ) (progn (prompt "\nThe selected entity retains the current direction from top-to-bottom.") (princ) (setq dir (getstring "\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) (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 (setq answ (getstring "\nThe selected entity has been drawn from bottom-to-top. Do you want to reverse direction? [Yes/No]")) (if (or (= answ "Y") (= answ "Yes") (= answ "yes") (= answ "YES")) (progn (command "._reverse" ename "") (princ "\nThe selected entity has changed direction from top-to-bottom.") (princ) (setq dir (getstring "\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) (strcat dir (cdr (assoc 1 data)))) (setq i (1+ i)) ) ) (progn (prompt "\nThe selected entity retains the current direction from bottom-to-top.") (princ) (setq dir (getstring "\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) (strcat dir (cdr (assoc 1 data)))) (setq i (1+ i)) ) ) ) ) (progn (setq answ (getstring "\nThe selected entity has been drawn from top-to-bottom. Do you want to reverse direction? [Yes/No]")) (if (or (= answ "Y") (= answ "Yes") (= answ "yes") (= answ "YES")) (progn (command "._reverse" ename "") (princ "\nThe selected entity has changed direction from bottom-to-top.") (princ) (setq dir (getstring "\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) (strcat dir (cdr (assoc 1 data)))) (setq i (1+ i)) ) ) (progn (prompt "\nThe selected entity retains the current direction from top-to-bottom.") (princ) (setq dir (getstring "\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) (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) ) Best regards. Edited September 15 by Saxlle The code has been updated and changes have been made Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted September 14 Share Posted September 14 This line has no sense since it's not doing anything... (vlax-safearray->list (vlax-variant-value offLine)) 1 Quote Link to comment Share on other sites More sharing options...
Saxlle Posted September 15 Share Posted September 15 Thank you Marko (Hvala ti puno! Pozdrav ). I did make a mistake. Also, i did a little update in posted code from above. Best regards. Quote Link to comment Share on other sites More sharing options...
Jojo Posted September 26 Author Share Posted September 26 On 9/14/2024 at 4:02 AM, Saxlle said: @Jojo According to your posted video ("Recording 2") and explanation in text, try this LISP and see if it works for your neededs. ***Did a little update in code (hope it can be helpful). This is what I was looking for but I was getting error. ; ***************************************************************************************************************** ; 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) (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 (setq answ (getstring "\nThe selected entity has been drawn from bottom-to-top. Do you want to reverse direction? [Yes/No]")) (if (or (= answ "Y") (= answ "Yes") (= answ "yes") (= answ "YES")) (progn (command "._reverse" ename "") (princ "\nThe selected entity has changed direction from top-to-bottom.") (princ) (setq dir (getstring "\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) (strcat dir (cdr (assoc 1 data)))) (setq i (1+ i)) ) ) (progn (prompt "\nThe selected entity retains the current direction from bottom-to-top.") (princ) (setq dir (getstring "\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) (strcat dir (cdr (assoc 1 data)))) (setq i (1+ i)) ) ) ) ) (progn (setq answ (getstring "\nThe selected entity has been drawn from top-to-bottom. Do you want to reverse direction? [Yes/No]")) (if (or (= answ "Y") (= answ "Yes") (= answ "yes") (= answ "YES")) (progn (command "._reverse" ename "") (princ "\nTThe selected entity has changed direction from bottom-to-top.") (princ) (setq dir (getstring "\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) (strcat dir (cdr (assoc 1 data)))) (setq i (1+ i)) ) ) (progn (prompt "\nThe selected entity retains the current direction from top-to-bottom.") (princ) (setq dir (getstring "\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) (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 (setq answ (getstring "\nThe selected entity has been drawn from bottom-to-top. Do you want to reverse direction? [Yes/No]")) (if (or (= answ "Y") (= answ "Yes") (= answ "yes") (= answ "YES")) (progn (command "._reverse" ename "") (princ "\nThe selected entity has changed direction from top-to-bottom.") (princ) (setq dir (getstring "\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) (strcat dir (cdr (assoc 1 data)))) (setq i (1+ i)) ) ) (progn (prompt "\nThe selected entity retains the current direction from bottom-to-top.") (princ) (setq dir (getstring "\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) (strcat dir (cdr (assoc 1 data)))) (setq i (1+ i)) ) ) ) ) (progn (setq answ (getstring "\nThe selected entity has been drawn from top-to-bottom. Do you want to reverse direction? [Yes/No]")) (if (or (= answ "Y") (= answ "Yes") (= answ "yes") (= answ "YES")) (progn (command "._reverse" ename "") (princ "\nThe selected entity has changed direction from bottom-to-top.") (princ) (setq dir (getstring "\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) (strcat dir (cdr (assoc 1 data)))) (setq i (1+ i)) ) ) (progn (prompt "\nThe selected entity retains the current direction from top-to-bottom.") (princ) (setq dir (getstring "\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) (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) ) Best regards. Quote Link to comment Share on other sites More sharing options...
Jojo Posted September 26 Author Share Posted September 26 On 9/14/2024 at 4:02 AM, Saxlle said: @Jojo According to your posted video ("Recording 2") and explanation in text, try this LISP and see if it works for your neededs. ***Did a little update in code (hope it can be helpful). ; ***************************************************************************************************************** ; 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) (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 (setq answ (getstring "\nThe selected entity has been drawn from bottom-to-top. Do you want to reverse direction? [Yes/No]")) (if (or (= answ "Y") (= answ "Yes") (= answ "yes") (= answ "YES")) (progn (command "._reverse" ename "") (princ "\nThe selected entity has changed direction from top-to-bottom.") (princ) (setq dir (getstring "\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) (strcat dir (cdr (assoc 1 data)))) (setq i (1+ i)) ) ) (progn (prompt "\nThe selected entity retains the current direction from bottom-to-top.") (princ) (setq dir (getstring "\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) (strcat dir (cdr (assoc 1 data)))) (setq i (1+ i)) ) ) ) ) (progn (setq answ (getstring "\nThe selected entity has been drawn from top-to-bottom. Do you want to reverse direction? [Yes/No]")) (if (or (= answ "Y") (= answ "Yes") (= answ "yes") (= answ "YES")) (progn (command "._reverse" ename "") (princ "\nTThe selected entity has changed direction from bottom-to-top.") (princ) (setq dir (getstring "\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) (strcat dir (cdr (assoc 1 data)))) (setq i (1+ i)) ) ) (progn (prompt "\nThe selected entity retains the current direction from top-to-bottom.") (princ) (setq dir (getstring "\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) (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 (setq answ (getstring "\nThe selected entity has been drawn from bottom-to-top. Do you want to reverse direction? [Yes/No]")) (if (or (= answ "Y") (= answ "Yes") (= answ "yes") (= answ "YES")) (progn (command "._reverse" ename "") (princ "\nThe selected entity has changed direction from top-to-bottom.") (princ) (setq dir (getstring "\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) (strcat dir (cdr (assoc 1 data)))) (setq i (1+ i)) ) ) (progn (prompt "\nThe selected entity retains the current direction from bottom-to-top.") (princ) (setq dir (getstring "\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) (strcat dir (cdr (assoc 1 data)))) (setq i (1+ i)) ) ) ) ) (progn (setq answ (getstring "\nThe selected entity has been drawn from top-to-bottom. Do you want to reverse direction? [Yes/No]")) (if (or (= answ "Y") (= answ "Yes") (= answ "yes") (= answ "YES")) (progn (command "._reverse" ename "") (princ "\nThe selected entity has changed direction from bottom-to-top.") (princ) (setq dir (getstring "\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) (strcat dir (cdr (assoc 1 data)))) (setq i (1+ i)) ) ) (progn (prompt "\nThe selected entity retains the current direction from top-to-bottom.") (princ) (setq dir (getstring "\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) (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) ) Best regards. Marko. please see attached video. Thank you. Recording 2024-09-26 095342.mp4 Quote Link to comment Share on other sites More sharing options...
Saxlle Posted September 26 Share Posted September 26 @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. Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted September 26 Share Posted September 26 (edited) 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) ) Edited September 26 by marko_ribar 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.