Setting arraypath direction and selection via LISP

Setting arraypath direction and selection via LISP

zdavisMLD73
Explorer Explorer
1,203 Views
6 Replies
Message 1 of 7

Setting arraypath direction and selection via LISP

zdavisMLD73
Explorer
Explorer

My lisp command draws a line from point 1 to point 2, and I later use that line as the 'select path curve' line. Also, when using the routine at a location that is a negative on the x-axis, the array will offset to the left, however if it's on the positive x-axis, it offsets to the right.

 

It would be awesome if I could:

 

A) set the path curve line as point 1 to point 2, rather than having to draw a line first and selecting it afterwards(thus saving the user a step).

B)force the arraypath to always array to the right (or towards the positive x-axis direction)

 

Does anyone have ideas to help?

 

Thank you,

 

(defun c:ap10 ( / ss1 a_path pnt1 pnt2)
(setvar "cmdecho" 0)
(setq pnt1 (getpoint "\nSelect bottom left corner of field area: "))
(setq pnt2 (getpoint "\nSelect bottom right corner of field area: "))
(command "line" pnt1 pnt2 "")
(prompt "\nSelect wall on RIGHT side: ")
(setq ss1 (entsel))
(setq a_path (car (entsel "\nSelect array path: ")))
(if (and ss1 a_path)
(command "_arraypath" ss1 "" a_path "" "" "" "_F" "60" "" "")
(princ "\nNo array created!")
)
(princ)
)
0 Likes
Accepted solutions (1)
1,204 Views
6 Replies
Replies (6)
Message 2 of 7

Moshe-A
Mentor
Mentor

@zdavisMLD73  hi,

 

check this

 

moshe

 

 

(defun c:ap10 ( / pnt1 pnt2 ss1 ename a_path)
 (setvar "cmdecho" 0)
 (command "_.undo" "_begin") 

 (if (and 
       (setq ss1 (LM:ssget "\nSelect wall on RIGHT side: " nil)) ; thanks to Lee Mac
       (setq pnt1 (getpoint "\nSelect bottom left corner of field area: "))
       (setq pnt2 (getpoint pnt1 "\nSelect bottom right corner of field area: "))
     )
  (progn
   (command "line" pnt1 pnt2 "")
   (setq ename (entlast))

   (cond
    ((equal (cadr pnt1) (cadr pnt2) 1e-3) ; is it Hor line?
     (if (< (car pnt1) (car pnt2))
      (setq a_path (list ename (polar pnt1 (angle pnt1 pnt2) (* (distance pnt1 pnt2) 0.2))))
      (setq a_path (list ename (polar pnt2 (angle pnt2 pnt1) (* (distance pnt2 pnt1) 0.2))))
     )
    ); case
    ((equal (car pnt1) (car pnt2) 1e-3)   ; is it Ver line?
     (if (< (cadr pnt1) (cadr pnt2))
      (setq a_path (list ename (polar pnt1 (angle pnt1 pnt2) (* (distance pnt1 pnt2) 0.2))))
      (setq a_path (list ename (polar pnt2 (angle pnt2 pnt1) (* (distance pnt2 pnt1) 0.2))))
     )
    ); case
   ); cond
   
   (if a_path  
    (command "_.arraypath" "_si" ss1 a_path "_F" "" "")
    (prompt "\nArray path not ortho.")
   )

   (entdel ename)
  ); progn 
  (princ "\nNo array created!")
 ); if

 (command "_.undo" "_end")
(setvar "cmdecho" 1)
(princ) ); c:ap10 ;; ssget - Lee Mac ;; A wrapper for the ssget function to permit the use of a custom selection prompt ;; msg - [str] selection prompt ;; arg - [lst] list of ssget arguments (defun LM:ssget ( msg arg / sel ) (princ msg) (setvar 'nomutt 1) (setq sel (vl-catch-all-apply 'ssget arg)) (setvar 'nomutt 0) (if (not (vl-catch-all-error-p sel)) sel) )
0 Likes
Message 3 of 7

zdavisMLD73
Explorer
Explorer

Hmm, unfortunately I ran into the same issue with the array going the opposite direction. Please see screenshot. The left object arrayed left when I selected the West wall, while the right object arrayed right when I selected the West wall.

0 Likes
Message 4 of 7

Moshe-A
Mentor
Mentor

it looks like the arrraypath coming from (command) function behave differently when the selected object is coming from negative  X cartezic coordinates - sorry

0 Likes
Message 5 of 7

Moshe-A
Mentor
Mentor

@zdavisMLD73 ,

 

i have further investigate this this morning and now it looks like the game is to use the right arraypath options

i will continue it tonight.

 

moshe

 

0 Likes
Message 6 of 7

Moshe-A
Mentor
Mentor
Accepted solution

@zdavisMLD73  hi,

 

OK solved it. i assumed that the respond to Select Path Curve should be the same as return value from (entsel) but it was wrong. Select Path Curve Expecting only a point, so i fix it and now it's working as you expected

i'm leaving it for you to choose the the right option arguments for the (command "_.arraypath" ........) 

 

enjoy

moshe

 

 

(defun c:ap10 (/ pnt1 pnt2 ss1 ename a_path)
 (setvar "cmdecho" 1)
 (command "_.undo" "_begin") 

 (if (and 
       (setq ss1 (LM:ssget "\nSelect wall on RIGHT side: " nil)) ; thanks to Lee Mac
       (setq pnt1 (getpoint "\nSelect bottom left corner of field area: "))
       (setq pnt2 (getpoint pnt1 "\nSelect bottom right corner of field area: "))
     )
  (progn
   (command "line" pnt1 pnt2 "")
   (setq ename (entlast))

   (cond
    ((equal (cadr pnt1) (cadr pnt2) 1e-3) ; is it Hor line?
     (if (< (car pnt1) (car pnt2))
      (setq a_path (polar pnt1 (angle pnt1 pnt2) (* (distance pnt1 pnt2) 0.2)))
      (setq a_path (polar pnt2 (angle pnt2 pnt1) (* (distance pnt2 pnt1) 0.2)))
     ); if
    ); case
    ((equal (car pnt1) (car pnt2) 1e-3)   ; is it Ver line?
     (if (< (cadr pnt1) (cadr pnt2))
      (setq a_path (polar pnt1 (angle pnt1 pnt2) (* (distance pnt1 pnt2) 0.2)))
      (setq a_path (polar pnt2 (angle pnt2 pnt1) (* (distance pnt2 pnt1) 0.2)))
     )
    ); case
   ); cond
   
   (if a_path
    (command "_.arraypath" "_si" ss1 (osnap a_path "near") "_F" 5 "" "") ; adjust this line as you want
    (prompt "\nArray path not ortho.")
   )

   (entdel ename)
  ); progn 
  (princ "\nNo array created!")
 ); if

 (command "_.undo" "_end")
 (princ)
); c:ap10


;; ssget  -  Lee Mac
;; A wrapper for the ssget function to permit the use of a custom selection prompt
;; msg - [str] selection prompt
;; arg - [lst] list of ssget arguments
 
(defun LM:ssget ( msg arg / sel )
 (princ msg)
 (setvar 'nomutt 1)
 (setq sel (vl-catch-all-apply 'ssget arg))
 (setvar 'nomutt 0)
 (if (not (vl-catch-all-error-p sel)) sel)
)

 

 

0 Likes
Message 7 of 7

zdavisMLD73
Explorer
Explorer

Wow, you were a great help on this. Thank you for taking the time to help me out!

0 Likes