Offset

Discussion in 'AutoCAD' started by Chris, Oct 12, 2005.

  1. Chris

    Chris Guest

    Does anyone know of a way to offset a large group of items in a drawings.
    Say you have a drawing with 50 circles and you need to offset them is there
    a command, lisp or shx that will do this? I found a lisp called offset all
    but it doesn't let you offset more than one item at a time.
     
    Chris, Oct 12, 2005
    #1
  2. Chris

    Paul Turvill Guest

    I suppose it could be handled by LISP, but it isn't exactly a trivial
    undertaking, since each offset requires a selection of an item, plus a pick
    to indicate on which side the offset object is to be placed.

    In your example of circles, I suppose the routine could ask for a distance
    and a choice of "inside" or "outside" ... and treat all of the circles
    similarly. Is this what you have in mind? Would you need to consider other
    types of objects as well? If so, the problem becomes increasingly complex.
    ___
     
    Paul Turvill, Oct 12, 2005
    #2
  3. Chris

    Chris Guest

    That's about what Im looking for. I have a plasma cutting table here at
    the shop I work at and we need to offset holes .125 to compensate for
    the cut. Say I have an array of 50 holes I just want to be able to
    select them all, choose the distance and to which direction and erase or
    put the original on a different layer.
     
    Chris, Oct 12, 2005
    #3
  4. Chris

    Brian Salt Guest


    If the holes are all the same radius, perhaps this (or something similar)
    would fit the bill. Note that there are two versions quoted.

    I have tried the first routine as it stands and it does change all the
    holes with the specified radius to the newly defined radius. I haven't
    checked the second routine.

    Brian.

    ;|
    ********************************************
    * CHRAD.LSP - (c) 1998 Tee Square Graphics *
    ********************************************

    Two utilities to globally change the radius of existing
    circles in an AutoCAD drawing.

    CAUTION: This is "demonstration" level software, and has no
    error traps or other refinements. These enhancements are
    left to the discretion of the end user. Both of the commands
    defined below will select ALL circles of the chosen "old
    radius" and change all to the "new radius." To allow the
    user to select a superset of objects to be scanned, remove
    the "x" from the (ssget...) function in either case:

    (setq ss (ssget (list '(0 . "CIRCLE")(cons 40 or))))

    ********************************************

    CHRAD command uses (command...) function and appears to be
    somewhat faster where the change of radius is fairly small.
    |;
    (defun C:CHRAD (/ or nr ss)
    (setq ce (getvar "cmdecho")
    or (getdist "\nOld radius: ")
    nr (getdist "\nNew radius: ")
    ss (ssget "x" (list '(0 . "CIRCLE")(cons 40 or))))
    (if ss
    (progn
    (setvar "cmdecho" 0)
    (command "_.change" ss "" "" nr)
    (while (= (logand (getvar "cmdactive") 1) 1)
    (command nr))
    (setvar "cmdecho" ce))
    (alert (strcat "No " (rtos or) " radius circles found.")))
    (princ)
    )
    ;|

    ********************************************

    CHRAD1 command uses (entmod...) and is considerably
    faster where the change of radius is large.
    |;
    (defun C:CHRAD1 (/ or nr ss n obj)
    (setq or (getdist "\nOld radius: ")
    nr (getdist "\nNew radius: ")
    ss (ssget "x" (list '(0 . "CIRCLE")(cons 40 or)))
    n 0)
    (if ss
    (while (< n (sslength ss))
    (setq obj (entget (ssname ss n))
    obj (subst (cons 40 nr)(assoc 40 obj) obj)
    n (1+ n))
    (entmod obj))
    (alert (strcat "No " (rtos or) " radius circles found.")))
    (princ)
    )
     
    Brian Salt, Oct 12, 2005
    #4
  5. Chris

    Paul Turvill Guest

    (defun C:OFFCIR (/ n os io dat orad nrad ndat)
    (while (not (setq ss (ssget '((0 . "CIRCLE"))))))
    (setq n (1- (sslength ss))
    os (getdist "\nEnter offset distance: ")
    );;setq
    (initget "Inside Outside")
    (setq io (getkword "\nInside or Outside <O>?"))
    (while (>= n 0)
    (setq dat (entget (ssname ss n))
    orad (cdr (assoc 40 dat))
    nrad (if (= io "Inside")(- orad os)(+ orad os))
    ndat (subst (cons 40 nrad)(assoc 40 dat) dat)
    n (1- n)
    );;setq
    (entmake ndat)
    );;while

    ;;Select the line below to do what you wish
    ;; with the original circles:

    ; (command "_.erase" ss "")
    ; (command "_.chprop" ss "" "_la" "[LayerName]" "")

    (princ)
    );;defun
    ___
     
    Paul Turvill, Oct 13, 2005
    #5
  6. Chris

    Brian Salt Guest

    That works very well, Paul.


    <SNIP>
     
    Brian Salt, Oct 13, 2005
    #6
  7. Chris

    Chris Guest

    Paul you rule. That works great. I need to learn how to write those
    programs but I have only been using CAD for about 6 months. Thanks again
    this helps bigtime.
     
    Chris, Oct 13, 2005
    #7
  8. Chris

    Chris Guest

    there wasn't a prompt to erase the originals.
     
    Chris, Oct 13, 2005
    #8
  9. Chris

    Brian Salt Guest

    They are erases automatically if you take the semicolon out of this line:

    ; (command "_.erase" ss "")

    to read:

    (command "_.erase" ss "")
     
    Brian Salt, Oct 13, 2005
    #9
  10. Chris

    Paul Turvill Guest

    Look closely; the code provides for both options you mentioned, near the
    end. Just remove the ";" at the start of the appropriate line. If you use
    the "chprop" option to move the original circles to a new layer, you'll also
    have to supply the actual layer name in place of "[LayerName]".
    ___
     
    Paul Turvill, Oct 13, 2005
    #10
  11. Chris

    Chris Guest

    Got ya. Works perfectly. Thanks alot.
     
    Chris, Oct 13, 2005
    #11
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.