Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Calculate the horizontal distance between two points or objects that have X,Y,Z

  1. #1
    100 Club
    Join Date
    2005-09
    Posts
    112
    Login to Give a bone
    0

    Default Calculate the horizontal distance between two points or objects that have X,Y,Z

    I need a lisp that will calculate the horizontal distance between two points or objects that have x,y,z with them. I do not need it label just for it to show the distance and bearing in the command prompt all of the lisps I have found label it and I am not sure which part of the routine calculates it.

  2. #2
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Calculate the horizontal distance between two points or objects that have X,Y,Z

    If you only want the x value distance, and it is in point format.

    Code:
    (setq Xdist (abs (- (car Pt1) (car Pt2))))
    Tim

  3. #3
    100 Club
    Join Date
    2005-09
    Posts
    112
    Login to Give a bone
    0

    Default Re: Calculate the horizontal distance between two points or objects that have X,Y,Z

    Sometimes it is not just between two points maybe a polyline or something that has a z value with it that is not set to zero. I just need it to display the distance and bearing.

  4. #4
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Calculate the horizontal distance between two points or objects that have X,Y,Z

    Can you just use the distance command within Acad? It will give you the total distance, distance in all planes, and the angle.

    Tim

  5. #5
    100 Club
    Join Date
    2005-09
    Posts
    112
    Login to Give a bone
    0

    Default Re: Calculate the horizontal distance between two points or objects that have X,Y,Z

    If I pick two points (x1,y1) and (x2,y2) I just need to use the distance between two points which is (x1-x2)/(y1-y2) the distance command in autocad gives you a slope distance. I am not sure if I explained this well but if there are any questions let me know.

  6. #6
    AUGI Addict Glenn Pope's Avatar
    Join Date
    2001-05
    Location
    Austin, TX USA
    Posts
    2,201
    Login to Give a bone
    0

    Default Re: Calculate the horizontal distance between two points or objects that have X,Y,Z

    You don't have Autodesk Map or LDT do you? They have tools that do what you want.
    Glenn Pope
    Civil Designer/CAD Manager
    River City Engineering
    AutoCAD Civil 3D 2011 Ver. 3
    Windows 7 Pro 64bit
    I explode MTEXT.

  7. #7
    100 Club
    Join Date
    2005-09
    Posts
    112
    Login to Give a bone
    0

    Default Re: Calculate the horizontal distance between two points or objects that have X,Y,Z

    yes i have ldt 2005 where is the tool that does that?

  8. #8
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Calculate the horizontal distance between two points or objects that have X,Y,Z

    Then maybe
    Code:
    (setq Xdist (abs (- (car Pt1) (car Pt2))))
    (setq Ydist (abs (- (cadr Pt1) (cadr Pt2))))
    (setq YourDist (/ Xdist Ydist))
    Tim

  9. #9
    AUGI Addict Glenn Pope's Avatar
    Join Date
    2001-05
    Location
    Austin, TX USA
    Posts
    2,201
    Login to Give a bone
    0

    Default Re: Calculate the horizontal distance between two points or objects that have X,Y,Z

    Quote Originally Posted by chrisw.94380
    yes i have ldt 2005 where is the tool that does that?
    Check out the Map toolbars. Look for one called "Coordinate Geometry". There are some nice tools for getting arc and line info. The command line entry for the command you want is MAPCGLIST.
    Glenn Pope
    Civil Designer/CAD Manager
    River City Engineering
    AutoCAD Civil 3D 2011 Ver. 3
    Windows 7 Pro 64bit
    I explode MTEXT.

  10. #10
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL
    Posts
    3,374
    Login to Give a bone
    0

    Default Re: Calculate the horizontal distance between two points or objects that have X,Y,Z

    This routine will give you Bearing, Distance, Delta elev and Slope:
    Code:
    ;|CADALYST Tip1666:DEC2000  DST.LSP  Quick Distance  (c)2000, Robert M. Jacobson
    
    DST.LSP WRITTEN BY ROBERT M. JACOBSON
    Modified by Tom Beauford: droped redundent prompts & expanded listed info.
    
    Dst.lsp will prompt the user to pick the first point, then pick the next point,
    then display the distance picked by with a colored line, every distance measured
    shows a different color. the bearing & horizontal distance will be displayed in
    the left corner of the status line and the bearing, horizontal distance, difference
    in elevation and slope will be displayed on the command line. |;
    
    (defun C:DST ( / 2DIST fact str1 tw CNTR PT1 PT2 ang DST PDST Pang)
    
      (defun 2DIST (PT) 
    	(list (car pt)(cadr pt))
      ) ;defun
      
      (setq fact nil)
      (if(and(= 1 (getvar "cvport"))(trans '(1 0 0) 2 3 0))
    	(progn
    	  (setq fact (car (trans '(1 0 0) 2 3 0)))
    	  (princ "\nPS:MS == 1:")
    	  (princ(/ 1 fact))
    	  (command "mspace")
    	  (setq tw (- (* 2 pi)(cdr(assoc 51(entget(acet-currentviewport-ename))))))
    	  (command "pspace")
    	)
      )
      (setq CNTR 0 ;INITIALIZE COUNTER
    		PT1 (getpoint "\nPick First Point") ;PROMPT FOR FIRST POINT
    		PT2 PT1
      )
      (while PT2 ;IF YES OR ENTER
    	(setq PT2 (getpoint "\nPick Next Point" PT1)) ;PROMPT FOR NEXT POINT
    	(if PT2
    	  (progn
    		(if fact
    		  (progn
    			(setq DST (/ (distance (2DIST PT1)(2DIST PT2))fact) ;CONVERT TO STRING
    				  PDST (distance (2DIST PT1)(2DIST PT2)) ;CONVERT TO STRING
    				  CNTR (1+ CNTR) ;ADD TO COUNTER FOR COLOR CHANGE
    				  Pang (angtos (angle pt1 pt2)4 4)
    				  ang (angtos (+(angle pt1 pt2)tw)4 4)
    				  deltaz  (/ (- (car(cddr pt2)) (car(cddr pt1)))fact)
    				  slope   (/ deltaz DST)
    			)
    			(if(eq Pang ang)
    			  (setq DST(strcat "MS Bearing= "ang ", Dist= " (rtos DST 2 2) "', PS Dist= " (rtos PDST 2 2) "\""))
    			  (setq DST(strcat "MS Bearing= "ang ", Dist= " (rtos DST 2 2) "', PS Bearing= "Pang ", Dist= " (rtos PDST 2 2) "\""))
    			);if
    		  );progn
    		  (setq DST (distance (2DIST PT1)(2DIST PT2))
    				CNTR (1+ CNTR)
    				ang (angtos (angle pt1 pt2)4 4)
    				deltaz  (- (car(cddr pt2)) (car(cddr pt1)))
    				slope   (/ deltaz DST)
    				DST	 (strcat "Bearing= "ang ", Dist= " (rtos DST 2 2) "'")
    		  )
    		);if fact
    		(prompt (strcat "\n" DST)) ;Print the distance to command line
    		(if (/= 0 deltaz)(prompt (strcat "\nDelta elev= "(rtos deltaz) "   Slope= "(rtos slope 2 6))))
    		(grtext -1 DST) ;Print distance in status line
    		(grdraw PT1 PT2 CNTR 2) ;Draw a colored line between points
    		(setq PT1 PT2) ;Change start point
    	  ) ;end progn
    	) ;end if PT2
      ) ;end while PT2
      (grtext -1 "") ;Clear status line
      (princ)
    ) ;end fun
    Quote Originally Posted by chrisw.94380
    I need a lisp that will calculate the horizontal distance between two points or objects that have x,y,z with them. I do not need it label just for it to show the distance and bearing in the command prompt all of the lisps I have found label it and I am not sure which part of the routine calculates it.
    Tom Beauford P.S.M. - Civil 2020 on Windows 10 Enterprise
    Design Analysis - Leon County Public Works/Engineering Wrap [CODE] tags around selected text
    2280 Miccosukee Rd. Tallahassee, FL 32308-5310
    Ph# (850)606-1516 Home Page

Page 1 of 2 12 LastLast

Similar Threads

  1. 2012: Calculate travel distance to exit
    By MikeJarosz in forum Revit Architecture - General
    Replies: 8
    Last Post: 2012-10-11, 02:52 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. Calculate distance - automatic
    By rodrigoabb in forum AutoCAD Map 3D - General
    Replies: 0
    Last Post: 2009-08-21, 01:55 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
  •