PDA

View Full Version : What's wrong with this code


noozybkk
2005-06-20, 01:16 PM
Like all the problems I have with coding, the answer to this is probably simple and I just cant see it.

All this snippet of code is supposed to do is change the layer to 'Vports' and invoke the mview command then reset the layer to what it was before.

It's falling over somewhere in c:MV function, but for the life of me I can't see where.

I know that the (GLAY) & (RLAY) functions work because I use them elsewhere.


(defun GLAY ()
(setq xcl (getvar "clayer"))
(princ))

(defun RLAY ()
(setvar "clayer" xcl)
(princ))

(defun c:MV ()
(GLAY)
(command "layer" "m" "Vports" "c" 253 "" "" "mview")
(RLAY))

rkmcswain
2005-06-20, 01:34 PM
Try this:


(defun c:mMV ()
(GLAY)
(command "layer" "m" "Vports" "c" "253" "" "")
(command "._mview")
(while (eq 1 (logand 1 (getvar "cmdactive")))
(command pause)
)
(RLAY)
)

Tom Beauford
2005-06-20, 01:51 PM
Try:(defun c:MV ()
(GLAY)
(command "layer" "m" "Vports" "c" 253 "" "" "mview")
(while (= 1 (logand 1 (getvar "cmdactive")))(command PAUSE))
(RLAY))

noozybkk
2005-06-20, 03:12 PM
Same solution, different formatting :D

Thanks guys, works well.

noozybkk
2005-06-20, 05:25 PM
Don't mean to be a pain, but what on earth does the logand function return?

The AutoLISP reference only says that it returns the "logical bitwise AND of a list of integers"

What does that mean? I've tried to work back from the examples that it shows, but I'm stumped.

Tom Beauford
2005-06-20, 05:31 PM
Never cared for the explanation in help either, here's a good one I found online: http://www.gamedev.net/reference/programming/features/bitwise/page2.asp Don't mean to be a pain, but what on earth does the logand function return?

The AutoLISP reference only says that it returns the "logical bitwise AND of a list of integers"

What does that mean? I've tried to work back from the examples that it shows, but I'm stumped.

rkmcswain
2005-06-20, 05:35 PM
Don't mean to be a pain, but what on earth does the logand function return?

See this link (http://groups-beta.google.com/group/autodesk.autocad.customization/msg/a63df65ac2aef822?hl=en)

noozybkk
2005-06-20, 05:54 PM
Excellent! Both very good articles....and Tony Tanzillo is a name I haven't heard for a long time. Used to love the Free Stuff section of his website, but hasn't been updated for a while.

Thanks very much for the links.