Results 1 to 2 of 2

Thread: Lisp help - cond and progn statement

  1. #1
    Join Date
    Jan 2011
    Posts
    3

    Lisp help - cond and progn statement

    Can someone please look at this and help me do a condition ?

    Basically, I want the program to decide if it's border1(zi3042sht) OR border #2 (i3042sht) and perform actions depending on which border it find. Thank you, thank you, thank you!

    [code](if (setq ss (ssget "x" (list (cons 0 "INSERT") (cons 2 "zi3042sht"))))
    (PROGN
    (vla-put-Name
    (vla-item
    (vla-get-Blocks
    (vla-get-ActiveDocument
    (vlax-get-acad-object)
    )
    )
    "zi3042sht") ;;;<-- old block name
    "abcde") ;;;< -- new block name
    )
    (if (setq B3Set (ssget "x" '((0 . "INSERT")(2 . "abcde"))))
    (progn
    (setq ename1 (ssname B3Set 0))
    (setq InsPt (cdr (assoc 10 (entget ename1))))
    (command "._move" "all" "" InsPt '(0.0 0.0))
    ; (command "._move" "all" "" "0,0" "@2.06155<194")
    )
    )
    )
    (PROGN
    (if (setq ss (ssget "x" (list (cons 0 "INSERT") (cons 2 "i3042sht"))))
    (vla-put-Name
    (vla-item
    (vla-get-Blocks
    (vla-get-ActiveDocument
    (vlax-get-acad-object)
    )
    )
    "i3042sht") ;;;<-- old block name
    "abcde") ;;;< -- new block name
    )
    (if (setq B3Set (ssget "x" '((0 . "INSERT")(2 . "abcde"))))
    (progn
    (setq ename1 (ssname B3Set 0))
    (setq InsPt (cdr (assoc 10 (entget ename1))))
    (command "._move" "all" "" InsPt '(0.0 0.0))
    (command "._move" "all" "" "0,0" "@2.06155<194")
    )
    )
    )
    );end of IF
    [\code}

  2. #2
    Join Date
    Mar 2011
    Location
    Joburg SA
    Posts
    1
    It "should" work.
    Code:
    (vl-load-com)
    (if (setq ss (ssget "x" (list (cons 0 "INSERT") (cons 2 "zi3042sht"))))
      ;; This is the then portion
      (vla-put-Name
        (vla-item
          (vla-get-Blocks
            (vla-get-ActiveDocument
              (vlax-get-acad-object)
            )
          )
          "zi3042sht" ;<-- old block name
        )
        "abcde" ;< -- new block name
      )
      ;; This is the Else portion
      (if (setq ss (ssget "x" (list (cons 0 "INSERT") (cons 2 "i3042sht"))))
        (vla-put-Name
          (vla-item
            (vla-get-Blocks
              (vla-get-ActiveDocument
                (vlax-get-acad-object)
              )
            )
            "i3042sht"
          )
          "abcde"
        )
      )
    
    )
    
    ;; No need to do the selection again, just check if it has found any objects
    ;; (either of the 2 blocks) - since in both cases the same actions are performed
    (if ss
      (progn
        (setq ename1 (ssname ss 0))
        (setq InsPt (cdr (assoc 10 (entget ename1))))
        (command "._move" "all" "" InsPt '(0.0 0.0))
      )
    )

Similar Threads

  1. Doesn't RC support this statement?
    By ppc in forum Cadence
    Replies: 0
    Last Post: 04-08-2005, 02:45 PM
  2. COND Issue?
    By crrussell3 in forum Customization
    Replies: 1
    Last Post: 04-01-2005, 02:02 AM
  3. if/Cond angle
    By jvellek in forum Customization
    Replies: 36
    Last Post: 03-30-2005, 02:11 PM
  4. assign statement in netlist
    By rajan in forum Cadence
    Replies: 4
    Last Post: 09-01-2004, 08:13 AM
  5. Statement of 2004
    By CAD in forum MicroStation
    Replies: 1
    Last Post: 06-18-2004, 03:34 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
  •  
Other forums: Access Forum - Microsoft Office Forum - Exchange Server Forum