Lee Mac Posted February 16, 2011 Posted February 16, 2011 (vlax-for x (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) [color=red];this gets me to the layer properties[/color] The above iterates through the Layer Collection, which contains the VLA Layer Objects for each layer in the Drawing. Think of vlax-for as a foreach function for iterating through VLA Collection Objects instead of lists. So, in the above we are saying: "For each Layer Object in the Layers Collection..." (and (eq (vla-get-lock x) :vlax-true) [color=red];this get me the lock variable [/color] This checks whether the Lock Property (not variable) of the Layer Object has a value of :vlax-true, hence checking whether the Layer is locked. (setq lst (cons (list x 'Lock :vlax-true) lst)) [color=red];this creates the list of locked layers[/color] This creates a list of: ((<VLA Layer Object> <Property Name> <Property Value>) ... ) For each locked layer. (vla-put-freeze x :vlax-false) [color=red] ;goes thru the vlax-for turning all frozen layers to thawed[/color] Correct, this sets the 'freeze' property of the VLA Layer Object to a value of :vlax-false, hence thawing the associated Layer. 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. Looking at the help for the vlax-put-property function, notice that it details the 'property' argument as: [i] property[/i] [b][i]A symbol or string[/i][/b] naming the property to be set. Hence we can supply it with 'Lock (a symbol), or "Lock" (a string). Where Lock is the name of a property belonging to a VLA Layer Object. 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) So that the symbols are taken as arguments to the vlax-put-property function and, more importantly, are not evaluated. If the symbols were evaluated, they would be treated as variables and would most probably evaluate to nil. That's precisely what the quote is used for, to mark expressions that are to be taken as literal statments and not be evaluated. Here is another explanation which might be of additional help: http://www.cadtutor.net/forum/showpost.php?p=258390&postcount=20 Quote
alanjt Posted February 16, 2011 Posted February 16, 2011 I'm quite glad you stepped in. I was in no mood to type all that. Quote
BlackBox Posted February 16, 2011 Posted February 16, 2011 I'm quite glad you stepped in. I was in no mood to type all that. Truly funny... that's been my mood for weeks now. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.