Results 1 to 2 of 2

Thread: Moving or copying half distance of your pick points

  1. #1
    I could stop if I wanted to
    Join Date
    2015-12
    Posts
    383
    Login to Give a bone
    0

    Talking Moving or copying half distance of your pick points

    Hello all,
    Getting tired of using distance command or drawing reference lines to get half distances I wrote the following lisp. This copies something 1/2 the distance you select and uses the same angle (so if your 2nd point was 6" to the right of your 1st point, the object will get copied 3" to the right)
    Also included is the move half distance, it works the same way.

    Code:
    (defun c:movehalfdist (/ pt1 pt2 myselset halvedtext disttobehalved halfdist angledeg)
      (setq myselset (ssget))
      (setq pt1 (getpoint "Pick start point: "))
      (command "line"  pt1 pause "")
      (setq pt2 (getvar "lastpoint"))
      (setq disttobehalved (distance pt1 pt2))
      (command "erase" (entlast) "")
      (setq halfdist (/ disttobehalved 2))
      ;(alert (strcat (rtos halfdist 2 2) " is half of " (rtos disttobehalved 2 2)))
      (setq angledeg (* (angle pt1 pt2) (/ 180 3.14159265)))
      ;(alert (strcat (rtos angledeg 2 0)))
      (setq halvedtext (strcat "@" (rtos halfdist 2 6) "<" (rtos angledeg 2 2)))
      (command "move" myselset "" pt1 halvedtext)
      (princ))
    
    (defun c:copyhalfdist (/ pt1 pt2 myselset halvedtext disttobehalved halfdist angledeg)
      (setq myselset (ssget))
      (setq pt1 (getpoint "Pick start point: "))
      (command "line"  pt1 pause "")
      (setq pt2 (getvar "lastpoint"))
      (setq disttobehalved (distance pt1 pt2))
      (command "erase" (entlast) "")
      (setq halfdist (/ disttobehalved 2))
      ;(alert (strcat (rtos halfdist 2 2) " is half of " (rtos disttobehalved 2 2)))
      (setq angledeg (* (angle pt1 pt2) (/ 180 3.14159265)))
      ;(alert (strcat (rtos angledeg 2 0)))
      (setq halvedtext (strcat "@" (rtos halfdist 2 6) "<" (rtos angledeg 2 2)))
      (command "copy" myselset "" pt1 halvedtext)
      (princ))
    
    (defun c:offsethalfdist (/ pt1 pt2 disttobehalved halfdist)
      (setq pt1 (getpoint "Pick start point: "))
      (command "line"  pt1 pause "")
      (setq pt2 (getvar "lastpoint"))
      (setq disttobehalved (distance pt1 pt2))
      (command "erase" (entlast) "")
      (setq halfdist (/ disttobehalved 2))
      (command ".offset" halfdist)
      (princ))

    Always up for learning, if I did somehing ineffeciently or just wrong, let me know.
    Thansk all
    Last edited by Opie; 2007-03-08 at 02:39 PM. Reason: [CODE] tags added

  2. #2
    AUGI Addict madcadder's Avatar
    Join Date
    2000-11
    Location
    Broken Arrow, OK
    Posts
    1,005
    Login to Give a bone
    0

    Default Re: Moving or copying half distance of your pick points

    Why not just use the "Midpoint Between 2 points" osnap?

    Or... If you are on a previous version that doesn't have that built-in then you can also use an older user version like:
    Code:
    ;;; Mid point of two points
    ;;;
    (DEFUN c:midpt (/ |lunits| |pt1| |pt2| |ptm|)
      (SETQ |pt1| (GETPOINT "\nMIDPT: Specify first point: "))
      (SETQ |pt2| (GETPOINT |pt1| "\nMIDPT: Specify second point: "))
      (SETQ	|ptm| (POLAR |pt1|
    		     (ANGLE |pt1| |pt2|)
    		     (/ (DISTANCE |pt1| |pt2|) 2.0)
    	      )
      )
      (SETQ |lunits| (GETVAR "lunits"))
      (IF (MEMBER (GETVAR "cmdnames") (LIST "MIRROR"))
        (STRCAT (RTOS (CAR |ptm|) |lunits| 15)
    	    ","
    	    (RTOS (CADR |ptm|) |lunits| 15)
        )
        (STRCAT (RTOS (CAR |ptm|) |lunits| 15)
    	    ","
    	    (RTOS (CADR |ptm|) |lunits| 15)
    	    ","
    	    (RTOS (CADDR |ptm|) |lunits| 15)
        )
      )
    )
    The advantage that using a midpt routine is that you can use it on any command, not just MOVE, COPY, OFFSET.

    Start a line, type in " 'midpt ", click first point, second point, and you are now starting a line mid point between the two selected points.

    Also included is my OFFSET HALF version. Mine works a little different, but I'm including just for the FYI of it.
    Code:
    ;;; FOR OFFSETTING 1/2 DISTANCE
    (DEFUN c:o2 (/ |dist| |fracoff| |lunits| |luprec| |pt1| |pt2|)
      (SETQ |lunits| (GETVAR "lunits"))
      (SETQ |luprec| (GETVAR "luprec"))
      (SETQ	|dist|
    	 (GETREAL
    	   "\nEnter Distance To Divide In HALF <ENTER to select first point>: "
    	 )
      )
      (IF (= |dist| nil)
        (SETQ |pt1|	 (GETPOINT "\nSelect First Point: ")
    	  |pt2|	 (GETPOINT |pt1| "\nSelect Second Point: ")
    	  |dist| (DISTANCE |pt1| |pt2|)
        )
      )
      (SETQ |halfoff| (/ |dist| 2.0))
      (PRINC (STRCAT "\nOffset Distance Set To: "
    		 (RTOS |fracoff| |lunits| |luprec|)
    	 )
      )
      (COMMAND "offset" |halfoff|)
      (PRINC)
    )

Similar Threads

  1. Replies: 1
    Last Post: 2015-05-11, 09:03 PM
  2. Replies: 2
    Last Post: 2011-07-22, 05:32 AM
  3. Points- create points slope-distance
    By jenniferchavez in forum AutoCAD Civil 3D - Survey
    Replies: 1
    Last Post: 2009-12-10, 06:03 PM
  4. Streching half the distance in both direction
    By r424andy in forum Dynamic Blocks - Technical
    Replies: 5
    Last Post: 2006-02-27, 05:21 PM
  5. Type in distance when dragging pick points
    By J. Grouchy in forum Revit Architecture - Wish List
    Replies: 11
    Last Post: 2004-10-14, 06:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •