Author Topic: What is it with .MOVE ???  (Read 3840 times)

0 Members and 1 Guest are viewing this topic.

Hangman

  • Guest
What is it with .MOVE ???
« on: July 06, 2005, 08:33:22 PM »
Can someone help me with this, it's drive'n me nuts.
Code: [Select]

  (setq point--1 (getpoint "\nSelect Center Point of First Bubble:"))
  (princ "\n Pick a Radius for First Bubble or Return for default:")
  (setq pt--1 (command ".circle" point--1 pause))
  (if (= pt--1 nil)
    (setq pt--1 mrk-rad)
  )
  (setq b1 (ssget "l"))
  (setq bbl-rad (cdr (assoc 40 (entget (ssname b1 0)))))
  (command ".circle" point--1 mrk-rad)
  (setq b2 (ssget "l"))
  (command ".line" (polar point--1 pi mrk-rad) (polar point--1 0 mrk-rad) "")
  (setq b2 (ssadd (entlast) b2))
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  (princ "\nPick a point for your Mark:")
  (setq pt--2 (command ".move" b2 "" point--1 pause))
  (if (= pt--2 nil)
    (princ "\nYou Have to Pick a point for your Mark, Try again!   ")
    (quit)
  )
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  (setq point--2 pt--2)
  (setq point--2 (list (cadr (assoc 10 (entget (ssname b2 0))))(caddr (assoc 10 (entget (ssname b2 0))))))
  (setq dis (distance point--1 point--2))
  (setq ang1 (angle point--1 point--2))
  (if (> min-rad bbl-rad)
    (setq bbl-rad min-rad)
  )
  (setq point--3 (polar point--1 ang1 bbl-rad))
  (if (> min-l2 dis)
    (setq point--2 (polar point--3 ang1 min-l2))
  )
  (setq point--4 (polar point--2 (+ ang1 pi) mrk-rad))
  (setq dis1 (distance point--3 point--4))
  (if (> min-l1 dis1)
    (setq dis1 min-l1)
  )


The code between the xxxxxxx lines is where I'm running into a problem.
When the user does a second button click (a return) rather than picking a point, the bubble cut goes clear off the sheet.
I'm trying to tell the user that they just can't hit return.  I've tried looping it with
Code: [Select]

  (while (= pt--2 nil)
    (setq pt--2 (command ".move" b2 "" point--1 pause))
  )

But for some reason, the .move command isn't setting the pt--2 pick point like my pt--1 does with the circle command at the beginning.



Here is the portion of original code if your curious:
Code: [Select]

  (setq point--1 (getpoint "\nSelect Center Point of First Bubble:"))
  (princ "\n Enter Radius of First Bubble")
  (command ".circle" point--1 pause)
  (setq b1 (ssget "l"))
  (setq bbl-rad (cdr (assoc 40 (entget (ssname b1 0)))))
  (command ".circle" point--1 mrk-rad)
  (setq b2 (ssget "l"))
  (command ".line" (polar point--1 pi mrk-rad) (polar point--1 0 mrk-rad) "")
  (setq b2 (ssadd (entlast) b2))
  (princ "\nEnter Direction of Mark:")
  (command ".move" b2 "" point--1 pause)
  (setq point--2 (list (cadr (assoc 10 (entget (ssname b2 0))))(caddr (assoc 10 (entget (ssname b2 0))))))
  (setq dis (distance point--1 point--2))
  (setq ang1 (angle point--1 point--2))
  (if (> min-rad bbl-rad)
    (setq bbl-rad min-rad)
  )
  (setq point--3 (polar point--1 ang1 bbl-rad))
  (if (> min-l2 dis)
    (setq point--2 (polar point--3 ang1 min-l2))
  )
  (setq point--4 (polar point--2 (+ ang1 pi) mrk-rad))
  (setq dis1 (distance point--3 point--4))
  (if (> min-l1 dis1)
    (setq dis1 min-l1)
  )


My users were having issues with hitting return for a default circle rather than just picking a circle (the purpose for pt--1, go figure) and then hitting return when they are suppose to pick where they want their cut label.  I want to force them to pick a point for their cut label rather than have it shoot off the page somewhere because it is an "invalid point".
If I can cancel the routine with a message if they don't pick a point or if I can make it loop until they pick a point, that would be great.
If you know of both ways, I would love to see them, and any other ideas you may have for this.

Thanks.

Jeff_M

  • King Gator
  • Posts: 4100
  • C3D user & customizer
What is it with .MOVE ???
« Reply #1 on: July 06, 2005, 09:04:58 PM »
Well, here's one way, but you lose the ability to see the objects being moved.
Code: [Select]

 (defun c:test (/ ss pt1 pt2)
  (setq ss (ssget)
pt1 (getpoint "\nBase point: ")
)
  (command ".move" ss "" pt1)
  (while (not (setq pt2 (getpoint pt1)))
    (princ "..you MUST pick a point!.....")
    )
  (command pt2)
  (princ)
  )

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
What is it with .MOVE ???
« Reply #2 on: July 07, 2005, 12:41:04 AM »
Try this..

The move command when enter is pressed takes the first point as an offset value.
So the object or ss in this case is moved by that polar vector. Therefore I test
to see if that happened & move everything back if it did and make the user try again.

Code: [Select]
(defun c:test()
  (setq mrk-rad 6)

 
(setq point--1 (getpoint "\nSelect Center Point of First Bubble:"))
  (princ "\n Enter Radius of First Bubble")
  (command ".circle" point--1 pause)
  (setq b1 (ssget "l"))
  (setq bbl-rad (cdr (assoc 40 (entget (ssname b1 0)))))
  (command ".circle" point--1 mrk-rad)
  (setq b2 (ssget "l"))
  (command ".line" (polar point--1 pi mrk-rad) (polar point--1 0 mrk-rad) "")
  (setq b2 (ssadd (entlast) b2))
  ;;============================================================================
  (setq ent (entlast)
        stpt (cdr (assoc 10 (entget ent)))
        nomove t)
  (while nomove
    (princ "\nEnter Direction of Mark:")
    (command ".move" b2 "" point--1 pause)
    (setq newpt (cdr (assoc 10 (entget ent))))
    (if (>= 0.0001 (distance (setq offset (sum stpt point--1)) newpt))
      (progn
        (prompt "\n***  Error, you must pick a new point.")
        (command ".move" b2 "" offset point--1)
      )
      (setq nomove nil)
    )
  )
  ;;=============================================================================
  (setq point--2 (list (cadr (assoc 10 (entget (ssname b2 0))))(caddr (assoc 10 (entget (ssname b2 0))))))
  (setq dis (distance point--1 point--2))
  (setq ang1 (angle point--1 point--2))
  (if (> min-rad bbl-rad)
    (setq bbl-rad min-rad)
  )
  (setq point--3 (polar point--1 ang1 bbl-rad))
  (if (> min-l2 dis)
    (setq point--2 (polar point--3 ang1 min-l2))
  )
  (setq point--4 (polar point--2 (+ ang1 pi) mrk-rad))
  (setq dis1 (distance point--3 point--4))
  (if (> min-l1 dis1)
    (setq dis1 min-l1)
  )

  )


;;   return sum of 3d points
(defun sum (p1 p2)
  (list
    (+ (car p1) (car p2))
    (+ (cadr p1) (cadr p2))
    (+ (caddr p1) (caddr p2))
    )
)
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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
What is it with .MOVE ???
« Reply #3 on: July 07, 2005, 09:40:09 AM »
I created a function to facilitate the move.
But if the move is the same exact distance & direction from the first
pick for the move as the pick point is from the origin (0 0 0) the routine
will not permit this move.
Example: pick at 12,12 moved to 24,24 will not be allowed
Too bad there is not a way to get the last input, if we had a function like
(lastkey) that returned the last key press or neg number if mouse or tablet
button was pressed.

Code: [Select]
;;;=======================[ Move_Only.lsp ]=======================
;;; Author: Copyright© 2005 Charles Alan Butler
;;; Version:  1.0 July 7, 2005
;;; Purpose: move an entity or ss, do not allow user to press enter
;;; Usage : (move_only ss msg basept)
;;; Arguments:
;;;     ss       ss or ent to move
;;;     msg      msg to user before move, may be nil
;;;     basept   first point of move, may be nil
;;; Returns: -list (start_point end_point) of move
;;;==============================================================
(defun move_only (ss basept msg / ent stpt loop newpt)

  ;;   return sum of 3d points
  (defun sum_pts (op p1 p2)
    (list
      (apply op (list (car p2) (car p1)))
      (apply op (list (cadr p2) (cadr p1)))
      (apply op (list (caddr p2) (caddr p1)))
    )
  )

  ;;  return a point, lower left box coordinates
  (defun getref (ent / ll ur)
    (vla-getboundingbox (vlax-ename->vla-object ent) 'll 'ur)
    (vlax-safearray->list ll)
  )

  (if (= (type ss) 'PICKSET)
    (setq ent (ssname ss 0))
    (setq ent ss)
  )
  (setq stpt (getref ent)) ; get start ref point (lower left of ent)
  (if (null basept) ; pisk start point of move
    (while (or (null (setq basept (getpoint "\nPick base point of move.")))
               (/= (type basept) 'LIST))
      (prompt "\n***  Error, you must pick a start point.")
    )
  )
  (setq loop t) ; loop flag
  (while loop
    (if msg (princ msg) )
    (command "._move" ss "" basept pause)
    (setq newpt (getref ent)) ; new start point
    (if (>= 0.0001 (distance (setq offset (sum_pts '+ stpt basept)) newpt))
      ;;  if ss moved via vector point--1 then ENTER was pressed
      (progn ; move ss back and make user move again
        (prompt "\n***  Error, you must pick a distination point.")
        ;(command "._move" ss "" "non" newpt "non" stpt)
        (command "._undo" "")
      )
      ;;  ELSE  point was picked, ok to exit loop
      (setq loop nil)
    )
  )
 
  (list basept (sum_pts '+ basept (sum_pts '- stpt newpt)))
)
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.

Jeff_M

  • King Gator
  • Posts: 4100
  • C3D user & customizer
What is it with .MOVE ???
« Reply #4 on: July 07, 2005, 10:06:42 AM »
Of course, this is a lot of work to work around a built-in feature of Autocad. It seems to me a wee bit of training is in order for the users. I know it only took me about 10 times of saying"Hey! Were'd my objects go?" before I figured out that hitting enter in response to the second pick was usually the wrong thing to do.....I got real good at pressing "U" right after..... :D

I should add that although it is a built-in function, not once have I ever seen a need to use this 'feature'. Has anyone else? I personally think that, at the very least, there should be an option to turn it off.

daron

  • Guest
What is it with .MOVE ???
« Reply #5 on: July 07, 2005, 10:25:53 AM »
Maybe I'm not understanding what is being desired here, but what I can gather is you're trying to keep autocad from moving selected object to outer space if the user hits enter. If that's the case, I wrote something a long time ago to do this. Here's a snippet:
Code: [Select]
(setq whereto
   (getpoint
tposi
"\nPick screen to move object or [enter]: "
   ) ;_ end of getpoint
 ) ;_ end of setq
 (if (= whereto nil)
      (command ".move" ename "" tposi tposi)
      (command ".move" ename "" tposi pause)
 ) ;_ end of if

ename is a preselected entity name pulled from a selectioin set and tposi is just a (cdr 10 value) of said object. I used this in a command I wrote that would take an object selected and ssget every object on that objects layer and allow you to move each one individually. It would zoom center at a hardcoded factor, so the user wasn't left wondering where the next object was at. There would normally be thousands of objects I was trying to move and I didn't always want to move all objects.

Jeff_M

  • King Gator
  • Posts: 4100
  • C3D user & customizer
What is it with .MOVE ???
« Reply #6 on: July 07, 2005, 11:26:18 AM »
Daron, the problem is that using your method, or the one I posted, does not allow the user to 'see' the objects being moved. To some users this is critical, otherwise you may move them to a point that conflicts with other objects....then it becomes a trial & error excercise.

And looking at your code a bit further, by giving the user the option to enter the second point in the move command, you can still have the situation where the user hits enter and off go the objects.......

Hangman

  • Guest
What is it with .MOVE ???
« Reply #7 on: July 07, 2005, 11:31:29 AM »
Thanks guys for the responses,  I'm going to have to go through these to see what I can see.
Then again, perhaps I am not explaining this well enough as Daron has pointed out.  So I'll give a brief explanation here.

This lisp is designed to draw a bubble cut.
The user first picks the center point of the bubble, then the user is asked to pick a radius or hit enter for a default radius which is the same size as the bubble cut label itself.  The lisp then draws the first circle and the bubble cut label.  Then it commands a move of the bubble cut label prompting the user to place it in some direction a small distance from the first bubble.  If it is too close to the first bubble, there is a default distance it is placed too.  Otherwise, it places the bubble, draws a line, puts in text and in the end, creates a block out of the whole thing and places the block.
Now the problem I am running into is that the bubble cut label can be placed in any 360 degree location from the first bubble.  So a default position would not be feasible.  But when some trigger happy user punches the enter button rather than picking a place for the bubble cut label, they get an 'invalid point' prompt but the bubble cut label is placed some huge distance from the first bubble and essentially placing the label off the limits of the sheet.
All I want to do is not allow the return value to occur.  Either loop a message saying the user cannot hit enter, they MUST pick a point.  Or cancel the routine and prompt the user to do it again until they do pick a point.

Did that make sense, ...

daron

  • Guest
What is it with .MOVE ???
« Reply #8 on: July 07, 2005, 11:56:36 AM »
Quote from: Jeff_M
Daron, the problem is that using your method, or the one I posted, does not allow the user to 'see' the objects being moved. To some users this is critical, otherwise you may move them to a point that conflicts with other objects....then it becomes a trial & error excercise.

And looking at your code a bit further, by giving the user the option to enter the second point in the move command, you can still have the situation where the user hits enter and off go the objects.......


Actually mine does allow you to see what you're moving. The whereto variable has you either picking the screen before you move or hitting enter to pass to the next object. Here's the rest of the code minus some variable settings and defun:
Code: [Select]

     (setvar "osmode" 0)
     (setq ent (car (entsel "\nSelect object for move by Layer: "))
  llist (entget ent)
  ltype (assoc 8 llist)
  etype (cdr (assoc 0 llist))
  ss (ssget "x" (list ltype (cons 0 etype)))
  ssl (sslength ss)
  cnt 0
     ) ;_ setq
     (repeat ssl
 (cond
      ((= etype "TEXT")
(setq ename (ssname ss cnt)
     elist (entget ename)
     tposi (cdr (assoc 11 elist))
     cnt   (1+ cnt)
) ;_ setq
      )
      ((or (= etype "MTEXT")
   (= etype "XLINE")
   (= etype "RAY")
   (= etype "LINE")
   (= etype "LWPOLYLINE")
   (= etype "INSERT")
   (= etype "ARC")
   (= etype "CIRCLE")
   (= etype "ELLIPSE")
) ;_ or
(setq ename (ssname ss cnt)
     elist (entget ename)
     tposi (cdr (assoc 10 elist))
     cnt   (1+ cnt)
) ;_ setq
      )
 ) ;_ cond
 (prompt (strcat "\n" (itoa cnt) " of " (itoa ssl)))
 (command ".zoom" "c" tposi "1368")
 (redraw ename 3)
 (setq whereto
   (getpoint
tposi
"\nPick screen to move object or [enter]: "
   ) ;_ end of getpoint
 ) ;_ end of setq
 (if (= whereto nil)
      (command ".move" ename "" tposi tposi)
      (command ".move" ename "" tposi pause)
 ) ;_ end of if
 (redraw ename 4)
     )
It's ugly, but it worked when I wrote it and it still works now.

Jeff_M

  • King Gator
  • Posts: 4100
  • C3D user & customizer
What is it with .MOVE ???
« Reply #9 on: July 07, 2005, 02:42:13 PM »
Daron, try as I might, I cannot see how this circumvents the inadvertent pressing of enter for the second point in the move. The way I see it working is:
Code: [Select]
(setq   whereto
          (getpoint
          tposi
          "\nPick screen to move object or [enter]: "
          ) ;_ end of getpoint
     ) ;_ end of setq

Here you are getting a point, or not, and setting 'whereto' to that value....the items being moved are not visible here, although a runbberband line is. Then
Code: [Select]
    (if (= whereto nil)
          (command ".move" ename "" tposi tposi)
          (command ".move" ename "" tposi pause)
     ) ;_ end of if
has the object being either "moved to the same place it already was if the user had entered nothing for whereto, OR the user must enter a point to move to (making the whole point of collecting 'whereto' pointless) at which point if they press enter the objects take off into space. If this is incorrect, please show me.

Jeff

daron

  • Guest
What is it with .MOVE ???
« Reply #10 on: July 07, 2005, 02:59:43 PM »
Okay, on further thought, you're right. What it does do, is give you the option to not move the selected object but also not send it off into space. However, picking on screen, then enter would still send it off. It's like Microsoft asking if you really want to delete the selected object, when you alrady told it to do so, only this has more purpose, since the object was selected programatically.

Hangman, what was your question? Oh, you want >this<. Let's get back on topic, please.