Results 1 to 6 of 6

Thread: Using Mline in a lisp routine

  1. #1
    Member
    Join Date
    2003-08
    Posts
    46
    Login to Give a bone
    0

    Default Using Mline in a lisp routine

    I need to see if anyone knows how to use Mline in a Lisp routine. I can do the following:

    (command "mline" "st" "casing" pause pause pause "")

    This allows the user to make an mline two segments long and no more, then continues the code for labeling, etc. Is there anyway to force the mline command to continue until the user decides he has enough segments and then continue the code?

    Any help would be appreciated.

    Thanks,
    Joe Watkins

  2. #2
    I could stop if I wanted to scwegner's Avatar
    Join Date
    2004-12
    Location
    Minneapolis, MN
    Posts
    449
    Login to Give a bone
    0

    Default Re: Using Mline in a lisp routine

    Quote Originally Posted by jawf
    Is there anyway to force the mline command to continue until the user decides he has enough segments and then continue the code?
    There sure is.

    Code:
        (command "mline" "st" "casing")
        (while 
          (= (logand (getvar "cmdactive") 1) 1)
          (command pause)
        );while
    Or:
    Code:
         (command "mline" "st" "casing")
         (while 
           (> (getvar "cmdactive") 0)
           (command pause)
         );while
    Last edited by scwegner; 2005-07-13 at 01:50 PM.

  3. #3
    Member
    Join Date
    2003-08
    Posts
    46
    Login to Give a bone
    0

    Default Re: Using Mline in a lisp routine

    Thanks. That works perfectly. I don't understand the LOGAND, though. I looked at the info I had on it and it didn't make sense to me. Any idea where I can get a better understanding of that type of function?

    Thanks, Joe

  4. #4
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: Using Mline in a lisp routine

    Logand works with bits (binary). It takes multiple arguments and returns a number that indicates the common bits in all the arguments. (Clear as mud, no?)

    Example: 3=11 in binary, and 2=10 in binary. Are there any common bits? Yes, the bit in the 2nd "slot" (both are turned on, or set to 1). The least significant bit is not the same between the two (one is on, one is off).

    11 AND 10 = 10
    or
    (logand 3 2) = 2
    or
    11 AND
    10
    10

    More complex:
    111
    001
    001
    or
    (logand 7 1) = 1

    In the CmdActive system variable, unless you need to know if the command is active due to a script or other automation, simply testing for greater than 0 is enough, e.g. (> (getvar "CmdActive") 0)
    Logand is useful there when you need to know if a script is running, i.e. is bit 2 (which equals 4) set.
    (= (logand (getvar "CmdActive") 4) 4) or "Does the AND of CmdActive and 4 equal 4?"

  5. #5
    I could stop if I wanted to scwegner's Avatar
    Join Date
    2004-12
    Location
    Minneapolis, MN
    Posts
    449
    Login to Give a bone
    0

    Default Re: Using Mline in a lisp routine

    Logand compares a bit (as in binary 1 or 0) or bitset (as string of 1s and 0s) with a bitset to see if the bit is in the bitset. So, in this case, it looks at the number it receives from (getvar "cmdactive") and sees whether or not there is a 1 in it or if it's just a string of 0s. If it finds what it's looking for, it returns that (in this case a 1), otherwise it returns 0.

    If that made no sense, this might be a better explanation:

    http://discussion.autodesk.com/threa...sageID=2006356

  6. #6
    Member
    Join Date
    2003-08
    Posts
    46
    Login to Give a bone
    0

    Default Re: Using Mline in a lisp routine

    OK. It has been a while since binary made sense. It does make some sense again. Thanks for all your patience.

    Joe

Similar Threads

  1. Editing MLINE with lisp
    By cadconcepts in forum AutoLISP
    Replies: 0
    Last Post: 2013-02-05, 09:22 PM
  2. Help with a lisp routine to add a 12" line to this routine
    By Orbytal.edge341183 in forum AutoLISP
    Replies: 3
    Last Post: 2012-11-14, 10:33 PM
  3. Combine three lisp routine into one routine.
    By BrianTFC in forum AutoLISP
    Replies: 1
    Last Post: 2012-02-08, 12:14 PM
  4. Replies: 9
    Last Post: 2012-01-21, 07:58 AM
  5. Using MLine in lisp
    By ReachAndre in forum AutoLISP
    Replies: 8
    Last Post: 2007-04-11, 02:07 PM

Posting Permissions

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