I use this to offset most anything but trusses in plan view is what I use it for the most.
It now uses one of Lee's older Vector Offset routines. See the two functions at the very end to call the routine from the command line.
;; ArrayObjects is a modified from of Lee Mac Array on Vector
;; This engine allowed me to replace several of my stand
;; alone lisp routines, now I have a versatile offset routine.
;;
;; http://www.theswamp.org/index.php?topic=44596.msg498546#msg498546
;; http://lee-mac.com/incrementalarray.html
(defun ArrayObjects
(ss ; selection set to copy
p0 ; base point of array
ortho_on ; vector constraints 0 90 180 270
dx ; distance between copies
/ ss->list copyv dx gr nx obs obx pd vx dis last#)
(vl-load-com)
(defun ss->lst (ss / i ename lst)
(setq i -1)
(while (setq ename (ssname ss (setq i (1+ i))))
(setq lst (cons (vlax-ename->vla-object ename) lst))
)
lst
)
(defun copyv (ob ; objects list
n ; number of copies
v ; vector direction
/ i b l)
(setq i 1
b (vlax-3d-point '(0. 0. 0.))
)
(repeat n
(foreach obj ob ; step through object list
;; note the the new object is created at the location of the original object
;; the move is a relative move based on base point zero & offset vectors
(vla-move ; each object copied
(car ; move newest of the new object
(setq l ; create a list of new objects
(cons (vla-copy obj) ; new object
l)))
b ; base move point 0,0,0
(vlax-3d-point ; destination of move
(mapcar '* v (list i i i)))
)
)
(setq i (1+ i))
)
l ; return the list of new objects
)
(if
(and
(setq obs (ss->lst ss))
(setq pw (trans p0 1 0))
(not (equal dx 0.0 1e-14))
)
(while (= 5 (car (setq gr (grread 't 13 0))))
(redraw)
(setq obx (car (mapcar 'vla-delete obx))
px (cadr gr))
;; vextor is p0->px
(cond
(ortho_on ; only use x or y axis which ever is greator
(setq dis (mapcar '- px p0)) ; get x & y distance
(if (> (abs(car dis))(abs(cadr dis)))
(setq dis (car dis) ; x axis
nx (fix (/ dis dx))
vx (trans (list (if (minusp dis) (- dx) dx) 0. 0.) 1 0)
px (trans (list (car px) (cadr p0)(caddr px)) 1 0)
)
(setq dis (cadr dis) ; y axis
nx (fix (/ dis dx))
vx (trans (list 0. (if (minusp dis) (- dx) dx) 0.) 1 0)
px (trans (list (car p0) (cadr px)(caddr px)) 1 0)
)
)
)
(t ; any angle
(setq vx (trans (polar '(0. 0. 0.) (angle p0 px) dx) 1 0)
nx (fix (/ (distance p0 px) dx)) ; calc number of copies to array
)
)
)
(setq obx (copyv obs (abs nx) vx))
(grvecs (list -3 p0 (trans px 0 1)))
;|(print p0)(princ " -> ")(princ px)|;
(if (null last#) (setq last# (1+ (abs nx))))
(if (/= (1+ (abs nx)) last#)
(progn
(setq last# (1+ (abs nx)))
(princ "\nArray count = ")
(princ last#)
)
)
)
)
(redraw)
(princ)
)
;;; TrussOffset.lsp
;;;
;;; Author: Copyright© 2005 Charles Alan Butler
;;; Version: 1.0 May. 23, 2004
;;; Version: 1.1 Jul. 22, 2004
;;; Version: 2.0 Mar. 08, 2013 - abondoned my array & used Lee's Array function
;;; Purpose: offset objects user offset distance to fill selected area
;;; Flag for X & Y directions only.
;;; Will work with any objects
;;;
;;; [Prompts]
;;; Select objects
;;; Enter or select offset distance
;;; Pick start & end point of array distance, these picks only establish
;;; direction and total distance, not start & end points.
;;;
(defun TrussArray (ortho_on ; t = use angles 0 90 180 270 only
/ *error* p1 p2 ss dist num tmp)
;;; error function & Routine Exit
(defun *error* (msg)
(if
(not
(member
msg
'("console break" "Function cancelled" "quit / exit abort" "")
)
)
(princ (strcat "\nError: " msg))
) ; if
(and useros (setvar "osmode" useros))
(and usercmd (setvar "CMDECHO" usercmd))
(princ)
) ;;end error function
(setq usercmd (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(setq useros (getvar "osmode"))
(setvar "orthomode" 1)
(prompt "\nSelect objects to offset")
(if (setq ss (ssget))
(progn
(if (null to_step); global var
(setq to_step 24)
(setq to_step (abs to_step))
)
(setq tmp (getdist (strcat "\nEnter or pick offset amount. <"(rtos to_step) "> ")))
(if tmp
(setq to_step (abs tmp))
)
(if (setq p1 (getpoint "Pick Starting point"))
(ArrayObjects ss p1 ortho_on to_step)
)
)
) ; endif
;;========== Exit Sequence ============
(*ERROR* "")
(princ); Exit quietly
) ; end defun
(defun c:trussoucs ()
(TrussArray nil) ; any angle
(princ)
)
(defun c:trusso ()
(TrussArray t) ; t = use angles 0 90 180 270 only
(princ)
)