Code Red > AutoLISP (Vanilla / Visual)

lisp help

(1/2) > >>

pryzmm:
hi everyone  :lol:,

;; can somebody give me some help with this simple lisp i did,,,
;; im not so good at it as im new to it, but im very willing to learn.
;; here it is.

;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; this routine will purge, image detach, zoom & start plot;
;
(prompt "\n use command:pizp")
(defun c:pizp ()
(setvar "cmdecho" 0)
   (command ".-layer" "s" "0" "" "")
   (command "tilemode" "0")
   (command "pspace")
   (command "zoom" "all")
   (command "-image" "d" "*" ) ;; can anyone show me how to fixed this line as when the drawing has no image it return with error, can this line check the drawing for any image/s and if "found" detach them, if "none" exit image command and proceed with the next task.
   (command "-purge" "all" "" "n")
   (prompt "\nPurging #1")(terpri)
   (command "-purge" "all" "" "n")
   (prompt "\nPurging #2")(terpri)
   (prompt "...done")(terpri) ;; is there a string to ensure that all the above run and finish completely before invoking the "plot" command, as right now when i type in "pizp" it go straight to plot, dunno if the above is already completed.  :-o

(command "plot");; i need this to show me the standard plot configuration table and not the command line plot.
(princ))

;;;;;;;;;;;;;;;;;;;;;;;;

thank you in advance  :-),

excuse my grammar  :|

Guest:
First off....welcome to The Swamp.

Here's a quick and dirty way to determine if there are images.


--- Code: ---(defun c:pizp ( / ss)
   (setvar "filedia" 1) [color=green]; Ensure that dialog boxes will be displayed instead of using the command line[/color]
   (setvar "cmdecho" 0)
   (command ".-layer" "s" "0" "" "")
   (command "tilemode" "0")
   (command "pspace")
   (command "zoom" "all")

[color=green];;;========================================================================
; Search drawing for images...[/color]
   [color=red](if (setq ss (ssget "X" '((0 . "IMAGE"))))[/color]
[color=green]      ; If there are images, detach them[/color]
      [color=red](command "-image" "d" "*" )[/color]
      [color=green]; If there aren't any images, just spit out a prompt that there aren't any images[/color]
      [color=red](princ "\n There are NO images here...")[/color]
   [color=red])[/color]
[color=green];;;========================================================================[/color]

   (command "-purge" "all" "" "n")
   (prompt "\nPurging #1")
   (command "-purge" "all" "" "n")
   (prompt "\nPurging #2")
   (prompt "...done")
   (command "plot")
   (princ)
)
--- End code ---

ronjonp:
Matt,

You're going to need a progn for that to work or switch the prompts around.


--- Code: ---   (if (setq ss (ssget "X" '((0 . "IMAGE"))))
      (command "-image" "d" "*" );;image found detach
      (princ "\n There are no images here...");;no image prompt
   )

or

(if (setq ss (ssget "X" '((0 . "IMAGE"))))
  ;;found and detached
  (progn (princ "\n There are images here...")
(command "-image" "d" "*")
  )
  ;;not found
  (princ "\n There are no images here...")
)
--- End code ---

Guest:

--- Quote from: ronjonp on April 01, 2008, 12:01:02 PM ---Matt,

You're going to need a progn for that to work or switch the prompts around.
--- End quote ---


Yeah... yeah... yeah...

I screwed it up.... Trying to do too much at once, I guess.   :|


--- Code: ---[color=green];;;========================================================================
; Search drawing for images...[/color]
   [color=red](if (setq ss (ssget "X" '((0 . "IMAGE"))))[/color]
[color=green]      ; If there are images, detach them[/color]
      [color=red](command "-image" "d" "*" )[/color]
      [color=green]; If there aren't any images, just spit out a prompt that there aren't any images[/color]
      [color=red](princ "\n There are NO images here...")[/color]
   [color=red])[/color]
[color=green];;;========================================================================[/color]
--- End code ---

alanjt:
this should help, it will only execute plot if the other commands are successful and you had too many "" for you set to layer 0 (i also added for it to thaw 0 layer just in case)


--- Code: ---(defun c:pizp ( / ss)
(if
(progn
   (setvar "filedia" 1) ; Ensure that dialog boxes will be displayed instead of using the command line
   (setvar "cmdecho" 0)
   (command "-layer" "t" "0" "s" "0" "")
   (command "tilemode" "0")
   (command "pspace")
   (command "zoom" "all")

;;;========================================================================
; Search drawing for images...
   (if (setq ss (ssget "X" '((0 . "IMAGE"))))
      ; If there are images, detach them
      (command "-image" "d" "*" )
      ; If there aren't any images, just spit out a prompt that there aren't any images
      (princ "\n There are NO images here...")
   )
;;;========================================================================

   (command "-purge" "all" "" "n")
   (prompt "\nPurging #1")
   (command "-purge" "all" "" "n")
   (prompt "\nPurging #2")
   (prompt "...done")
);progn
   (command "plot")
);if
   (princ)
)
--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version