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.
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
@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...].
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.
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