Author Topic: Would like to ask some question about my code  (Read 1562 times)

0 Members and 1 Guest are viewing this topic.

cadman6735

  • Guest
Would like to ask some question about my code
« on: January 31, 2011, 05:47:36 PM »
I have some questions about my code.

Code: [Select]
(defun C:test ( / LayerBin)

  (vl-load-com)

  (setq
    acadObject (vlax-get-acad-object)
    acadActiveDocument (vla-get-ActiveDocument acadObject)
  ) 

(setq
    acadLayers (vla-get-Layers acadActiveDocument)
  )

  (vlax-for eachLockedLayer acadLayers
    (if
      (= (vla-get-Lock eachLockedLayer) :vlax-true)
      (progn
(setq LayerBin (cons eachLockedLayer LayerBin))
(vla-put-Lock eachLockedLayer :vlax-false)
      )
    )
  )


{work done here}

 (vlax-for eachLayer LayerBin
   (vla-put-Lock eachLayer :vlax-true)
 )

(princ)
)



The first (vlax-for) works just fine but the second one does not.  I guess my quesion is  "What is LayerBin in my second (vlax-for) statement?"

I am assuming that I need a sset to work with and in my case LayerBin is only a list (guessing), LayerBin is my container symbol so I can unlock all layers, work on the layer then lock them back when done.  The names are there in LayerBin so why will my second vlax-for statment not work.

Thanks

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Would like to ask some question about my code
« Reply #1 on: January 31, 2011, 05:50:52 PM »
First, welcome the theSwamp.

LayerBin = a list created by you.

To work on a regular list, use ' foreach ' instead of ' vlax-for ', which is used to step through an ActriveX collection.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

cadman6735

  • Guest
Re: Would like to ask some question about my code
« Reply #2 on: January 31, 2011, 06:13:06 PM »
Thanks for welcoming, I am happy to be here.

LayerBin = list

Happy that I guessed right, frustrated that I have more work ahead of me.

with my new found knowledge, I will play with my code and see if I can't get it to do what I want it to do.

Thanks for the helping me.

cadman6735

  • Guest
Re: Would like to ask some question about my code
« Reply #3 on: February 01, 2011, 09:57:28 AM »
t.willey

I was wrong, not much work ahead of me at all...  It worked great switching the vlax-for to foreach.  Took me about 2 hours to figure out that I do not have to change the ename to an object tho... :oops:


Anyway, learned a concept off of this one, thanks


Got another question:

Would LayerBin be considered a selection set?  Even though it is a list, it holds Layer names and I did not create it thru the conventional manner using selection set functions?

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Would like to ask some question about my code
« Reply #4 on: February 01, 2011, 11:13:11 AM »
A selection set is a very specific variable type.  It is only achieved with ' ss ' something calls.  Ie ' ssget ' or ' ssadd '.  You are creating a list in your code, so that is what makes the ' LayerBin ' variable a list type.  If you want to see what type of variable you have, you can just print it to the command line in the middle of your code like:

(print (type LayerBin))

Hope that helps, and you're welcome.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

cadman6735

  • Guest
Re: Would like to ask some question about my code
« Reply #5 on: February 01, 2011, 11:36:41 AM »
As a selection set is a collection of elements, specified by the ss functions


my list, LayerBin, is a collection of layer names used to restore my layers after being worked on.

Though they are not the same thing in variable type, they are both a collection of something, either elements from a sset
or
Names from a layer table in list form.

Sorry for wording out my thoughts, just trying to grab a concept.