+ Reply to Thread
Results 1 to 6 of 6

Thread: DIMLFAC routine

  1. #1
    Senior Member jmerch's Avatar
    Using
    MEP 2010
    Join Date
    Sep 2010
    Posts
    182

    Default DIMLFAC routine

    Registered forum members do not see this ad.

    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.

    Code:
    (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)

  2. #2
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,640

    Default

    Code:
     
    (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")\
    (while (> (getvar 'cmdactive) 0)
    (command pause))
      (setvar "dimlfac" dimlfac)

    And as much as possible, avoid using variable names the same as a function/system/native symbol names

  3. #3
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Jul 2010
    Posts
    356

    Default

    I guess that the problem were with the extra parens .
    Code:
     (* to (fix (/ 
             (if (minusp value) - +)
              value
              (* to 0.5)) to))
    Regards

  4. #4
    Senior Member jmerch's Avatar
    Using
    MEP 2010
    Join Date
    Sep 2010
    Posts
    182

    Default

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

  5. #5
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,640

    Default

    thats odd, it works fine with mine

    what is the sub (dimvalue) do anyway?

  6. #6
    Senior Member jmerch's Avatar
    Using
    MEP 2010
    Join Date
    Sep 2010
    Posts
    182

    Default

    Registered forum members do not see this ad.

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

Similar Threads

  1. DIMLFAC Message Alert Box Creation
    By balajibth84 in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 23rd Oct 2010, 05:34 pm
  2. dwg to xls routine?
    By edgar_hj1 in forum AutoLISP, Visual LISP & DCL
    Replies: 27
    Last Post: 21st Oct 2010, 03:28 pm
  3. Help with this routine
    By jcap91163 in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 5th Aug 2010, 01:28 pm
  4. Just another routine, pls take a look
    By pryzmm in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 30th Jul 2007, 04:04 pm
  5. DIMLFAC?
    By besolid in forum AutoCAD Beginners' Area
    Replies: 1
    Last Post: 6th Mar 2006, 11:31 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts