See the top rated post in this thread. Click here

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

Thread: LISP modification request - inverse

  1. #1
    Member
    Join Date
    2017-03
    Posts
    6
    Login to Give a bone
    0

    Default LISP modification request - inverse

    I have a LSP file that's been in my library for a while that allows you to pick any two points then list the bearing/horizontal/slope distance in the command line. Don't remember where I got it - but it is currently set to report the final distances to two (2) decimal places. Hoping there is an easy way to modify to have it read distance to four (4) decimal places?

    This is probably super simple to anyone comfortable writing LSP...I'm just not there....

    Alternatively - if this pulls from a variable or setting that would control that rather than the LSP code itself, what would I use to do that?

    Code:
    (defun C:INV ( / 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

  2. #2
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,707
    Login to Give a bone
    1

    Default Re: LISP modification request - inverse

    Look through your code and change something like this:

    Code:
    (rtos <SomeVariableName> 2 2)
    ... to this:

    Code:
    (rtos <SomeVariableName> 2 4)
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  3. #3
    Member
    Join Date
    2017-03
    Posts
    6
    Login to Give a bone
    0

    Default Re: LISP modification request - inverse

    Thanks @BlackBox -- just curious, what does the first number in each of those variable sets control?

  4. #4
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,707
    Login to Give a bone
    0

    Default Re: LISP modification request - inverse

    Quote Originally Posted by SWarnock84 View Post
    Thanks @BlackBox -- just curious, what does the first number in each of those variable sets control?
    Most welcome; this may help:

    http://docs.autodesk.com/ACD/2013/EN...ber=d30e627140
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  5. #5
    Member
    Join Date
    2017-03
    Posts
    6
    Login to Give a bone
    0

    Default Re: LISP modification request - inverse

    That is helpful, thanks again.

    However, even after changing all of those variables to a 4, nothing happens. I still get a readout to 2 decimal places. Any other ideas?

    Capture.JPG

  6. #6
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,707
    Login to Give a bone
    0

    Default Re: LISP modification request - inverse

    What precision are the drawing's UNITS, specifically LUPREC sysvar?
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  7. #7
    Member
    Join Date
    2017-03
    Posts
    6
    Login to Give a bone
    0

    Default Re: LISP modification request - inverse

    That was my first thought - but it doesn't seem to have any effect. LUPREC is set to 4, and UNITS are set to four decimal points as well. Since I'm working in C3D I also checked the Global Drawing Settings, and those units are also set to 4.

    Has me stumped...

  8. #8
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,051
    Login to Give a bone
    0

    Default Re: LISP modification request - inverse

    Have you stepped through your code to find where this is reporting incorrectly?
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  9. #9
    Member
    Join Date
    2017-03
    Posts
    6
    Login to Give a bone
    0

    Default Re: LISP modification request - inverse

    It's not that it's reporting "incorrectly". It works, but only reports distances to 2 decimal places no matter what variables are changed. We were hoping to alter the code to report to 4 decimal places for when we do precision work.

    I didn't write the original code, and my knowledge is fairly limited - so I'm hoping someone more experienced can pick out why that may be happening.

    Thus far we have changed the precision values to 4, checked UNITS, LUPREC, and other drawing settings to no effect.

  10. #10
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,707
    Login to Give a bone
    0

    Default Re: LISP modification request - inverse

    Think it has to do with one of the point/angle calculations - just don't recall which.

    As example, if you obtain a point, then subtract the integer from the X value of same point, you get more digits than is displayed when obtaining the point:

    Code:
    Command: (setq pt (getpoint))
    (485129.0 1.02485e+06 0.0)
    
    Command: (- (car pt) 485129)
    0.126708
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

Page 1 of 2 12 LastLast

Similar Threads

  1. Need a help in modification of lisp. Please update the lisp code as required.
    By brahmanandam.thadikonda762224 in forum AutoLISP
    Replies: 0
    Last Post: 2018-09-20, 04:12 AM
  2. Modification to a lisp (needs to change the lisp code)
    By nanaji130285733687 in forum AutoLISP
    Replies: 3
    Last Post: 2016-11-21, 04:45 AM
  3. Replies: 12
    Last Post: 2006-01-10, 09:38 PM
  4. Please HELP: Need "Inverse of a Matrix" routine
    By bradipos in forum AutoLISP
    Replies: 0
    Last Post: 2005-07-08, 02:40 PM
  5. Inverse mouse for walkthrough
    By overcaffeined1745 in forum Revit Architecture - Wish List
    Replies: 0
    Last Post: 2003-06-10, 11:14 AM

Posting Permissions

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