Jump to content

multiple commands in one function


Recommended Posts

Posted

Hello everyone. I would like to have multiple commands within one function. I am having a hard time figuring it out. Here is the code I am working on.

(defun c:UIRN ()
       (command "ucsicon" "on" " " "or")
   (princ)
)

other things I have tried

       (command "ucsicon" "on" "" "or")
)

       (command "ucsicon" "on" "ucsicon" "or")
)

       (command "ucsicon" "on" command "ucsicon" "or")
)

Posted

Is this what you are trying to achieve?

(defun c:uirn ()
   (setvar "cmdecho" 0)
   (command "_ucsicon" "ON")
   (setvar "cmdecho" 1)
   (princ)
)

or are you trying to create a toggle between something?

 

If its a toggle you are after, maybe something like this:

 

(defun c:uirn2 ()
   (cond
       ((= (getvar "ucsicon") 3)
        (setvar "ucsicon" 2))
       ((= (getvar "ucsicon") 2)
        (setvar "ucsicon" 3))
   ) ; end cond
   (princ)
) ; end function

Please clarify Noel :geek:

Posted

Maybe as simple as this

(defun c:uirn ()
(setvar "ucsicon" 3)
(princ)
)

Posted

I am trying to create a lisp that turns the ucsicon on ("ucsicon" "on")and also puts the ucsicon to origin ("ucsicon" "or"). Sorry for the confusion. Thanks!

Posted

From Sysvdlg (Express tools System Variable Editor)

Displays the UCS icon for the current viewport using bitcode. UCSICON is both a command and a system variable. It is the sum of the following:

 

0 No icon displayed

1 On; icon is displayed

2 Origin; if icon is displayed, the icon floats to the UCS origin if possible

3 On and displayed at origin.

Posted

Using the information kindly provided by lpseifert, you could create a LISP as follows:

 

(defun c:uirn ()
   (setvar "ucsicon" 3)
   (princ)
)

Or if you desire a toggle between ON (ORIGIN) and OFF:

 

(defun c:uirn2 ()
   (cond
       ((= (getvar "ucsicon") 3)
        (setvar "ucsicon" 0))
       ((= (getvar "ucsicon") 0)
        (setvar "ucsicon" 3))
   ) ; end cond
   (princ)
) ; end function

Hope this helps :)

 

FYI.

If you prefer to use the "command" syntax in the LISP instead of changing the system variables:

 

(defun c:uirn3 ()
   (setvar "cmdecho" 0)
   (command "_ucsicon" "ON")
   (command "_ucsicon" "OR")
   (setvar "cmdecho" 1)
   (princ "\nUCS Icon Set to Origin.")
   (princ)
)

Posted

Got it working now thanks to all of your input. Thanks so much for your help and enjoy your day. Here is the code that I am using

 

; UIN sets the ucs icon to on
(defun c:UIN ()
       (command "ucsicon" "on")
   (princ) ; exit cleanly
) ; end program
; UIR sets the ucs icon to origin
(defun c:UIR ()
       (command "ucsicon" "or")
   (princ) ; exit cleanly
) ; end program

; UIRN sets the ucs icon to on and to origin
(defun c:uirn ()
(setvar "ucsicon" 3)
(princ)
)
; UCSA sets the ucs icon to on and to origin and sets UCS to world
(defun c:ucsa ()
   (setvar "cmdecho" 0)
   (command "_ucsicon" "ON")
   (command "_ucsicon" "OR")
(command "ucs" "world")
   (princ)
)

Posted

Make sure you include

 

(setvar "cmdecho" 1)

 

In your ucsa code - otherwise you won't be prompted when running standard ACAD commands :P

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...