Author Topic: (cond issue  (Read 1336 times)

0 Members and 1 Guest are viewing this topic.

au-s

  • Guest
(cond issue
« on: February 11, 2009, 11:16:39 AM »
Hello ...

I have a lisp that inserts blocks.
Can I make this lisp so it only works in certain path..
if the user browses to another path ... it alerts.

You need DOSLib for it.
And take a look only on the test part.
What I want here is that the lisp will only work when inserting blocks from that path.
If I browse to anoher, it alerts me.

Here it is:

Code: [Select]
(defun describe ()
;;;Do the mapcar function for each layer in the drawing.
  (vlax-for layer
        (vla-get-layers
          (vla-get-activedocument
        (vlax-get-acad-object)
        )
          )
;;;if the current layer being checked matches a predetermined name, add the needed description.
    (mapcar
      (function
    (lambda (layname description)
      (if (= (strcase (vla-get-name layer)) (strcase layname))
        (vla-put-description layer description)
        ()
        )
      )
    )
      '("A-------O2-" ) ; This is your list of layers needing a description.
      '("arrow"); This is the descriptions for each layer.  Make sure the order is EXACTLY the same as in the layer list.
      )
    )
  (princ); Silent exit.
  )
 
    (defun layercreation ()
 
        (if  (tblsearch "LAYER" "A-------O2-")
(command "_layer" "s" "A-------O2-" "")
            (command "-layer" "M" "A-------O2-" "C" "red" "A-------O2-" "")
 
            ) ; end if
 
           );en defun
 
 
(defun c:test ( / sl oldlay)
(setq path (strcat "K:\\CAD\\Block\\arrow"))
(cond
  ((path)
   (
 
  (setq oldlay (getvar "clayer"))
  (setq sl nil)
 
 
  (setq sl (dos_dwgpreview "Välj Block" "K:\\CAD\\Block\\arrow"))
  (prompt "\nChoose insertion point...")
  (if sl
    (progn
      (layercreation)
      (describe)
      (setvar "clayer" "A-------O2-")
      (command "-insert" sl pause "1" "1" "0")
    (setvar "clayer" oldlay)
 
 
);progn
 
    );if
  ))(t (alert "It only works in arrow path")))
 
 
  )

T.Willey

  • Needs a day job
  • Posts: 5251
Re: (cond issue
« Reply #1 on: February 11, 2009, 01:01:58 PM »
Before the insert, just check to see if the path equals the path you want, and if not then prompt them to select again, and maybe have an alert box stating the fact that the block came from the wrong location.

One way you can do it, is use a while loop in conjunction with ' wcmatch '.  While wcmatch returns nil, then loop to select the block.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.