Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Transparent Running Osnap

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
736 Views, 3 Replies

Transparent Running Osnap

I have read thru a few postings on the subject and nothing seems to be working.  I would like these functions to work transparently if I can.  This is what I have:

 

(defun o1 () (setvar "osmode" 1))

(defun o2 () (setvar "osmode" 2))

and so on

 

I have these loaded within a program and I have tried with the apostrophe and without, in parenthesis and without and a combination of both as stated in some of the older posts and nothing seems to work.  I have tried with the c: and without and still no go.  They work at the command prompt but not transparently within a command and I know if I type (setvar "osmode" 2) while in the middle of the line command it will work.  What am I missing, just wanting to shorten my typing steps?  Terrible typist here.

3 REPLIES 3
Message 2 of 4
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

....  I would like these functions to work transparently if I can.  This is what I have:

 

(defun o1 () (setvar "osmode" 1))

(defun o2 () (setvar "osmode" 2))

and so on

 

I have these loaded within a program and I have tried with the apostrophe and without, in parenthesis and without ... with the c: and without ....


They work for me if I define them with the C: [without that, you must use them with parentheses], and use them [when within a command] with the apostrophe:

 

(defun C:o1 () (setvar 'osmode 1) (princ))
(defun C:o2 () (setvar 'osmode 2) (princ))

 
Usage:

 

[start a command, like Line, and somewhere along the way...]

'o1

[snaps only to Endpoints...]

'o2

[snaps only to Midpoints], etc.

 

The (princ)'s would be expendable in isolated usage and within certain commands, but within something like Line, if you don't have them, you get a Line of 1 or 2 drawing units' length from the previous point in the direction from there toward the crosshairs location, because the functions return the 1 or 2 value to the command, just as if you aimed the crosshairs and typed an intended distance.

 

Also, make sure you're not mixing up zeros and letter-O's when you type [I did once, in trying these...].

Kent Cooper, AIA
Message 3 of 4
Anonymous
in reply to: Kent1Cooper

Will do and retry.  Yeah, I did a search and replace with C:o to o and vice-a-versa to make sure I have o and not zero and I have type the wrong character at the command prompt also.  Thanks for you responce.

 

Works great!  Thanks again.

Message 4 of 4
hofcad
in reply to: Anonymous

Not so cool alternative:

 

(defun c:o1 ()
  (vl-load-com)
  (vla-SendCommand
    (vla-get-ActiveDocument (vlax-get-acad-object))
    "'SETVAR OSMODE 1 "
  )
  (princ)
)

 

HofCAD CSI

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost