Lisp works then if another lisp is run the previous one fails to work correctly

Lisp works then if another lisp is run the previous one fails to work correctly

paul9ZMBV
Advocate Advocate
683 Views
6 Replies
Message 1 of 7

Lisp works then if another lisp is run the previous one fails to work correctly

paul9ZMBV
Advocate
Advocate

Hi

komondormrex kindly done me a brilliant lisp to space some drawers within a unit.

 

Link below for reference

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/spacing-of-drawers-with-no-drawer-fr...

 

It works brilliantly but as soon as I run another lisp and then try to run the one above its doesn't work? why would this be ?

 

Please see attached video

Any help much appreciated

0 Likes
Accepted solutions (1)
684 Views
6 Replies
Replies (6)
Message 2 of 7

paul9ZMBV
Advocate
Advocate

komondormrex

 

this is the scenario

 

If i run the "place drawers no front" i works fine

if i then run the "place drawers" it works fine

if i then run the "place drawers no front" again i get the error as per the video

0 Likes
Message 3 of 7

komondormrex
Mentor
Mentor

it is common variables for sure. i will look and tune both.

0 Likes
Message 4 of 7

paul9ZMBV
Advocate
Advocate

thanks

0 Likes
Message 5 of 7

paul9ZMBV
Advocate
Advocate

komondormrex

Been using the shelf lsp you done previously and that's been working great, its just the drawer one that seems to being acting up.

0 Likes
Message 6 of 7

komondormrex
Mentor
Mentor
Accepted solution

it's init_d_values that comes common for drawers codes. i changed it in last code to init_dn_values. do check them work in pair.

 

(defun c:place_drawers_no_front (/  interior_h_line_1 redraw_ interior_h_line_2 line_ends min_x max_x min_y max_y unit_interior_depth unit_interior_height
						   			drawer_ledge drawer_ledge_gap drawer_runner_increment drawers_number drawer_set_back drawer_height
						   			drawer_runner_calculated drawer_runner drawer_block index
					    		)
	(redraw)
	(defun get_dyn_property_by_name (dyn_property_name insert_object / dyn_property_found)
		(if (vl-some '(lambda (dyn_property) (= dyn_property_name (vla-get-propertyname (setq dyn_property_found dyn_property))))
					  (vlax-invoke insert_object 'getdynamicblockproperties)
			) dyn_property_found nil
		)
	)
	(setq init_dn_values (if (null init_dn_values) (setq init_dn_values '(3 70 40)) init_dn_values)
		  interior_h_line_1 (car (entsel "\nPick unit interior horizontal 1st line: "))
		  redraw_ (redraw interior_h_line_1 3)
		  interior_h_line_2 (car (entsel "\nPick unit interior horizontal 2nd line: "))
		  redraw_ (redraw interior_h_line_2 3)
		  line_ends (apply 'append (mapcar '(lambda (line) (list (vlax-get (vlax-ename->vla-object line) 'startpoint)
												  		   		 (vlax-get (vlax-ename->vla-object line) 'endpoint)
														   )
											)
											(list interior_h_line_1 interior_h_line_2)
							 	   )
					)
		  min_x (apply 'min (mapcar 'car line_ends))
		  max_x (apply 'max (mapcar 'car line_ends))
		  min_y (apply 'min (mapcar 'cadr line_ends))
		  max_y (apply 'max (mapcar 'cadr line_ends))
		  unit_interior_depth (- max_x min_x)
		  unit_interior_height (- max_y min_y)
		  drawer_ledge     		  15
		  drawer_ledge_gap        5
		  drawer_runner_increment 20
		  drawers_number (getint (strcat "\nEnter number of drawers <"   (itoa (nth 0 init_dn_values)) ">: "))
		  drawers_number (if (null drawers_number)   					 	   (nth 0 init_dn_values) drawers_number)
	      drawer_set_back (getint (strcat "\nEnter drawer set back <"    (itoa (nth 1 init_dn_values)) ">: "))
		  drawer_set_back (if (null drawer_set_back) 						   (nth 1 init_dn_values) drawer_set_back)
	      drawer_gap (getint (strcat "\nEnter drawer gap <"    	         (itoa (nth 2 init_dn_values)) ">: "))
		  drawer_gap (if (null drawer_gap) 						         	   (nth 2 init_dn_values) drawer_gap)
		  drawer_height (/ (- unit_interior_height (+ drawer_ledge_gap (* drawers_number (+ drawer_ledge drawer_gap)))) drawers_number)
		  drawer_runner_calculated (* drawer_runner_increment (fix (/ (- unit_interior_depth drawer_set_back drawer_runner_increment) drawer_runner_increment)))
	      drawer_runner (getint (strcat "\nEnter drawer runner <" (itoa drawer_runner_calculated) ">: "))		;	Drawer Runner
		  drawer_runner (if (null drawer_runner) drawer_runner_calculated drawer_runner)
		  drawer_block (vla-insertblock (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
									  	(vlax-3d-point (setq 1st_insert_point (list (- max_x drawer_set_back) (+ min_y drawer_ledge_gap drawer_ledge))))
									  	"Drawer Side No Front"
									  	1 1 1 0
					   )
		  index 0
	)
	(vlax-put (get_dyn_property_by_name "Height" drawer_block) 'value drawer_height)
	(vlax-put (get_dyn_property_by_name "Runner" drawer_block) 'value (float drawer_runner))
	(repeat (1- drawers_number)
		(vla-move (vla-copy drawer_block)
				  (vlax-3d-point 1st_insert_point)
				  (vlax-3d-point (list (car 1st_insert_point) (+ (cadr 1st_insert_point) (* (1+ index) (+ drawer_height drawer_gap drawer_ledge)))))
		)
		(setq index (1+ index))
	)
	(setq init_dn_values (list drawers_number drawer_set_back drawer_gap))
	(redraw interior_h_line_1 4)
	(redraw interior_h_line_2 4)
	(princ)
)

 

 

0 Likes
Message 7 of 7

paul9ZMBV
Advocate
Advocate

Thankyou komondormrex, that seem to do the trick

I've tried many combinations with the drawers, shelves and drawers with no fronts and all seem to be working perfectly

Many thanks for your time it is much appreciated

0 Likes