Offset both sides of line

Discussion in 'AutoCAD' started by Kevin Lockwood, Aug 11, 2004.

  1. Offset to both sides of a line (maybe to a specified layer)I've looked
    and looked and still cant find a tool for this (that I have to buy :) )
     
    Kevin Lockwood, Aug 11, 2004
    #1
  2. Kevin Lockwood

    Jim Claypool Guest

    It's old and crude but it works.

    (defun dbloffset (layername / osmode ss ename ent pt1 pt2 midpt ang)
    (setq osmode (getvar "osmode"))
    (setvar "osmode" 0)
    (while (not (setq ename (entsel "\nSelect line to offset: "))))
    (setq ename (car ename))
    (setq ent (entget ename))
    (setq pt1 (cdr (assoc 10 ent)))
    (setq pt2 (cdr (assoc 11 ent)))
    (setq ang (angle pt1 pt2))
    (setq midpt (polar pt1 ang (/ (distance pt1 pt2) 2.0)))
    (while (not (setq offset (getdist midpt "\nOffset distance: "))))
    (command ".offset" offset ename (polar midpt (+ ang (* pi 0.5)) offset) "")
    (if layername (entmod (subst (cons 8 Layername) (assoc 8 (entget
    (entlast))) (entget (entlast)))))
    (command ".offset" offset ename (polar midpt (- ang (* pi 0.5)) offset) "")
    (if layername (entmod (subst (cons 8 Layername) (assoc 8 (entget
    (entlast))) (entget (entlast)))))
    (setvar "osmode" osmode)
    (princ)
    )
     
    Jim Claypool, Aug 11, 2004
    #2
  3. Kevin Lockwood

    Jeff Mishler Guest

    (setq layr (getstring "\nLayer to offset to: ")
    (setq offdist (getreal "\nDistance to offset: ")
    (setq l1 (car (entsel "\nSelect line to offset: ")))
    (setq l1-vla (vlax-ename->vla-object l1))
    (setq new-l (vla-offset l1-vla offdist))
    (if layr (vla-put-layer new-l laYR))
    (setq new-l (vla-offset l1-vla (- offdist)))
    (if layr (vla-put-layer new-l laYR))
     
    Jeff Mishler, Aug 12, 2004
    #3
  4. Kevin Lockwood

    Jim Claypool Guest

    Ok here's the update using Jeff's solution (with corrections)

    (defun dbloffset (layername / ename offdist l1-vla)
    (setvar "osmode" 0)
    (while (not (setq ename (entsel "\nSelect line to offset: "))))
    (setq ename (car ename))
    (setq l1-vla (vlax-ename->vla-object ename))
    (while (not (setq offdist (getdist "\nOffset distance: "))))
    (vla-offset l1-vla offdist)
    (if layername (vla-put-layer (vlax-ename->vla-object (entlast)) layername))
    (vla-offset l1-vla (- offdist))
    (if layername (vla-put-layer (vlax-ename->vla-object (entlast)) layername))
    (princ)
    )
     
    Jim Claypool, Aug 12, 2004
    #4
  5. thanks for the help !!! and you guys dont even get paid...wow
     
    Kevin Lockwood, Aug 16, 2004
    #5
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.