Arraypath with various step values

Arraypath with various step values

Anonymous
Not applicable
10,224 Views
41 Replies
Message 1 of 42

Arraypath with various step values

Anonymous
Not applicable

Hi,

I would create a LISP that draw a circle at the starting or ending point (depends where I click) of a existing line.

Then with this circle I would do an ARRAYPATH but with different value of distance between the circles. The value of the distance should be taken from a fixed pool of values.

 

Example

1. I click on the line in the side where I want the circle (with fixed radius)

2. LISP command draws the circle

3. LIPS command draws a second circle "VAR1" unit far from the first circle, LIPS command draws a third circle "VAR2" unit far from the second circle, and so on until the end of the line/path.

 

"VAR1" "VAR2" "VAR3"... are fixed values that the command should take randomly.

It could be plus if I could edit manually some values of distance (maybe with something like a input text box between the circles).

 

Is it possible to do this? Maybe at the least without the random distance value?

Where I could find guide of the ARRAYPATH parameters?

 

Thank you

 

PS: I would change the default distance of the arraypath command. There isn't any system variable to change? I see only solutions with "actions recording" or "lisp" for this...and it can't be!!!😅

 

 

0 Likes
Accepted solutions (2)
10,225 Views
41 Replies
Replies (41)
Message 41 of 42

ВeekeeCZ
Consultant
Consultant

Here's the update. I failed in resetting multiple times. Sorry about that.

 

 

(vl-load-com)

(defun c:ArrayOfCirclesRandom3 ( / LM:rand LM:randrange rad dlt-lst1 pnt1 pnt2 tmp dlt-lst2 dst ents-lst gap gap-min gap-max itr-max itr i s done)
  
  (setq rad 		15
	dlt-lst1 	'(30 32 34 35)
	gap-min 	31					;; also possible: (apply 'min dlt-lst1)
	gap-max 	36					;; also possible: (apply 'max dlt-lst1)
	itr-max 	99)
  
  ;; Random  -  Lee Mac
  (defun LM:rand ( / a c m )
    (setq m   4294967296.0 a 1664525.0 c 1013904223.0
	  $xn (rem (+ c (* a (cond ($xn) ((getvar 'date))))) m))
    (/ $xn m))
  
  (defun LM:randrange ( a b ) (+ (min a b) (fix (* (LM:rand) (1+ (abs (- a b)))))))
  
  ; -----------------------------
  
  (if (setq s (ssget '((0 . "LWPOLYLINE,LINE,ARC,CIRCLE"))))
    (repeat (setq i (sslength s))
      (setq ent (ssname s (setq i (1- i))))
      
      (setq pnt1 (vlax-curve-getStartPoint ent)
	    pnt2 (vlax-curve-getEndPoint ent)
	    len-tot (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent))
	    itr itr-max
	    dlt-lst2 nil
	    dst 0.
	    done nil)
      
      (while (not done)
	  (setq dlt (nth (LM:randrange 0 (1- (length dlt-lst1))) dlt-lst1)
		gap (abs (- len-tot (+ (apply '+ dlt-lst2) dlt))))
	  
	  (cond ((> gap gap-max)					;; gap is still more than max
		 (setq dlt-lst2 (cons dlt dlt-lst2)		;; add length
		       done nil))				;; not done yet
		
		((< gap gap-min)					;; gap is less than min
		 (princ (strcat "\n" (itoa itr) ": " (vl-princ-to-string (reverse (cons gap (cons dlt dlt-lst2)))) " failed"))
		 (setq itr (1- itr)			;; lower the counter
		       dlt-lst2 nil)				;; reset length list
		 (setq done (zerop itr)))			;; done if reached max of attempts, else keep going
		
		(T						;; gap within the range
		 (setq dlt-lst2 (cons gap (cons dlt dlt-lst2))	;; add length and remaining gap for last-one
		       done T)					;; done
		 (princ (strcat "\n" (itoa itr) ": " (vl-princ-to-string (reverse dlt-lst2)) " OK"))))
	  dlt-lst2)
	
	(if dlt-lst2 (setq dlt-lst2 (cons 0. (reverse dlt-lst2))))		;; add 0 for first-one
	
	(foreach dlt dlt-lst2							;; draw circles
	  (entmakex (list (cons 0 "CIRCLE") (cons 10 (vlax-curve-getPointAtDist ent (setq dst (+ dst dlt)))) (cons 40 rad))))))
  
  (princ)
  )

 

0 Likes
Message 42 of 42

Anonymous
Not applicable

Are you really apologizing? 🙂
You're helping me wasting your time ... I just have to say thank you all 😉

Anyway, last code update seems to work great! 🤗

0 Likes