How make a transparent command?

How make a transparent command?

Anonymous
Not applicable
949 Views
30 Replies
Message 1 of 31

How make a transparent command?

Anonymous
Not applicable
Does anyone know how I can make the following
function transparent: (osnap (cadr (grread nil 1)) "end,int"); function
provided by Michael Puckett

Below is my attempt, and it does not work.
Can anyone tell me why, or suggest something else?

Thanks, Steve

(vl-load-com)
(defun ada-2 ()
(osnap (cadr (grread nil 1)) "end,int")
)
(vlax-add-cmd "jsa-a" 'ada-2 "jsa-a" 1 )
0 Likes
950 Views
30 Replies
Replies (30)
Message 2 of 31

Anonymous
Not applicable
Don't define it using (vlax-add-command).

Just do this:

(defun C:JSA-A ()
(command (osnap (cadr (grread nil 1)) "QUI,END,INT"))
(princ)
)

Steve Adams wrote:
>
> Does anyone know how I can make the following
> function transparent: (osnap (cadr (grread nil 1)) "end,int"); function
> provided by Michael Puckett
>
> Below is my attempt, and it does not work.
> Can anyone tell me why, or suggest something else?
>
> Thanks, Steve
>
> (vl-load-com)
> (defun ada-2 ()
> (osnap (cadr (grread nil 1)) "end,int")
> )
> (vlax-add-cmd "jsa-a" 'ada-2 "jsa-a" 1 )

--
/*********************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Programming & Customization for AutoCAD & Compatibles */
/* ----------------------------------------------------- */
/* [email protected] */
/* http://www.caddzone.com */
/*********************************************************/
0 Likes
Message 3 of 31

Anonymous
Not applicable
Thanks, Tony. I'm trying to make the kind of
tranparent command that you can call from
the button menu, while a lisp routine is in progress.
I would appreciate any tips you could offer
on this.

Steve
0 Likes
Message 4 of 31

Anonymous
Not applicable
Tony's right, just prefix the function with c: and then call it via 'name,

e.g. line [enter] 'jsa-a [enter] ...

However, the way you defined your function, if no object is under the cursor
for a snap to be realized, the osnap function will return nil. Since that
might not be your intent I had it default to the point where the cursor was
if there is no object to snap to.

(defun c:jsa-a ( / p)
(command
(cond
( (osnap (setq p (cadr (grread nil 1))) "_endp,_int"))
( p )
)
)
(princ)
)

If It was desirable to have the routine return nil just skip my rambling.

__________________________________

Michael Puckett
[email protected]
> Not < an Autodesk hall monitor.
Imagination makes all things possible.
Copyright (c) 2000 Michael Puckett
All Rights Reserved
__________________________________

"Steve Adams" wrote in message
news:[email protected]...
Does anyone know how I can make the following
function transparent: (osnap (cadr (grread nil 1)) "end,int"); function
provided by Michael Puckett

Below is my attempt, and it does not work.
Can anyone tell me why, or suggest something else?

Thanks, Steve

(vl-load-com)
(defun ada-2 ()
(osnap (cadr (grread nil 1)) "end,int")
)
(vlax-add-cmd "jsa-a" 'ada-2 "jsa-a" 1 )
0 Likes
Message 5 of 31

Anonymous
Not applicable
Hmmm ... if you only wanted to return a point if a valid snap was found you
could always ...

(defun c:jsa-a ( / p)
(if (setq p (osnap (cadr (grread nil 1)) "_endp,_int"))
(command p)
)
(princ)
)

Anyway, have fun ... I've other fish to fry.

__________________________________

Michael Puckett
[email protected]
> Not < an Autodesk hall monitor.
Imagination makes all things possible.
Copyright (c) 2000 Michael Puckett
All Rights Reserved
__________________________________

"Michael Puckett" wrote in message
news:[email protected]...
Tony's right, just prefix the function with c: and then call it via 'name,

e.g. line [enter] 'jsa-a [enter] ...

However, the way you defined your function, if no object is under the cursor
for a snap to be realized, the osnap function will return nil. Since that
might not be your intent I had it default to the point where the cursor was
if there is no object to snap to.

(defun c:jsa-a ( / p)
(command
(cond
( (osnap (setq p (cadr (grread nil 1))) "_endp,_int"))
( p )
)
)
(princ)
)

If It was desirable to have the routine return nil just skip my rambling.

__________________________________

Michael Puckett
[email protected]
> Not < an Autodesk hall monitor.
Imagination makes all things possible.
Copyright (c) 2000 Michael Puckett
All Rights Reserved
__________________________________

"Steve Adams" wrote in message
news:[email protected]...
Does anyone know how I can make the following
function transparent: (osnap (cadr (grread nil 1)) "end,int"); function
provided by Michael Puckett

Below is my attempt, and it does not work.
Can anyone tell me why, or suggest something else?

Thanks, Steve

(vl-load-com)
(defun ada-2 ()
(osnap (cadr (grread nil 1)) "end,int")
)
(vlax-add-cmd "jsa-a" 'ada-2 "jsa-a" 1 )
0 Likes
Message 6 of 31

Anonymous
Not applicable
<< Anyway, have fun ... I've other fish to fry. >>>

Wait a minute, Michael. You ain't goin' to no fish fry
'till we we make this function truly transparent (i.e. one that can
be called *during* another lisp command. We don't want to get
the "can't re-enter autolisp" message".)

Just kidding. You can go to the fish fry if you want.

Steve
0 Likes
Message 7 of 31

Anonymous
Not applicable
I should have credited Eric Schneider with that
portion of "grread" code. Sorry Eric.

Steve
0 Likes
Message 8 of 31

Anonymous
Not applicable
Steve,
maybe the best method is to jump up & down
& scream until Autodesk changes the A2K
button/aux menu behaviour to be the same as R14.
i.e the button/aux line
endpt,int \
does what you want in R14, but does not work in A2K
Regards Ian

Steve Adams wrote in message ...
>Thanks, Tony. I'm trying to make the kind of
>tranparent command that you can call from
>the button menu, while a lisp routine is in progress.
>I would appreciate any tips you could offer
>on this.
>
>Steve
>
0 Likes
Message 9 of 31

Anonymous
Not applicable
Ian,

I lost a lot (mainly SoftEngine) when I moved from
R12 to R15. Maybe I went " a release too far"....

Ian Bryant wrote:

> Steve,
> maybe the best method is to jump up & down
> & scream until Autodesk changes the A2K
> button/aux menu behaviour to be the same as R14.
> i.e the button/aux line
> endpt,int \
> does what you want in R14, but does not work in A2K
> Regards Ian
>
> Steve Adams wrote in message ...
> >Thanks, Tony. I'm trying to make the kind of
> >tranparent command that you can call from
> >the button menu, while a lisp routine is in progress.
> >I would appreciate any tips you could offer
> >on this.
> >
> >Steve
> >
0 Likes
Message 10 of 31

Anonymous
Not applicable
Maybe it's the the even number syndrome,
R10 good, R11 a dog, R12 good, R13 a real dog, R14 good
R15 ???
Regards Ian

Steve Adams wrote in message <[email protected]>...
>Ian,
>
> I lost a lot (mainly SoftEngine) when I moved from
>R12 to R15. Maybe I went " a release too far"....
>
>Ian Bryant wrote:
>
>> Steve,
>> maybe the best method is to jump up & down
>> & scream until Autodesk changes the A2K
>> button/aux menu behaviour to be the same as R14.
>> i.e the button/aux line
>> endpt,int \
>> does what you want in R14, but does not work in A2K
>> Regards Ian
>>
>> Steve Adams wrote in message ...
>> >Thanks, Tony. I'm trying to make the kind of
>> >tranparent command that you can call from
>> >the button menu, while a lisp routine is in progress.
>> >I would appreciate any tips you could offer
>> >on this.
>> >
>> >Steve
>> >
>
0 Likes
Message 11 of 31

Anonymous
Not applicable
(if (zerop (rem (atoi (getvar "acadver")) 2)) "good" "blech")

_____________________________________

[email protected]
> Not < an AutoDESK classroom monitor
Imagination makes all things possible
Copyright (c) 2000 Michael Puckett
All Rights Reserved
_____________________________________

Ian Bryant wrote in message ...
Maybe it's the the even number syndrome,
R10 good, R11 a dog, R12 good, R13 a real dog, R14 good
R15 ???
Regards Ian

Steve Adams wrote in message <[email protected]>...
>Ian,
>
> I lost a lot (mainly SoftEngine) when I moved from
>R12 to R15. Maybe I went " a release too far"....
>
>Ian Bryant wrote:
>
>> Steve,
>> maybe the best method is to jump up & down
>> & scream until Autodesk changes the A2K
>> button/aux menu behaviour to be the same as R14.
>> i.e the button/aux line
>> endpt,int \
>> does what you want in R14, but does not work in A2K
>> Regards Ian
>>
>> Steve Adams wrote in message ...
>> >Thanks, Tony. I'm trying to make the kind of
>> >tranparent command that you can call from
>> >the button menu, while a lisp routine is in progress.
>> >I would appreciate any tips you could offer
>> >on this.
>> >
>> >Steve
>> >
>
0 Likes
Message 12 of 31

Anonymous
Not applicable
Or if you're a bit sniffer ...

(if (zerop (logand 1 (atoi (getvar "acadver")))) "good" "blech")

_____________________________________

[email protected]
> Not < an AutoDESK classroom monitor
Imagination makes all things possible
Copyright (c) 2000 Michael Puckett
All Rights Reserved
_____________________________________

Michael Puckett wrote in message ...
(if (zerop (rem (atoi (getvar "acadver")) 2)) "good" "blech")

_____________________________________

[email protected]
> Not < an AutoDESK classroom monitor
Imagination makes all things possible
Copyright (c) 2000 Michael Puckett
All Rights Reserved
_____________________________________

Ian Bryant wrote in message ...
Maybe it's the the even number syndrome,
R10 good, R11 a dog, R12 good, R13 a real dog, R14 good
R15 ???
Regards Ian

Steve Adams wrote in message <[email protected]>...
>Ian,
>
> I lost a lot (mainly SoftEngine) when I moved from
>R12 to R15. Maybe I went " a release too far"....
>
>Ian Bryant wrote:
>
>> Steve,
>> maybe the best method is to jump up & down
>> & scream until Autodesk changes the A2K
>> button/aux menu behaviour to be the same as R14.
>> i.e the button/aux line
>> endpt,int \
>> does what you want in R14, but does not work in A2K
>> Regards Ian
>>
>> Steve Adams wrote in message ...
>> >Thanks, Tony. I'm trying to make the kind of
>> >tranparent command that you can call from
>> >the button menu, while a lisp routine is in progress.
>> >I would appreciate any tips you could offer
>> >on this.
>> >
>> >Steve
>> >
>
0 Likes
Message 13 of 31

Anonymous
Not applicable
Woof woof,
Regards Ian

Michael Puckett wrote in message ...
>Or if you're a bit sniffer ...
>
>(if (zerop (logand 1 (atoi (getvar "acadver")))) "good" "blech")
>
>_____________________________________
>
>[email protected]
>> Not < an AutoDESK classroom monitor
>Imagination makes all things possible
>Copyright (c) 2000 Michael Puckett
>All Rights Reserved
>_____________________________________
>
>Michael Puckett wrote in message ...
>(if (zerop (rem (atoi (getvar "acadver")) 2)) "good" "blech")
>
>_____________________________________
>
>[email protected]
>> Not < an AutoDESK classroom monitor
>Imagination makes all things possible
>Copyright (c) 2000 Michael Puckett
>All Rights Reserved
>_____________________________________
>
>Ian Bryant wrote in message ...
>Maybe it's the the even number syndrome,
>R10 good, R11 a dog, R12 good, R13 a real dog, R14 good
>R15 ???
>Regards Ian
>
>Steve Adams wrote in message <[email protected]>...
>>Ian,
>>
>> I lost a lot (mainly SoftEngine) when I moved from
>>R12 to R15. Maybe I went " a release too far"....
>>
>>Ian Bryant wrote:
>>
>>> Steve,
>>> maybe the best method is to jump up & down
>>> & scream until Autodesk changes the A2K
>>> button/aux menu behaviour to be the same as R14.
>>> i.e the button/aux line
>>> endpt,int \
>>> does what you want in R14, but does not work in A2K
>>> Regards Ian
>>>
>>> Steve Adams wrote in message ...
>>> >Thanks, Tony. I'm trying to make the kind of
>>> >tranparent command that you can call from
>>> >the button menu, while a lisp routine is in progress.
>>> >I would appreciate any tips you could offer
>>> >on this.
>>> >
>>> >Steve
>>> >
>>
>
0 Likes
Message 14 of 31

Anonymous
Not applicable
Hi Steve,

maybe you can use vla-sendCommand here:

(defun ada-2 ( / p activedoc cmd)
(if (setq p (osnap (cadr (grread nil 1)) "_end,_int"))
(progn
(setq activedoc (vla-get-ActiveDocument (vlax-get-acad-object)))
(setq cmd (strcat (rtos (car p) 2 16) ","
(rtos (cadr p) 2 16) ","
(rtos (caddr p) 2 16) "\n"))
(vla-SendCommand activedoc cmd)
)
)
)

Stephan
0 Likes
Message 15 of 31

Anonymous
Not applicable
Thanks, Stephan, but I couldn't get it to work.
Did it work on your end?

-Steve
0 Likes
Message 16 of 31

Anonymous
Not applicable
Hi Steve,

yes, by adding the line
(vlax-add-cmd "jsa-a" 'ada-2 "jsa-a" 1)
it works for me as a transparent command
in AutoCAD 2000 SP 1 & NT 4 SP 6.
Works with AutoCAD commands and with
lisp i.e. (getpoint).
Please can you explain why it
does not work for you.

Stephan
0 Likes
Message 17 of 31

Anonymous
Not applicable
Stephan,

Thanks for reminding me to vlax-add-cmd.

Your program works great. This will save me a hundred
button pushes a day. I really appreciate it.

Thank you,
Steve

Stephan Koster wrote:

> Hi Steve,
>
> yes, by adding the line
> (vlax-add-cmd "jsa-a" 'ada-2 "jsa-a" 1)
> it works for me as a transparent command
> in AutoCAD 2000 SP 1 & NT 4 SP 6.
> Works with AutoCAD commands and with
> lisp i.e. (getpoint).
> Please can you explain why it
> does not work for you.
>
> Stephan
0 Likes
Message 18 of 31

Anonymous
Not applicable
Stephan - I've been running into an interesting problem with (vlax-add-cmd).
Here's the Scenario:

1.) I define a Lisp routine with the following:

(vl-load-com)
;; Zoom Extents (Command: ZE)
(defun agc-ze ()
(vla-zoomextents (vlax-get-acad-object))
(princ)
)
(vlax-add-cmd "ZE" 'agc-ze "ZE" 1)

2.) I start AutoCAD and create a new drawing, Then try the ZE command. At
this point it works exactly as it's supposed to...

3.) I open a second drawing in the same AutoCAD session, Then try the
command in the second drawing - Still works good...

1.) I then switch back to the First drawing I created. Trying the ZE command
again in this drawing now returns an Error: "Visual LISP command document
mismatch: ZE"

Any ideas on what I'm doing wrong?? I'm about ready to give up on this!

Thanks,
--
Phillip Kenewell
CAD Systems Technician
Air Gage Company
[email protected]
0 Likes
Message 19 of 31

Anonymous
Not applicable
Hi Phillip,

yes, this is a bug in AutoCAD 2000.
I published a workaround in this group some months ago.
I use that every day and it seems to work without problems.

Good luck
Stephan

P.S.:
If you can't find the message from last year here it is:

> vlax-add-cmd fails in MDI mode
> This and more bugs can you find here: http://www.dotsoft.com/
>
> As a workaround you can use a docmanager-reactor which redefines
> the commands every time you change the active document
> (not fully tested, but it seems to work):
>
> ;;; by Stephan Koster 1999
> ;;; enables vlax-add-cmd in MDI
> ;;; Global functions: AddCommandsHelper AddCommandsInMDI
> ;;; Global variable: *AddCommandsList*
> ;;; Example: Add commands "Test1" and "Test2" (transparent):
> ;;;
> ;;; (AddCommandsInMDI '(("Test1" test)("Test2" c:test2 "Test2" 1)))
> ;;;
> ;;; The functions must be defined before the call to AddCommandsInMDI
> ;;; A new call to AddCommandsInMDI with the same command name but
> ;;; changed function redefines the command
> ;;; Returns: A list of the commands succesfully defined
>
> (defun AddCommandsHelper (CallingReactor CommandList / return ok)
> (foreach x *AddCommandsList*
> (if (and (member (type (eval (caddr x))) '(SUBR USUBR EXRXSUBR))
> (setq ok (apply 'vlax-add-cmd (cdr x))))
> (setq return (cons ok return))
> )
> )
> return
> )
>
> (defun AddCommandsInMDI (lst / old)
> (foreach x lst
> (vlax-remove-cmd (car x))
> (if (setq old (assoc (strcase (car x)) *AddCommandsList*))
> (setq *AddCommandsList* (subst (cons (strcase (car x)) x) old *AddCommandsList*))
> (setq *AddCommandsList* (cons (cons (strcase (car x)) x) *AddCommandsList*))
> )
> )
> (if (not InitializeAddCommandsReactor)
> (setq InitializeAddCommandsReactor
> (vlr-docmanager-reactor "InitializeAddCommands"
> '((:vlr-documentBecameCurrent . AddCommandsHelper))
> )
> )
> )
> (AddCommandsHelper NIL NIL)
> )
>
0 Likes
Message 20 of 31

Anonymous
Not applicable
(DEFUN MP ()
(SETQ MP1 (GETPOINT "\nSelect first point for MID-PICK..."))
(setq mpt2 (GETPOINT "\nSelect SECOND point for MID-PICK..."))
(setq ang (angle mp1 mpt2))
(setq dist (distance mp1 mpt2))
(SETQ MP (polar mp1 ang ( * 0.5 dist)))
)
(vlax-add-cmd "mp" 'mp)

why won't this work transparently within another lisp routine?

Thanks
Rodney

Tony Tanzillo wrote in message
news:[email protected]...
> Don't define it using (vlax-add-command).
>
> Just do this:
>
> (defun C:JSA-A ()
> (command (osnap (cadr (grread nil 1)) "QUI,END,INT"))
> (princ)
> )
>
> Steve Adams wrote:
> >
> > Does anyone know how I can make the following
> > function transparent: (osnap (cadr (grread nil 1)) "end,int");
function
> > provided by Michael Puckett
> >
> > Below is my attempt, and it does not work.
> > Can anyone tell me why, or suggest something else?
> >
> > Thanks, Steve
> >
> > (vl-load-com)
> > (defun ada-2 ()
> > (osnap (cadr (grread nil 1)) "end,int")
> > )
> > (vlax-add-cmd "jsa-a" 'ada-2 "jsa-a" 1 )
>
> --
> /*********************************************************/
> /* Tony Tanzillo Design Automation Consulting */
> /* Programming & Customization for AutoCAD & Compatibles */
> /* ----------------------------------------------------- */
> /* [email protected] */
> /* http://www.caddzone.com */
> /*********************************************************/
0 Likes