cadman6735 发表于 2022-7-6 10:20:39

This is what I like to see, different techniques to accomplish the same result. It opens the mind.
 
 
Basicaly
if one layer is in both states (frozen) and (locked), lets say layer 0 is Frozen and Locked, the list "lst" will contain layer "0" twice, one instance being frozen, and one instance being locked.
 
so as "lst" is being passed to the (foreach)function, Layer 0 will pass thru the (foreach) function twice, once to restore the frozen layer and once to restore the locked layer.
 
Is this correct??? (fingers crossed, that I am right)
 
 
Thanks Alan

cadman6735 发表于 2022-7-6 10:23:31

 
Alan
(setq lst (cons (list x 'Freeze :vlax-true) lst))
How does (lst) get the property (‘Freeze) from (x) as each layer passes thru (x) without the (vlax-get-property) function?

cadman6735 发表于 2022-7-6 10:26:16

Alan
 
Sorry for the bother but I really do want to understand my question above.
 
Thanks

alanjt 发表于 2022-7-6 10:29:20

I freeze the layer in the next line of code. The lst variable is just so I can later apply vlax-put-property to each sublist. 
eg.

(foreach x lst (apply (function vlax-put-property) x))

cadman6735 发表于 2022-7-6 10:32:14

Thanks for the reply Alan
 
Sorry, I don't think I am asking my question correctly.
 
 

(setq lst (cons (list x 'Lock :vlax-true) lst))
 
Where did 'Lock come from?or
 

(setq lst (cons (list x 'Freeze :vlax-true) lst))
 
Where did "Freeze come from?
 
It looks to me you are making a list using some sort of get property technique.
 

(setq lst (vlax-get-property Freeze 'ActiveLayer))

Lee Mac 发表于 2022-7-6 10:37:43

'Lock and 'Freeze are symbol arguments for the vlax-put-property function (hence why they are quoted).
 
Alan could have alternatively used:
 

(setq lst (cons (list x "Lock" :vlax-true) lst))Following the vlax-for loop through the layer collection, the list 'lst' might look something like:
 

((# 'Lock :vlax-true) ... )# being a VLA Layer Object. Each sublist is a list of arguments for the vlax-put-property function.
 
Then, in the foreach loop at the end of the program, these sublists are supplied as arguments to the apply function:
 

(apply 'vlax-put-property '( 'Lock :vlax-true))Which is equivalent to:
 

(vlax-put-property'Lock :vlax-true)

alanjt 发表于 2022-7-6 10:39:11

LoL
Well, there you go.

Lee Mac 发表于 2022-7-6 10:43:34

Sorry for jumping in Alan

alanjt 发表于 2022-7-6 10:44:45

Oh, no worries. I was just laughing at it. Step in an explain my work anytime.

cadman6735 发表于 2022-7-6 10:48:27

I think I understand.
 

(vlax-for x (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))    ;this gets me to the layer properties
 
 

(and (eq (vla-get-lock x) :vlax-true)    ;this get me the lock variable
 
 

(setq lst (cons (list x 'Lock :vlax-true) lst))   ;this creates the list of locked layers
 

(vla-put-freeze x :vlax-false)    ;goes thru the vlax-for turning all frozen layers to thawed
 
 
So, I am going to ask a silly question, 'Freeze and 'Lock are the properties of Layer, 'Freeze and 'Lock are arguments not symbols so I could not use any arbitrary word such as 'Snow, for example.
 
 
 
Why are they quoted? I have been wondering how and when to know to use 'quote and what do they mean. I have seen it in (mapcar) and (lambda)
 
from help menu:
 

(mapcar'(lambda (x)          (+ x 3)          )          '(10 20 30))
 
 
'quoted lists and 'quoted function and 'quoted arguments (this I don't understand)
 
 
Anyway guys, thanks for the education
页: 1 [2]
查看完整版本: need help shortening my '