MODIFY OFFSET LISP

MODIFY OFFSET LISP

emersongonzalez1999
Advocate Advocate
965 Views
6 Replies
Message 1 of 7

MODIFY OFFSET LISP

emersongonzalez1999
Advocate
Advocate

Hi, I found this offset lisp but it needs a minor tweak. I want the lisp to maintain the specified offset distance(just as the regular OFFSET command) and also to allow me to select LAYER--> Enter layer option for offset object: Current or Source (just as the regular OFFSET COMMAND). These options will make it easier for me for the task am performing.

0 Likes
Accepted solutions (1)
966 Views
6 Replies
Replies (6)
Message 2 of 7

Kent1Cooper
Consultant
Consultant

That's all doable.  [I have routines that do some of those things, but built-in rather than as options.]  Would I assume correctly that you also want it to maintain your Yes/No choice on whether to delete the original object(s)?

 

[It should also be fixed to not have simply *LINE in the object-type entry in the (ssget) filter.  That allows selection of MLINE and 3D POLYLINE objects, which cannot be Offset, as well as the ones you want it to allow.]

Kent Cooper, AIA
0 Likes
Message 3 of 7

john.uhden
Mentor
Mentor

@emersongonzalez1999 ,

I have a (very) old program I wrote called XOFFSET that provides dialog options for layer, color, etc.

Plus it can offset objects nested in a block or xref, and can offset polylines entirely or by selected segment, and can "clone" objects by using an offset of 0.

But I am bound by legal considerations to not be able to give it away.

johnuhden_0-1715795932188.png

 

John F. Uhden

0 Likes
Message 4 of 7

komondormrex
Mentor
Mentor
Accepted solution

hi there,

it's done)

 

(defun c:dOff ( / *error* of ofs undo doc ss flg layer)
 (vl-load-com)
  (if (null of_saved) (setq of_saved 10.0))
  (if (null layer_saved) (setq layer_saved "Source"))
  (if (null flg_saved) (setq flg_saved "No"))
(defun *error* ( msg )
   (and undo (vla-EndUndomark doc))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ)
  )
(if (ssget '((0 . "ARC,CIRCLE,ELLIPSE,*LINE")))
   (progn
     (if (null (setq of (getdist (strcat "\nSpecify Offset Distance <" (rtos of_saved) ">: "))))
	(setq of of_saved)
	(setq of_saved of)
     )
     (initget "Yes No")
     (if (null (setq flg (getkword (strcat "\nDelete Original? [Yes/No] <" flg_saved ">: "))))
       (setq flg flg_saved)
       (setq flg_saved flg)
     )
     (initget "Source Current")
     (if (null (setq layer (getkword (strcat "\nLayer for offset? [Source/Current] <" layer_saved ">: "))))
       (setq layer layer_saved)
       (setq layer_saved layer)
     )
     (setq undo
       (not
         (vla-StartUndomark
           (setq doc
             (vla-get-ActiveDocument
               (vlax-get-acad-object)
             )
           )
         )
       )
     )
     
     (vlax-for obj (setq ss (vla-get-ActiveSelectionSet doc))
       (mapcar
         (function
           (lambda ( o )
             (setq ofs (vl-catch-all-apply
               (function vla-offset) (list obj o)
             ))
	     (if (and (null (vl-catch-all-error-p ofs))
		      (= "Current" layer)
		      (/= (getvar 'clayer) (vla-get-layer obj))
		 )
	       	(mapcar '(lambda (object) (vla-put-layer object (getvar 'clayer)))
			 (vlax-safearray->list (vlax-variant-value ofs))
		)
	      )
           )
         )
         (list of (- of))
       )
       (if (= flg "Yes") (vla-delete obj))
     )
     
     (vla-delete ss)
(setq undo (vla-EndUndoMark doc))
   )
 )
 (princ)
)

 

 

 

0 Likes
Message 5 of 7

emersongonzalez1999
Advocate
Advocate

Thank you @Kent1Cooper and @john.uhden but @komondormrex has my solutions.

0 Likes
Message 6 of 7

Sea-Haven
Mentor
Mentor

What about a front end. This is not finished needs some tidying up. Dinner time any one else can tidy up.

 

SeaHaven_0-1715844809006.png

 

ddoffsAH : dialog {
	label ="Enter Values" ;
 : column {
spacer_1 ;
: edit_box {
 width =25;
    key = "key1";
	alignment = left;
 label = "Distance";
     edit_width = 8;
     edit_limit = 7;
   is_enabled = true ;
   allow_accept=true ;
   alignment = left;
    }
	spacer_1 ;
: boxed_row	{
width = 15 ;
label = "Keep or delete ";
	: radio_row	{
	: radio_button	{
key = "Rb1";
label = "Yes";
	}
spacer_1 ;
	: radio_button	{
key = "Rb2";
label = "No";
	}
	}
	}
spacer_1 ;
: edit_box {
    key = "key2";
 label = "Layer ";
     edit_width = 30;
     edit_limit = 29;
   is_enabled = true ;
   allow_accept=true ;
    }
    }
spacer_1 ;
ok_cancel;}

 

0 Likes
Message 7 of 7

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:

....

[It should also be fixed to not have simply *LINE in the object-type entry in the (ssget) filter.  That allows selection of MLINE and 3D POLYLINE objects, which cannot be Offset, as well as the ones you want it to allow.]


To find all OFFSETtable objects using *LINE to cover LINE/SPLINE/*POLYLINE/XLINE but omitting MLINE & 3D Polyline because they cannot be Offset at all, and in this case omitting RAY because though they can be Offset, (vla-offset) doesn't work on them:

    (setq YourSelectionSetVariable
      (ssget "_:L" ; only on unlocked Layer(s)
        '( ; filter list
          (0 . "*LINE,ARC,CIRCLE,ELLIPSE"); *LINE = Line/*Polyline/Spline/Xline/Mline
          (-4 . "<NOT"); forbid these [not Offsettable]
            (-4 . "<OR")
              (0 . "MLINE")
              (-4 . "<AND") (0 . "POLYLINE") (-4 . "&") (70 . 8) (-4 . "AND>"); 3D Polyline
            (-4 . "OR>")
          (-4 . "NOT>")
        ); filter list
      ); ssget
    ); setq

 

Kent Cooper, AIA
0 Likes