Remember previous DCL values(Default Values)

Remember previous DCL values(Default Values)

desmund08
Contributor Contributor
3,973 Views
23 Replies
Message 1 of 24

Remember previous DCL values(Default Values)

desmund08
Contributor
Contributor

Hi All,

 

Hope you could help me with this one.

 

I have a lisp with dcl that is working already but I want my previous values to be the default value when I run the program again.

 

PLease find attached lisp and dcl files.

 

Thank you in advance.

 

Regards,

 

Desmund

 

0 Likes
Accepted solutions (2)
3,974 Views
23 Replies
Replies (23)
Message 21 of 24

pbejse
Mentor
Mentor

@desmund08 wrote:

Oh. Sorry I thought the result from the program.

 

Say I have 9 paths,

path1 - for apple, plastic bag (blocks inside path are a1, a2,...a7)

....


Do i look like Proffesor X to you Desmund? 😀

Px.png

 

Again, you're just throwing some randon names as an example. 

 

Please note, that n your previous posts, you are making us guess . As your sample code is incompete. 

I added the "cond and insert" bit as a bonus for you, hoping you can pick it up from there.

 

I will give you the rest of the day to figure it out on your own. 

 

Its really easy, its either the folder name is the same as the key 

(strcat driveletter keyname storage quantity)

or a different one

(strcat driveletter (cadr (assoc keyname ThrFruits ))  storage quantity)

 

Holler if starting to have a nosebleed.

 

 

 

0 Likes
Message 22 of 24

desmund08
Contributor
Contributor

@pbejse wrote:

@desmund08 wrote:

Oh. Sorry I thought the result from the program.

 

Say I have 9 paths,

path1 - for apple, plastic bag (blocks inside path are a1, a2,...a7)

....


Do i look like Proffesor X to you Desmund? 😀

Px.png

 

Again, you're just throwing some randon names as an example. 

 

Please note, that n your previous posts, you are making us guess . As your sample code is incompete. 

I added the "cond and insert" bit as a bonus for you, hoping you can pick it up from there.

 

I will give you the rest of the day to figure it out on your own. 

 

Its really easy, its either the folder name is the same as the key 

(strcat driveletter keyname storage quantity)

or a different one

(strcat driveletter (cadr (assoc keyname ThrFruits ))  storage quantity)

 

Holler if starting to have a nosebleed.

 

 

 


@pbejse Honestly, I don't know how to associate the fruit tile. Even if it's easy I still don't have any any idea on that.

I tried to figure out on how to use your hint above but I was not able to. Maybe I'm just too dumb for this.😁 

I used "if" instead and was able to make the code working. I don't know if this is the best way. Please suggest if there is a better and simple way to do it. By the way, below is the working one:

 

(defun C:fruitBasket (/ _WhatIsSelected _SummaryInfo aDoc dProps
		      _Path&block dcl_id flag storage quantity filetoInsert)
  
(Defun _WhatIsSelected ()
    (mapcar
      '(lambda (r)
	 (vl-some '(lambda (rd)
		     (if (eq "1" (get_tile rd))
		       rd
		     )
		   )
		  r
	 )
       )
      '(("fruit1" "fruit2" "fruit3")
	("0" "1" "2")
	("00" "01" "02" "03" "04" "05" "06") 
       )
    )
  )
  (defun _SummaryInfo (lst dp)
    ((lambda (n)
       (mapcar
	 '(lambda (key)
	    (cond
	      ((vl-catch-all-error-p
		 (vl-catch-all-apply
		   'vla-GetCustomByKey
		   (list dp (Car key) 'value)
		 )
	       )
	       (vla-AddCustomInfo dp (Car key) (Cadr key))
	       (Cadr key)
	      )
	      (lst
	       (vla-SetCustomByKey
		 dp
		 (Car key)
		 (setq v (nth (Setq n (1+ n)) lst))
	       )
	       v
	      )
	      (value)
	    )
	  )
	 '(("RADIO1" "fruit1")
	   ("RADIO2" "0")
	   ("RADIO3" "00")
	  )
       )
     )
      -1
    )
  )

  (setq aDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
  (setq dProps (vla-get-SummaryInfo aDoc))
  
  (setq dcl_id (load_dialog "C:\\Downloads\\Fruit_basket.DCL"))
  (if (not (new_dialog "FRUIT_TEST" dcl_id))
    (exit)
  )					;if

  (mapcar '(lambda (r) (set_tile r "1"))
	  (_SummaryInfo lst dProps)
  )

  (action_tile "cancel" "(done_dialog 0)")
  (action_tile
    "accept"
    "(setq lst (_WhatIsSelected))
  		(_SummaryInfo lst dProps)(setq dia 2) (done_dialog 1)"
  )

  (setq flag (start_dialog))
  (unload_dialog dcl_id)

  (if (= (car lst) "fruit1")
    (setq _Path&block 
    	'(	("C:\\xxx\\" ("111" "222" "333" "444" "555" "666" "777"))
			("c:\\yyy\\" ("x1" "x2" "x3" "x4" "x5" "x6" "x7"))
		    	("c:\\zzz\\" ("y1" "y2" "y3" "y4" "y5" "y6" "y7"))
		    	)
    ))

(if (= (car lst) "fruit2")
    (setq _Path&block 
    	'(	("C:\\xxx\\" ("aaa" "bbb" "ccc" "ddd" "eee" "fff" "ggg"))
			("c:\\yyy\\" ("xx1" "xx2" "xx3" "xx4" "xx5" "xx6" "xx7"))
		    	("c:\\zzz\\" ("yy1" "yy2" "yy3" "yy4" "yy5" "yy6" "yy7"))
		    	)
    ))
(if (= (car lst) "fruit3")
    (setq _Path&block 
    	'(	("C:\\xxx\\" ("aa1" "aa2" "aa3" "aa4" "aa5" "aa6" "aa7"))
			("c:\\yyy\\" ("xxx1" "xxx2" "xxx3" "xxx4" "xxx5" "xxx6" "xxx7"))
		    	("c:\\zzz\\" ("yyy1" "yyy2" "yyy3" "yyy4" "yyy5" "yyy6" "yyy7"))
		    	)
    ))

  
	(cond
	  (	(zerop flag) (princ "\nCancelled.")
	   		)	  
	  (	(and (= flag 1)
			(setq storage	(nth (atoi (Cadr lst)) _Path&block)
			      quantity	(nth (atoi (Caddr lst)) (cadr storage))
			)
		 
		 (findfile
		   (setq filetoInsert (strcat (car storage) quantity ".dwg"))
		   
		 )
	    	)
		(command "-insert" filetoInsert "\\" 1 1 "\\")
	   		)
	   (	T  (princ (strcat "\n" filetoInsert " Not found"))
			)
	)
  (princ)
)
0 Likes
Message 23 of 24

pbejse
Mentor
Mentor
Accepted solution

@desmund08 wrote:
@pbejse 

...I tried to figure out on how to use your hint above but I was not able to. Maybe I'm just too dumb for this.😁 

I used "if" instead and was able to make the code working. I don't know if this is the best way. Please suggest if there is a better and simple way to do it. By the way, below is the working one:


 

Dont say that @desmund08 , if you think that often enough,  you will to start believe that it's true. 👓

Good try using "IF" 👍.  but you can still shorten that by separating the path items

 

 

(setq _Path&  (nth (setq _path (atoi (Cadr lst)))
		   '("C:\\xxx\\" "c:\\yyy\\" "c:\\zzz\\"))
      _&block (cadr (assoc (Car lst) 
			'(("fruit1"
			   (("111" "222" "333" "444" "555" "666" "777")
			    ("x1" "x2" "x3" "x4" "x5" "x6" "x7")
			    ("y1" "y2" "y3" "y4" "y5" "y6" "y7")))
			  ("fruit2"
			   (("aaa" "bbb" "ccc" "ddd" "eee" "fff" "ggg")
			    ("xx1" "xx2" "xx3" "xx4" "xx5" "xx6" "xx7")
			    ("yy1" "yy2" "yy3" "yy4" "yy5" "yy6" "yy7")))
			  ("fruit3"
			   (("aa1" "aa2" "aa3" "aa4" "aa5" "aa6" "aa7")
			    ("xxx1" "xxx2" "xxx3" "xxx4" "xxx5" "xxx6" "xxx7")
			    ("yyy1" "yyy2" "yyy3" "yyy4" "yyy5" "yyy6" "yyy7")))
			 ))))

 

 

 

(cond
	  (	(zerop flag) (princ "\nCancelled.") )	  
	  (	(and (= flag 1)
			(setq storage	(nth _path _&block)
			      quantity	(nth (atoi (Caddr lst)) storage)
			)		 
		 (findfile
		   (setq filetoInsert (strcat _Path& quantity ".dwg"))))		   
		(command "-insert" filetoInsert "\\" 1 1 "\\")
	   		)
	   (	T  (princ (strcat "\n" filetoInsert " Not found")))
	)

Refer to attached file [ TheSelectedFruit 2.0.lsp ]

HTH

 

Message 24 of 24

desmund08
Contributor
Contributor

Thanks again @pbejse. Now I have other options to do it. I usually do the long method because that's what I only understand. Still have alot to learn.

0 Likes