lisp in Start Up Suite is running automatically when opening a new drawing even before typing in command ?

lisp in Start Up Suite is running automatically when opening a new drawing even before typing in command ?

paul9ZMBV
Advocate Advocate
445 Views
7 Replies
Message 1 of 8

lisp in Start Up Suite is running automatically when opening a new drawing even before typing in command ?

paul9ZMBV
Advocate
Advocate

Hi 

 

I have many lips in autocad all of which are in the start up suite, i have recently added one and on opening a new drawing the lisp is running and asking for inputs event though i havent anything in the command line?

 

Any help much appreciated

0 Likes
Accepted solutions (1)
446 Views
7 Replies
Replies (7)
Message 2 of 8

annoisscary
Advocate
Advocate

Typically this can be attributed to either incorrect formatting or a line that calls the function outside of the main function, i.e. a line like "(myfunction do stuff)"

 

Only way to be sure is if you provide a copy of the code to look at.

0 Likes
Message 3 of 8

cadffm
Consultant
Consultant

Hi,

 

to load a lisp by (load ) drag&drop, Appload (also start up suite) means:

AutoCAD read the FILE, line by line and evaluate the content.

A Lisp file is not a function or program! But you can define a program or function by

loading this file.

 

As @annoisscary said, this file contains lisp statement(s) what do not just define anything.

Share the content and we can help you.

Sebastian

0 Likes
Message 4 of 8

paul9ZMBV
Advocate
Advocate

Hi annoisscary

 

Thanks for the reply

 

the code is as follows (there are two lisps when is caling up the other)

 

(defun c:tg_board (/ total_width_dim _redraw total_width boards_number tongue_thickness tongue_setback tongue_length tongue_overlap insertion_point
              board_thickness boards_gap one_board_width board_start_geom_list board_end_geom_list vertices_list
           )
(setq total_width_dim (car (entsel "\nPick dimension for total width: "))
 _redraw (redraw total_width_dim 3)
 total_width (cdr (assoc 42 (entget total_width_dim)))
)

(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq ans (AH:getvalsm (list "Enter values"
  "Enter number of boards: "  5 4 "10"
  "Enter board_thickness: " 5 4 "22"
  "Enter tongue thickness: " 5 4 "6"
  "Enter tongue setback: " 5 4 "8"
  "Enter tongue_length: " 5 4 "12"
  "Enter boards_gap: " 5 4 "3"
  "Enter boards_chamfer: " 5 4 "3"
    )
)
)
         
(setq boards_number (atoi (nth 0 ans))
    board_thickness (atof (nth 1 ans))
    tongue_thickness (atof (nth 2 ans))
    tongue_setback (atof (nth 3 ans))
    tongue_length (atof (nth 4 ans))
    boards_gap (atof (nth 5 ans))
    boards_chamfer (atof (nth 6 ans))
    )
     
(setq insertion_point (getpoint "\nPick insertion point: ")
insertion_point_list '((0 0))
tongue_overlap (- tongue_length boards_gap)
one_board_width (/ (- total_width (* boards_gap (1- boards_number))) boards_number)
board_start_geom_list (list (list (list one_board_width (+ (- board_thickness) tongue_setback))   ; 1
    (list one_board_width (+ (- board_thickness) boards_chamfer))       ;   2
    (list (- one_board_width boards_chamfer) (- board_thickness))   ;   3 this control chamfer
    (list boards_chamfer (- board_thickness))                           ;       4 this controls chamfer
    (list 0 (+ (- board_thickness) boards_chamfer))             ;   5
    (list 0 (+ (- board_thickness) tongue_setback))             ;   6
    (list (- tongue_length) (+ (- board_thickness) tongue_setback))     ;   7
    (list (- tongue_length) (+ (- board_thickness) tongue_setback tongue_thickness))    ;   8
    (list 0 (+ (- board_thickness) tongue_setback tongue_thickness))            ;   9
    (list 0 0)  ;   10
    (list one_board_width 0)    ;   11
    (list one_board_width (+ (- board_thickness) tongue_setback tongue_thickness))  ;   12
    )
    (list (list (- one_board_width tongue_overlap) (+ (- board_thickness) tongue_setback tongue_thickness)) ;   1
    (list (- one_board_width tongue_overlap boards_gap) (+ (- board_thickness) tongue_setback tongue_thickness))    ;   2
    (list (- one_board_width tongue_overlap boards_gap) (+ (- board_thickness) tongue_setback)) ;   3
    (list (- one_board_width tongue_overlap) (+ (- board_thickness) tongue_setback))    ;   4
    )
    )
    board_end_geom_list (append (car board_start_geom_list)
    (list (list (+ one_board_width tongue_length) (+ (- board_thickness) tongue_setback tongue_thickness))) ;   13
    (list (list (+ one_board_width tongue_length) (+ (- board_thickness) tongue_setback)))  ;   14
    )
    )
(repeat (1- boards_number) (setq insertion_point_list (append insertion_point_list (list (mapcar '+ (last insertion_point_list) (list (+ one_board_width boards_gap) 0))))))  (foreach insertion (vl-remove (last insertion_point_list) insertion_point_list)
(foreach pline board_start_geom_list
(vla-addlightweightpolyline (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
(vlax-safearray-fill (vlax-make-safearray vlax-vbdouble
(cons 1 (length (setq vertices_list
(apply 'append
(mapcar '(lambda (vertex) (mapcar '+ insertion_point insertion vertex))
pline
)
)
)
)
)
)
vertices_list
)
)
)
)
(vlax-put (vla-addlightweightpolyline (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
(vlax-safearray-fill (vlax-make-safearray vlax-vbdouble
(cons 1 (length (setq vertices_list
(apply 'append
(mapcar '(lambda (vertex) (mapcar '+ insertion_point
(last insertion_point_list)
vertex
)
)
board_end_geom_list
)
)
)
)
)
)
vertices_list
)
)
'closed
1
)
(redraw total_width_dim 4)
(princ)
)
(c:tg_board)
 
0 Likes
Message 5 of 8

paul9ZMBV
Advocate
Advocate
; Getvals multi allows multiple line inputs
; By Alan H Feb 2019 info@alanh.com.au
;
; code examples
; the input box size can be bigger just change the two values tetsed with 145 145 and worked ok.
; (if (not AH:getvalsm)(load "Multi Getvals.lsp"))
; (setq ans (AH:getvalsm (list "Enter values " "Rows" 5 4 "3" "columns " 5 4 "10" "Gap" 5 4 "20")))
; (setq ans (AH:getvalsm (list "Enter values " "Length " 5 4 "6" "width" 5 4 "1")))
; (setq l1 (atof (car ans)) l2 (atof (cadr ans)))
;
; (setq L1 (atof (nth 0 ans)) L2 (atof (nth 1 ans)) L3 (atof (nth 2 ans)) L4 (atof (nth 3 ans)))

; note the values are strings not numbers can be any number including decimal "25.4"

; (setq ans (AH:getvalsm (list "Enter Values" "Length      " 5 4 "100" "Width" 5 4 "50" "Depth" 5 4 "25" "Gap" 5 4 "25")))
; note the values are strings so use atof to convert to real number others can be strings
; (setq len (atof (nth 0 ans)) wid (atof (nth 1 ans)) depth (atof (nth 2 ans)) gap (atof (nth 3 ans)))

; mix of numbers and strings
; (setq ans (AH:getvalsm (list "Enter Values" "Length      " 5 4 "100" "Width" 5 4 "50" "Depth" 5 4 "25" "Gap type" 5 4 "A")))
; (setq len (atof (nth 0 ans)) wid (atof (nth 1 ans)) depth (atof (nth 2 ans)) gap (nth 3 ans))

(defun AH:getvalsm (dcllst / x y num fo fname keynum key_lst v_lst)
  (setq num (/ (- (length dcllst) 1) 4))
  (setq x 0)
  (setq y 0)

(setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w"))
  (write-line "ddgetvalAH : dialog {" fo)
  (write-line (strcat " label =" (chr 34) (nth 0 dcllst) (chr 34) " ;") fo)
  (write-line " : column {" fo)
  (write-line " width =25;" fo)
  (repeat num
    (write-line "spacer_1 ;" fo)
    (write-line ": edit_box {" fo)
    (setq keynum (strcat "key" (rtos (setq y (+ Y 1)) 2 0)))
    (write-line (strcat "    key = " (chr 34) keynum (chr 34) ";") fo)
    (write-line (strcat " label = " (chr 34) (nth (+ x 1) dcllst) (chr 34) ";") fo)
    (write-line (strcat "     edit_width = " (rtos (nth (+ x 2) dcllst) 2 0) ";") fo)
    (write-line (strcat "     edit_limit = " (rtos (nth (+ x 3) dcllst) 2 0) ";") fo)
    (write-line "   is_enabled = true ;" fo)
    (write-line "   allow_accept=true ;" fo)
    (write-line "    }" fo)
    (setq x (+ x 4))
  )
  (write-line "    }" fo)
  (write-line "spacer_1 ;" fo)
  (write-line "ok_cancel;}" fo)
  (close fo)

  (setq dcl_id (load_dialog fname))
  (if (not (new_dialog "ddgetvalAH" dcl_id))
    (exit)
  )
  (setq x 0)
  (setq y 0)
  (setq v_lst '())
  (repeat num
    (setq keynum (strcat "key" (rtos (setq y (+ Y 1)) 2 0)))
    (setq key_lst (cons keynum key_lst))
    (set_tile keynum (nth (setq x (+ x 4)) dcllst))
   ; (mode_tile keynum 3)
  )
    (mode_tile "key1" 2)
  (action_tile "accept" "(mapcar '(lambda (x) (setq v_lst (cons (get_tile x) v_lst))) key_lst)(done_dialog)")
  (action_tile "cancel" "(setq ah:cancel \"Yes\")(done_dialog)")
  (start_dialog)
  (unload_dialog dcl_id)
 ; (vl-file-delete fname)

  (princ v_lst)
)
(princ)
0 Likes
Message 6 of 8

paul9ZMBV
Advocate
Advocate

Please see attached video showing what is happening

 

it will only load the rest of autocad (ribbons etc) once escape have been pressed

0 Likes
Message 7 of 8

annoisscary
Advocate
Advocate
Accepted solution

The very last line of your first reply to me. "(c:tg_board)"

That line literally translates to "run this function" as long as it is in your code, whenever you load the lisp its going to run it immediately after loading.

0 Likes
Message 8 of 8

paul9ZMBV
Advocate
Advocate

Fantastic, works perfectly now

 

much appreciated

 

0 Likes