Jef! 发表于 2022-7-5 18:47:46

Hi Grrrr..
 
2 little comments
 

(cond ((not blkname)          (progn (princ "\nMissed.. Try again!")(C:test))         )         ((not found)          (princ "\n Block not found in drawing !!!")         )         (t...
Having the cond relaunch the c:test command doesnt just relaunch the command, but relaunch it recursively! (hint 1: use a while... hint 2:Maybe you should read that thread made by a nice op called Grrrr who had the same approach before being suggested otherwise with a while example in the best reply he ever received...
 
 
Ah! I just understood the question... set a quote => set quote => (set(quote => setq.
Well, a for-each approach can be used for a list no matters the # of contained arguments. While (last ) retrieve the last element, you could also use (car ) to retrieve the 1rst element, or again the (nth) to retrieve a specific element of the list (keeping in mind that the first element of a list is (nth 0 ).You could use (length ) to verify how many elements are contained in the list and act accordingly only if the length is 1.
 
..as for the quote function, won't be much use for you here. It just instructs cad to returns the expression without evaluating it, so (quote(princ "hello")) would literally return (PRINC "hello")
 
-------
The next part might be usefull to understand return values only if I correctly understood what you meant.
Are you reffering to the returned value of your function? If so, in your example, your users do not get the returned value. The returned value is the last expression evaluated, and the last thing you do is (princ), which exit quietly. Let's take these 2 functions.

(defun foo ()(princ 2)(princ))(defun baz ()2)
By using them, here's what we get.
Even if it looks the same, let's bind their returned value to a symbol and see what happens
zzz doeesn't seems to contain anything, yet is doesn't return nil. If we check what is the type...
now lets check if zzz and (princ) are bound to the same object with the "nasty" (eq function

(eq zzz (princ))T
..so, any program ending by (princ) returns... (princ)
 
Cheers
(princ)

Grrr 发表于 2022-7-5 18:56:06

Thanks, Jef!!
 
Excuse me for the recursive relaunch, I grabbed some old routine that I mixed-up and started these experiments.
I hope this would do the job:

    (cond          ((= 52 (getvar 'errno))          (princ "\nMissed.. Try again!")(C:test)         )         ((null sel)          (princ "\nYou missed, try again.")(C:test)         )         ((not blkname)          (princ "\n Missed name of block ***")         )         ((not found)          (princ "\n Block not found in drawing !!!")         )         (t          (princ "\n couldn't find any block !!! ")         )   );cond
 
Before your post I figured out that I might just use (setq setquoteditem (car listwithoneitem))
such method didn't feel very right to me so I had to ask, but reading this from your post:
by providing the length check for the list first would make the code look more right
 
 
 
Anyway, everything seems to work fine..
I get all the attribute tags in the listbox
I get all the attribute values in the listbox
I get all the parameter tags in the listbox
But I do not get the parameter values in the listbox
 
So the reason why (it might be) is because that the "lst-param-vals" must contain a mix of numbers/strings/symbols.
With my lack of list experience I came up with this (my concept doesn't work ofcourse):

(setq lst-param-vals (append '(mapcar 'cdr lst-params) lst-param-vals)) ; create list with 2nd associated element from lst-params; sort the items from the "lst-param-vals", by constructing sorted lists(foreach itm lst-param-vals(cond ((numberp itm) (setq listwithnumbers '()) (append itm listwithnumbers) ; add it to numbers list ) ((stringp itm) (setq listwithstrings '()) (append itm listwithstrings) ; add it to strings list ) ((symbolp itm) (setq listwithsymbols '()) (append itm listwithsymbols) ; add it to symbols list ));cond);end of foreach (print listwithnumbers) (print listwithstrings) (print listwithsymbols)
Construct lists to sort out the different items.
 
 
 
 
However I'm not sure I'm going on the right track, I mean:

;; Get Dynamic Block Properties-Lee Mac;; Returns an association list of Dynamic Block properties & values.;; blk - VLA Dynamic Block Reference object;; Returns: Association list of (( . ) ... )
How does one who gets such association list could benefit from it?
 
The way I could think of it is to extract theand theof one or a few items and for example put some conditioning to select by/match by these attribute's/parameter's tags/values.
 
(maybe for this question I should start new thread, because it could be long to discuss - working with assoc lists)
页: 1 [2]
查看完整版本: Dynamic block - analyzing (LM&