jmerch Posted January 5, 2011 Share Posted January 5, 2011 Trying to get the following snippet of code to work. If I do each line singly it works but when it's in my LISP as the following, it does not set the DIMLFAC. Any reason why? I had some guidance on the defun round function but the rest of the code I can't get to work. (defun round (value to) (setq to (abs to)) (* to (fix (/ ((if (minusp value) - +) value (* to 0.5)) to))) ) (setq dimlfac (getvar "dimlfac")) (setq value (vla-get-customscale(vla-get-activepviewport(vla-get-activedocument(vlax-get-acad-object))))) (setq vpscale (/ 1 value)) (setvar "dimlfac" vpscale) (dimvalue) (command "pspace") (command "_dimlinear" pause pause pause) (command "dimcontinue") (setvar "dimlfac" dimlfac) Quote Link to comment Share on other sites More sharing options...
pBe Posted January 5, 2011 Share Posted January 5, 2011 (setq dimlfac (getvar "dimlfac")) (setq value (vla-get-customscale(vla-get-activepviewport(vla-get-activedocument(vlax-get-acad-object))))) (setq vpscale (/ 1 value)) (setvar "dimlfac" vpscale) (dimvalue) (command "pspace") (command "_dimlinear" pause pause pause) (command "dimcontinue")\ [color=blue](while (> (getvar 'cmdactive) 0)[/color] [color=blue](command pause))[/color] (setvar "dimlfac" dimlfac) And as much as possible, avoid using variable names the same as a function/system/native symbol names Quote Link to comment Share on other sites More sharing options...
Michaels Posted January 5, 2011 Share Posted January 5, 2011 I guess that the problem were with the extra parens . (* to (fix (/ (if (minusp value) - +) value (* to 0.5)) to)) Regards Quote Link to comment Share on other sites More sharing options...
jmerch Posted January 5, 2011 Author Share Posted January 5, 2011 @pBe: the added code still didn't work and doesn't set the dimlfac. I am curious though on the "while" function. My original question in this thread was going to be about "while" b/c I had it in there but didn't understand it fully. I can't find any tutorials on the while/cmdactive and would like to understand how it works. @Michaels: I took out the extra parens but it still didn't seem to work either. I do appreciate your help. Quote Link to comment Share on other sites More sharing options...
pBe Posted January 5, 2011 Share Posted January 5, 2011 thats odd, it works fine with mine what is the sub (dimvalue) do anyway? Quote Link to comment Share on other sites More sharing options...
jmerch Posted January 5, 2011 Author Share Posted January 5, 2011 (dimvalue) was my bad . I tried taking the first couple lines out of that function and put into a separate one to be called up in my main one to see if that worked. I forgot to erase it when I scrapped that idea and posted my code. So I deleted that. I restarted my computer just to clear it up and see if the lisp worked now. It does work now, BUT it's still not setting the DIMLFAC. If i exclude the last line to reset the DIMLFAC, then run the script, the DIMLFAC should be 96 (based on my 1/8" viewport). It's not, it still reads 1 BUT the dimensions come out right...how is that? The dims come out as if the DIMLFAC is actually 96. And as much as possible, avoid using variable names the same as a function/system/native symbol names and to touch on this, I do try to avoid using those names but I'm not 100% familiar with ALL the names so sometimes here and there I may accidentally use one I shouldn't. I think from here on out I may just add a digit after the name to be sure it's not a system name. Quote Link to comment Share on other sites More sharing options...
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.