PDA

View Full Version : Passing selection sets as arguments


mcoonrod
2005-10-21, 06:50 PM
Is it possible?
I have been trying to pass the name of a selection set as a argument ie...

(addblock "BLOCKNAME" "MYBLOCK1")
(defun addblock (blkname selset)
(setq tempss (ssget "X" (list (cons 2 blkname))))
(setq num 0)
(if (= tempss nil)
(progn
(princ)
)
(progn
(setq ssle (sslength tempss))
(repeat ssle
(setq ent1 (ssname tempss num))
(ssadd ent1 selset)
;;;;;;CRASHES HERE
(setq num (+ num 1))
)
)
)
)[ Moderator Action = ON ] What are [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code) [ Moderator Action = OFF ]

It crashes when I go to add a block to it.
Any help would be appreciated because I am new to this.

Opie
2005-10-21, 07:00 PM
Names of selection set are just variable names in Lisp. If Myblock1 is supposed to be a selection set, then remove the quotes from around it within your addblock call.
(addblock "BLOCKNAME" myblock1)
I am assuming BLOCKNAME is the name of your block and the MYBLOCK1 is the variable that contains a selection set.

mcoonrod
2005-10-21, 07:13 PM
Thanks for the quick reply. I tried what you said and it came back with a error when trying to add the block to the selection set. It appears that after I call the function, selset = nil. Before selset = "MYBLOCK1" but I don't think it is passing a reference to the selection set.

T.Willey
2005-10-21, 07:23 PM
Yes, but you have to pass the selection set variable. In the main code do something like
(setq BlkSS (ssadd))
Then you can do.
(addblock "BLOCKNAME" BlkSS)

Tim

mcoonrod
2005-10-21, 07:51 PM
That's it!
Thanks all