Author Topic: 2D/3D Displacement  (Read 1575 times)

0 Members and 1 Guest are viewing this topic.

Didge

  • Bull Frog
  • Posts: 211
2D/3D Displacement
« on: June 16, 2006, 11:32:49 AM »
Can somebody please enlighten me. The following code is supposed to move a selection set of entities by a simple 2D displacement even when snapped between 3D objects of varying elevation. Unfortunately, even though the pnt & newpnt variables are 2D the move command still uses a 3D displacement.

If I un-remark the osnap lines of code all works fine but then the user has to use transparent snaps which can get a touch tedious. 

It's not a big issue and I can certainly live without it but it has left me scratching my head somewhat.   :ugly:

Code: [Select]
(defun c:2Dmove (/ OLDCMD OLDSNAP SS PNT NEWPNT 2D)
  (defun 2D (p)(list (car p)(cadr p)))
;  (setq OLDSNAP (getvar "OSMODE"))
;  (setvar "OSMODE" 0)
  (prompt "\nSelect Objects to Move > ")
  (setq SS (ssget))
  (setq PNT (2D (getpoint "\nPick Base Point for Displacement > ")))
  (setq NEWPNT (2D (getpoint PNT "\nPick Second Point > ")))
  (command "_MOVE" SS "" PNT NEWPNT)
;  (setvar "OSMODE" OLDSNAP)
  (princ)
)
Think Slow......

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: 2D/3D Displacement
« Reply #1 on: June 16, 2006, 11:54:05 AM »
Try this:

(command "_MOVE" SS "" "_non" PNT "_non"  NEWPNT)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Didge

  • Bull Frog
  • Posts: 211
Re: 2D/3D Displacement
« Reply #2 on: June 16, 2006, 02:51:07 PM »
 :lmao:  :lmao:  :lmao:  :lmao:

Many thanks CAB, but I have to laugh.

I started to add a standard error trap to this old code this afternoon then after a short while my edits appeared to be having the opposite or no effect, very confusing.
I got home from work and ran that same code on my home pc and everything worked as expected, even more confusing me thinks.

So I began to add your code snippet (many thanks btw, it's more intuitive than my approach) and then realised my mistake:  Half way through working on the lisp file I ran the 2DMOVE command from my pull down menu, this loaded a 'VLX' of the same file but with the "OSMODE" in a slightly different position.  Once loaded the VLX defun killed any further LSP defuns making my edits pretty much useless.  I'm just off now to find out if VLX's can be unloaded like ARX's can.

Code: [Select]
(defun c:2Dmove (/ OLDCMD OLDSNAP SS PNT NEWPNT 2D)
  (defun 2D (p)(list (car p)(cadr p)))
  (setq OLDSNAP (getvar "OSMODE"))
  (prompt "\nSelect Objects to Move > ")
  (setq SS (ssget))
  (setq PNT (2D (getpoint "\nPick Base Point for Displacement > ")))
  (setq NEWPNT (2D (getpoint PNT "\nPick Second Point > ")))
  (setvar "OSMODE" 0)
  (command "_MOVE" SS "" PNT NEWPNT)
  (setvar "OSMODE" OLDSNAP)
  (princ)
)

And the moral of this story, dont rush coding last thing on a Friday afternoon, no matter how basic the coding is.   :oops:
Think Slow......