Author Topic: osnap question  (Read 8555 times)

0 Members and 1 Guest are viewing this topic.

Andrew H

  • Guest
osnap question
« Reply #15 on: August 13, 2004, 01:40:22 PM »
oic, it changes it to a transparent command.

The "F" key which says: 'osmode 255 works geat too.

Andrew H

  • Guest
osnap question
« Reply #16 on: August 13, 2004, 01:42:33 PM »
me, too CADaver

JohnK

  • Administrator
  • Seagull
  • Posts: 10637
osnap question
« Reply #17 on: August 13, 2004, 01:47:40 PM »
Now the $ 10,000 question is: "Why is there a diff.? What makes using 'setvar' better then 'command'? " (In this situation)
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Andrew H

  • Guest
osnap question
« Reply #18 on: August 13, 2004, 01:49:33 PM »
CAN'T MAKE 'COMMAND' TRANSPARENT. IS MY GUESS.

JohnK

  • Administrator
  • Seagull
  • Posts: 10637
osnap question
« Reply #19 on: August 13, 2004, 01:50:42 PM »
Again, WHY?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Andrew H

  • Guest
osnap question
« Reply #20 on: August 13, 2004, 01:52:30 PM »
good question, I dunno.

ELOQUINTET

  • Guest
osnap question
« Reply #21 on: August 13, 2004, 01:55:28 PM »
(smartass mode) umm cos it's one less letter to type

JohnK

  • Administrator
  • Seagull
  • Posts: 10637
osnap question
« Reply #22 on: August 13, 2004, 01:56:45 PM »
What does "command" do?
Look it up in the help doc's.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Andrew H

  • Guest
osnap question
« Reply #23 on: August 13, 2004, 02:00:11 PM »
Not that good at lisps, yet. But I think it invokes an existing AutoCAD command and setvar assigns a value to a variable. and adding c in front of the defun name turns it into a command.

can you invoke an existing command with the 'command' function, but have it come in as transparent? as in "command" "'osmode"?

JohnK

  • Administrator
  • Seagull
  • Posts: 10637
osnap question
« Reply #24 on: August 13, 2004, 02:07:16 PM »
Basicly, --Real basic-- Using "setvar" im not try to necessarly 'pass information to AutoCAD to make some changes' but instead we are just 'making changes to AutoCAD' ourselves. (does that make sence?)

No. (Well i should say: I guess ive never really tried, but i seriously doubt it.)
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

CADaver

  • Guest
osnap question
« Reply #25 on: August 13, 2004, 02:43:27 PM »
Quote from: Se7en
Basicly, --Real basic-- Using "setvar" im not try to necessarly 'pass information to AutoCAD to make some changes' but instead we are just 'making changes to AutoCAD' ourselves. (does that make sence?)

No. (Well i should say: I guess ive never really tried, but i seriously doubt it.)
Yeah , that makes sense, at least that's how I always looked at it COMMAND means yer fixin' to tell ACAD to do something SETVAR is just changing settings.

sinc

  • Guest
osnap question
« Reply #26 on: August 13, 2004, 04:41:08 PM »
In most cases, when a task can be performed in two different ways, and one of them is with "command", the other way is preferable, for two reasons:

The first reason is simply a matter of efficiency.  In the above example, using "command" to change osnap ends up doing the same thing as seting "osnap" directly, it just involves a lot more processing.  If your code performs a simple task that is quickly accomplished, this difference is not noticeable; it only makes a real difference if your code loops.

The second is that "command" means "run the command as if you were taking input from the user", in the same way as if you had written a macro.  This means that all the additional "features" that Autocad adds during user input, and which may affect the result, are also applied.  This can sometimes lead to unintended side-effects.  For example, if you use "command" to draw lines without turning off osnaps first, you can get unpredictable results.  It's usually best to perform each task in as explicit a fashion as possible.

Sometimes, however, it's preferable to use the "command" version.  For example, if you WANT all the extra user-input features applied, go ahead and use the "command" version.  And sometimes, the "command" version is much easier to use.  For example, when I was recently trying to write a program to offset entities to the current layer instead of the object's layer, I used 'command ".offset"'', because after messing in vain with directional vaguaries of the LightWeightPolyline's offset method for a while, I decided it was much easier use the existing offset command and change the layer of the resulting entities.

Columbia

  • Guest
osnap question
« Reply #27 on: August 17, 2004, 10:12:47 AM »
And just to throw in something really confusing and muddy up the waters a little bit here's this little tidbit of code...
Code: [Select]

(defun set_osnap () (setvar "osmode" 127) (princ)) ;; setup snap function

(vl-load-com) ;; initialize the VisualLisp Environment

(vlax-add-cmd "reset_snap" 'set_osnap "reset_snap" 1) ;; add the command to ACAD command stack



The end result is a that you can now use C:RESET_SNAP as if it were a native ACAD command.  Which now means that it will work transparently in other LISP functions as well as native ACAD commands.