Jump to content

DIMLFAC routine


jmerch

Recommended Posts

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)

Link to comment
Share on other sites

 
(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

Link to comment
Share on other sites

@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.

Link to comment
Share on other sites

(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.
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...