Author Topic: Evenly space objects in a linear path.  (Read 14797 times)

0 Members and 1 Guest are viewing this topic.

thunderfoot

  • Guest
Evenly space objects in a linear path.
« on: January 28, 2013, 10:24:41 AM »
I searched for a function to do this but could not find one.  :blank: Does anyone know if there is one located here in the Swamp? Or elsewhere?

Thanks,
     Reuben Shilling

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Evenly space objects in a linear path.
« Reply #1 on: January 28, 2013, 10:54:43 AM »
MEASURE??
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

Tharwat

  • Swamp Rat
  • Posts: 707
  • Hypersensitive
Re: Evenly space objects in a linear path.
« Reply #2 on: January 28, 2013, 10:55:12 AM »
Hi ,

Can you explain your aim of the lisp in more details ?

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Evenly space objects in a linear path.
« Reply #3 on: January 28, 2013, 10:55:18 AM »
Or ARRAY??
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Evenly space objects in a linear path.
« Reply #4 on: January 28, 2013, 11:03:40 AM »
« Last Edit: January 28, 2013, 11:08:36 AM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

thunderfoot

  • Guest
Re: Evenly space objects in a linear path.
« Reply #5 on: January 28, 2013, 11:26:01 AM »
Hi ,

Can you explain your aim of the lisp in more details ?

I want to be able to select already existing objects (usually text but sometimes a block) (one at a time is OK, but i would rather select them all at once and let their individual x or y coordinates determine their current alignment and from that derive their new alignment) and from that selection set specify a distance between the objects along a path determined by 2 user-defined points (to define the angle of array).

Thanks,
    Reuben Shilling

Nibster

  • Guest
Re: Evenly space objects in a linear path.
« Reply #6 on: January 28, 2013, 11:29:28 AM »
DIVIDE

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Evenly space objects in a linear path.
« Reply #7 on: January 28, 2013, 11:30:00 AM »
Hi ,

Can you explain your aim of the lisp in more details ?

I want to be able to select already existing objects (usually text but sometimes a block) (one at a time is OK, but i would rather select them all at once and let their individual x or y coordinates determine their current alignment and from that derive their new alignment) and from that selection set specify a distance between the objects along a path determined by 2 user-defined points (to define the angle of array).

Thanks,
    Reuben Shilling
Looks like you may have already answered your own question.
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

thunderfoot

  • Guest
Re: Evenly space objects in a linear path.
« Reply #8 on: January 28, 2013, 11:31:21 AM »
Hi ,

Can you explain your aim of the lisp in more details ?

I want to be able to select already existing objects (usually text but sometimes a block) (one at a time is OK, but i would rather select them all at once and let their individual x or y coordinates determine their current alignment and from that derive their new alignment) and from that selection set specify a distance between the objects along a path determined by 2 user-defined points (to define the angle of array).

Thanks,
    Reuben Shilling
Looks like you may have already answered your own question.

Doesn't array just copy objects?
I want to evenly space the existing objects.

thunderfoot

  • Guest
Re: Evenly space objects in a linear path.
« Reply #9 on: January 28, 2013, 11:31:51 AM »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Evenly space objects in a linear path.
« Reply #10 on: January 28, 2013, 11:39:06 AM »
This is a routine I use to offset objects.
Originally used for trusses in houses but will work for any object.
This one is X or Y axis only. http://www.theswamp.org/index.php?topic=34092.msg394338#msg394338


This is another version for UCS.
Note that they are rather old & in need of a remake.  8-)
Code: [Select]
;;; TrussOffsetUCS.lsp
;;;
;;; Author: Copyright© 2005 Charles Alan Butler
;;; Version:  1.0 May 01, 2005
;;; Purpose: offset objects user offset distance to fill selected area
;;;          Modified version of TrussOffset.lsp to use UCS
;;;          Will work with any objects
;;;
;;; [Prompts]
;;; Select objects
;;; Enter or select offset distance
;;; Pick start & end point of array distance, these picks establish
;;;  direction and total distance, not start & end points.
;;;
(defun c:trussoucs (/ *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
  (setvar "osmode" useros)
  (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")
  (setq ss (ssget))
  (if ss
    (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 tmp)
      )
      (setq p1 (getpoint "Pick Starting point"))
      (if p1
        (progn
          (setq p2 (getpoint p1 "Pick End point and the axix of offset"))
          (if p2
            (progn
              (setq dist (distance p1 p2)
                    num  (fix (1+(/ dist to_step)))
                    ang  (angle p1 p2)
              )
              (if (or (equal ang pi 0.2)
                      (equal ang (* pi 1.5) 0.2)
                  )
                (setq to_step (- to_step)); reverse the direction
              )
              (setvar "osmode" 0)
              (cond
                ((or (equal ang 0 0.2) ; Horrizontal
                     (equal ang pi 0.2)
                 )
                 (command "_.array" ss "" "R" "" num to_step)
                )
                ((or (equal ang (/ pi 2) 0.2) ; Vertical
                     (equal ang (* pi 1.5) 0.2)
                 )
                 (command "_.array" ss "" "R" num "" to_step)
                 
                )
                (t
                  (alert "Under condtruction")
                  (setq p3 (polar p1 (+ (angle p1 p2) (/ pi 2)) 50))
                  (command "._ucs" "N" "3" p1 p2 p3) ; origin x y
                  (command "_.array" ss "" "R" "" num to_step)
                  (command "_ucs" "P")
                )

              ) ; end cond stmt
            ) ; end progn
          ) ; endif
        ) ; end progn
      ) ; endif
    ) ; end progn
  ) ; endif
;;;==========  Exit Sequence  ============
  (*ERROR* "")
  (princ); Exit quietly
) ; end defun
(prompt "\nOffset Object Loaded. Enter OOS to run.")
(princ)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Evenly space objects in a linear path.
« Reply #11 on: January 28, 2013, 11:48:04 AM »
Try the following code Reuben:

Code: [Select]
;; Equispace  -  Lee Mac
(defun c:eqsp ( / a b e i l p s v )
    (if
        (and
            (setq s (ssget "_:L" '((0 . "TEXT,MTEXT,INSERT"))))
            (setq a (getpoint "\nSpecify Basepoint: "))
            (setq b (getpoint "\nSpecify Spacing Vector: " a))
        )
        (progn
            (repeat (setq i (sslength s))
                (setq e (entget (ssname s (setq i (1- i)))))
                (if (or (wcmatch (cdr (assoc 0 e)) "MTEXT,INSERT")
                        (and
                            (zerop (cdr (assoc 72 e)))
                            (zerop (cdr (assoc 73 e)))
                        )
                    )
                    (setq p (assoc 10 e))
                    (setq p (assoc 11 e))
                )
                (setq l (cons (list p e) l))
            )
            (setq v (mapcar '- b a))
            (foreach e
                (vl-sort l
                    (function
                        (lambda ( a b )
                            (< (last (trans (cdar a) 0 v)) (last (trans (cdar b) 0 v)))
                        )
                    )
                )
                (entmod (subst (cons (caar e) a) (car e) (cadr e)))
                (setq a (mapcar '+ a v))
            )
        )
    )
    (princ)
)

PS: Off topic, your user name seems rather contradictory in nature to your signature...

thunderfoot

  • Guest
Re: Evenly space objects in a linear path.
« Reply #12 on: January 28, 2013, 11:59:39 AM »
Try the following code Reuben:

Code: [Select]
;; Equispace  -  Lee Mac
(defun c:eqsp ( / a b e i l p s v )
    (if
        (and
            (setq s (ssget "_:L" '((0 . "TEXT,MTEXT,INSERT"))))
            (setq a (getpoint "\nSpecify Basepoint: "))
            (setq b (getpoint "\nSpecify Spacing Vector: " a))
        )
        (progn
            (repeat (setq i (sslength s))
                (setq e (entget (ssname s (setq i (1- i)))))
                (if (or (wcmatch (cdr (assoc 0 e)) "MTEXT,INSERT")
                        (and
                            (zerop (cdr (assoc 72 e)))
                            (zerop (cdr (assoc 73 e)))
                        )
                    )
                    (setq p (assoc 10 e))
                    (setq p (assoc 11 e))
                )
                (setq l (cons (list p e) l))
            )
            (setq v (mapcar '- b a))
            (foreach e
                (vl-sort l
                    (function
                        (lambda ( a b )
                            (< (last (trans (cdar a) 0 v)) (last (trans (cdar b) 0 v)))
                        )
                    )
                )
                (entmod (subst (cons (caar e) a) (car e) (cadr e)))
                (setq a (mapcar '+ a v))
            )
        )
    )
    (princ)
)

PS: Off topic, your user name seems rather contradictory in nature to your signature...

Lee,
   
    Routine does just what I needed!

How so on the contradiction?
Chief Thunderfoot was a nickname I picked up my senior year in high school. It got started because I was running barefoot, and partly because I had just moved to Missouri from Oklahoma I think.

Thanks for the awesome routine, I hope to study it out and learn from it and others.

Sincerely,
     Reuben Shilling

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Evenly space objects in a linear path.
« Reply #13 on: January 28, 2013, 12:10:13 PM »
Routine does just what I needed!

Excellent  :-)

How so on the contradiction?
Chief Thunderfoot was a nickname I picked up my senior year in high school. It got started because I was running barefoot, and partly because I had just moved to Missouri from Oklahoma I think.

If you Google the name 'thunderfoot' you will discover that it is the name of a reasonably well-known online atheist; the contradiction being that you are quoting bible verses.

Thanks for the awesome routine, I hope to study it out and learn from it and others.

You're very welcome, ask if you have any questions about the code.

thunderfoot

  • Guest
Re: Evenly space objects in a linear path.
« Reply #14 on: January 28, 2013, 12:19:58 PM »
Routine does just what I needed!

Excellent  :-)

How so on the contradiction?
Chief Thunderfoot was a nickname I picked up my senior year in high school. It got started because I was running barefoot, and partly because I had just moved to Missouri from Oklahoma I think.

If you Google the name 'thunderfoot' you will discover that it is the name of a reasonably well-known online atheist; the contradiction being that you are quoting bible verses.

In light of that fact and "Abstain from all appearance of evil." ~ I Thessalonians 5:22 I have changed my username to my wife's personal nickname for me (even using her spelling as opposed to my preferred "Roo").

Thanks for the awesome routine, I hope to study it out and learn from it and others.

You're very welcome, ask if you have any questions about the code.

On the code, when I tried to use it on a dynamic block, it only moved part of the block? I'm assuming this is because of (ssget "_:L" '((0 . "TEXT,MTEXT,INSERT")?