Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Cond works in one drawing, but not another.

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
kpennell
211 Views, 4 Replies

Cond works in one drawing, but not another.

I am baffled.

 

When I copy and paste the following code in one drawing, everything gets defined correctly.  When I do it to another drawing, I get "nil" retruned.

 

(cond
((= UnitScale 0.09375) (setq mview1 (list -3.0 1.0 0.0)) (setq mview2 (list -1.0 3.0 0.0)) (setq mview3 (list -2.0 0.85 0.0)))
((= UnitScale 2.5)  (setq mview1 (list -75.0 25.0 0.0)) (setq mview2 (list -25.0 75.0 0.0)) (setq mview3 (list -50.0 20.0 0.0)))
)

 

Whiskey Tango Foxtrot

 

I hope someone is able to help.

4 REPLIES 4
Message 2 of 5
kpennell
in reply to: kpennell

I have confirmed that the variable is being set correctly, but for some reason, in a mmparticular drawing, the list is being built.

Message 3 of 5
Kent1Cooper
in reply to: kpennell

You don't say how the variable is being set, or how you're verifying that it's correct.  If it's the result of some kind of calculation, using some value that's perhaps also the result of some calculation that may be based some number that could be ever-so-slightly different in the one problem drawing, it could be that the apparent 0.09375 is really something like 0.09375000000021 or 0.093749999983, in which case even though it may display correctly however you're checking, the (=) function would return nil.  Try using (equal) with a fuzz factor instead, something like this:

 

(equal UnitScale 0.09375 1e-6)

Kent Cooper, AIA
Message 4 of 5
kpennell
in reply to: Kent1Cooper

The variables are not set previously by a calculation or anything.  They are purposely set using (setq UnitScale 0.09375) directly.

 

I haven't had an issue with it for about ten years.  Now some drawing is causing the issue.

 

Thanks for the response KC.

Message 5 of 5
kpennell
in reply to: kpennell

Oh for FS's.

 

When I set up the project, I set UnitScale to 0.9375 instead of 0.09375.

 

Sorry for your troubles KC.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost