Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: move after insert problem

  1. #1
    Member
    Join Date
    2008-07
    Posts
    26
    Login to Give a bone
    0

    Question move after insert problem

    Hi,

    I have this piece of code in my routine which inserts a block from another dwg into the one I run the LISP from.

    The code works in the sense that it does insert the block and moves it, but it is not moving it the displacement I am giving in the code always. Sometimes it inserts and moves the first block right but then the second is moved a constant displacement.

    Sometimes it inserts both at the same constant displacement....

    Does anybody know what is wrong with the code...or if it's the code or how to solve this?

    (command "_insert" pipe_dir_top_last pti "1" "1" "0")
    (if (/= top_last_verif+1 nil) (command "move" "l" "" "d" "0,0,250"))
    (if (/= top_last_verif+2 nil) (command "move" "l" "" "d" "0,0,500"))
    (if (/= top_last_verif-1 nil) (command "move" "l" "" "d" "0,0,-250"))
    (if (/= top_last_verif-2 nil) (command "move" "l" "" "d" "0,0,-500"))
    (command "_insert" pipe_dir_top pti "1" "1" "0")
    (if (/= top_verif+1 nil) (command "move" "l" "" "d" "0,0,250"))
    (if (/= top_verif+2 nil) (command "move" "l" "" "d" "0,0,500"))
    (if (/= top_verif-1 nil) (command "move" "l" "" "d" "0,0,-250"))
    (if (/= top_verif-2 nil) (command "move" "l" "" "d" "0,0,-500"))

    thanks!,
    dario

  2. #2
    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: move after insert problem

    You've made the common mistake of not considering running OSnaps. Use the None OSnap override every time you are providing a point in a (command) function.

    (I also cleaned up the nonsensical if test (not equal to nil is the same as the variable has data) and wrapped it into a (cond) statement.)

    Example:
    Code:
    (command "_insert" pipe_dir_top_last "_non" pti "1" "1" "0")
    (command "move" "l" "" "d" "_non")
    (cond 
     (top_last_verif+1 (command "0,0,250"))
     (top_last_verif+2 (command "0,0,500"))
     (top_last_verif-1 (command "0,0,-250"))
     (T (command "0,0,-500")))
    (command "_insert" pipe_dir_top "_non" pti "1" "1" "0")
    (command "move" "l" "" "d" "_non")
    (cond
     (top_verif+1 (command "0,0,250"))
     (top_verif+2 (command "0,0,500"))
     (top_verif-1 (command "0,0,-250"))
     (T (command "0,0,-500")))
    Last edited by RobertB; 2008-08-21 at 12:30 AM.
    R. Robert Bell
    Design Technology Manager
    Stantec
    Opinions expressed are mine alone and do not reflect the views of Stantec.

  3. #3
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: move after insert problem

    Or change OSMODE to 0 after saving the old value to a variable, then set it back once you're done, e.g.
    Code:
    (setq OldSnap (getvar "OSMODE"))
    ;; Continue your code here
    (setvar "OSMODE" OldSnap)

  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: move after insert problem

    Quote Originally Posted by irneb View Post
    Or change OSMODE to 0 after saving the old value to a variable, then set it back once you're done...
    Except that if you are also allowing the user to pick points somewhere in that process, you hosed the user's favorite running OSnaps. Which would lead to unhappy users. I know I would be unhappy.
    R. Robert Bell
    Design Technology Manager
    Stantec
    Opinions expressed are mine alone and do not reflect the views of Stantec.

  5. #5
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: move after insert problem

    Quote Originally Posted by RobertB View Post
    Except that if you are also allowing the user to pick points somewhere in that process, you hosed the user's favorite running OSnaps. Which would lead to unhappy users. I know I would be unhappy.
    Yes you're perfectly correct. My suggestion's what you do when you're a lazy programmer ... like me. Yours is definitely a better solution!

  6. #6
    Member
    Join Date
    2008-07
    Posts
    26
    Login to Give a bone
    0

    Default Re: move after insert problem

    Thanks much Robert,

    I got this routine at work and I am modifying it without previous experience with LISP. I hadn't even figured out how conditional loops worked in LISP (I've work with "IF/ELSE")

    I used your code. Had to modify it a little because the way I had it, the "T" (or "ELSE") was just passing the "IF"s I had.

    Now it seems that is working in a more controlled way but it is moving the blocks (although some constantly (2000,2000,0) ) in X & Y coord. and the code is moving them in Z coord.??

    Because of the way the routine is, it inserts some blocks more than once and it is moving them different displacements..??

    If you have any idea why this could be, I'll appreciate it. Meanwhile, I'll be hitting myself with it...

    The code looks like this now:

    (command "_insert" pipe_dir_top_last "_non" pti "1" "1" "0")
    (command "move" "l" "" "d" "_non")
    (cond
    (top_last_verif_0 (command "0,0,0"))
    (top_last_verif+1 (command "0,0,250"))
    (top_last_verif+2 (command "0,0,500"))
    (top_last_verif-1 (command "0,0,-250"))
    (T (command "0,0,-500")))
    (command "_insert" pipe_dir_top "_non" pti "1" "1" "0")
    (command "move" "l" "" "d" "_non")
    (cond
    (top_verif_0 (command "0,0,0"))
    (top_verif+1 (command "0,0,250"))
    (top_verif+2 (command "0,0,500"))
    (top_verif-1 (command "0,0,-250"))
    (T (command "0,0,-500")))

  7. #7
    Member
    Join Date
    2008-07
    Posts
    26
    Login to Give a bone
    0

    Default Re: move after insert problem

    and thanks irneb, I'd have done that like that too.. I didn't know you could do it the way Robert did.

    and yes, I'd be unhappy with the osnaps had i done it that way

  8. #8
    Member
    Join Date
    2008-07
    Posts
    26
    Login to Give a bone
    0

    Default Re: move after insert problem

    and I just figured out that it is only when it reads the move (0,0,0) that it goes crazy.

    it seems that it is only having problems when the conditional is true for "top_verify_0" or "top_last_verify_0"...

  9. #9
    Member
    Join Date
    2008-07
    Posts
    26
    Login to Give a bone
    0

    Default Re: move after insert problem

    Thanks all!!

    got it working now!

  10. #10
    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: move after insert problem

    Quote Originally Posted by dgomez.189897 View Post
    and I just figured out that it is only when it reads the move (0,0,0) that it goes crazy.

    it seems that it is only having problems when the conditional is true for "top_verify_0" or "top_last_verify_0"...
    Well, in all actuality, even having that condition is useless. Why even bother with the move if you are displacing by 0,0,0?
    Code:
    (command "_insert" pipe_dir_top_last "_non" pti "1" "1" "0")
    (cond 
     (top_last_verif_) ; if set, do not move
     (T
      (command "move" "l" "" "d" "_non")
      (cond   
       (top_last_verif+1 (command "0,0,250"))
       (top_last_verif+2 (command "0,0,500"))
       (top_last_verif-1 (command "0,0,-250"))
       (T (command "0,0,-500")))))
    (command "_insert" pipe_dir_top "_non" pti "1" "1" "0")
    (cond 
     (top_verif_0) ; if set, do not move
     (T
      (command "move" "l" "" "d" "_non")
      (cond
       (top_verif+1 (command "0,0,250"))
       (top_verif+2 (command "0,0,500"))
       (top_verif-1 (command "0,0,-250"))
       (T (command "0,0,-500")))))
    R. Robert Bell
    Design Technology Manager
    Stantec
    Opinions expressed are mine alone and do not reflect the views of Stantec.

Page 1 of 2 12 LastLast

Similar Threads

  1. 2004: problem with move command
    By Mr Ron in forum AutoCAD General
    Replies: 4
    Last Post: 2011-12-28, 11:04 PM
  2. LISP: move dopo di insert
    By dgomez.189897 in forum AutoCAD General
    Replies: 1
    Last Post: 2009-03-14, 08:38 PM
  3. LISP: problema come move despues de insert
    By dgomez.189897 in forum AutoCAD General
    Replies: 3
    Last Post: 2008-08-28, 04:52 PM
  4. Insert problem
    By jmctamney in forum AutoLISP
    Replies: 3
    Last Post: 2007-12-28, 06:22 PM
  5. Replies: 11
    Last Post: 2006-11-10, 10:03 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
  •