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

Thread: Display insertion point coordinates in decimal feet

  1. #1
    I could stop if I wanted to
    Join Date
    2011-09
    Posts
    308
    Login to Give a bone
    0

    Default Display insertion point coordinates in decimal feet

    Hi folks, I need a bit of a refresher I'm afraid.

    I have a Lisp routine that inserts a block and then populates two attributes with X and Y values of the pick point.

    It works fine but I'm having a hard time getting it to display in decimal feet (not feet and decimal inches). So: 136.75 feet.

    Currently it's spitting out decimal inches, so I think I just need to divide something in the 2 "setq" lines (in red) by 12 but where and how are eluding me.

    Here is the code that populates the attributes:

    Code:
    (while (setq p (getpoint "\n Specify point :"))
    (setq CRDX (strcat "X: " (rtos (car p) 2 2)))
    (setq CRDY (strcat "Y: " (rtos (cadr p) 2 2)))
      (command "_.-insert"
               "Point Of Test"
               "Scale"
               SCL
               "_none"
               p
               ""
               CRDX
               CRDY
      )
    
    
    )
    Thanks for any guidance!

    -JP

  2. #2
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    555
    Login to Give a bone
    0

    Default Re: Display insertion point coordinates in decimal feet

    Check the sequence of commands by doing manualy -insert point of int scl "" Pause crdx crdy, you can enter a lisp value in a manual test use !scl when asked for scale.

  3. #3
    I could stop if I wanted to
    Join Date
    2011-09
    Posts
    308
    Login to Give a bone
    0

    Default Re: Display insertion point coordinates in decimal feet

    ThanksBig Al, the scale works fine. It's just the value for CDRX and CDRY. I can get hem to display decimal inches, but I need decimal feet and I cant figure out how to divide by 12 in the code. Does that make sense?

  4. #4
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Display insertion point coordinates in decimal feet

    Hi,
    Set the system variable 'DIMZIN to zero then convert the value to (feet and decimal inches) with rtos function as follows.
    e.g:
    Code:
    (setq dz (getvar 'DIMZIN))
    (setvar 'DIMZIN 0)
    (rtos 10 3 2)
    (setvar 'DIMZIN dz)
    
    ;; Should return: "10.00\""

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

    Default Re: Display insertion point coordinates in decimal feet

    I use one by Tharwat including code by others that includes a leader, options to display No Elevation, All Coordinates, or Z coordinates only. It also adds comma delimiters as in 1,234,567,890.12
    It also loops letting you pick as many points to label as you want.
    https://www.cadtutor.net/forum/topic...comment-552696

    Pretty sweet!

    Forgot my version was modified a little:
    Code:
    (defun c:enz (/ clr key pnt a b c)
      ;;	Tharwat - 5.Jul.2019
      ;;	(load "enz.lsp") enz
      ;;	https://www.cadtutor.net/forum/topic/68126-require-lisp-3-in-1-for-xyz-coordinates-with-leader/?tab=comments#comment-552696
    
      ;; Add Commas
      ;; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/1-000-comma-separator/m-p/1857166#M230806
      ;; Code Source: John Uhden
      ;; This function pads a numeric string with commas.
      ;; Arguments:
      ;; num = any number, real or integer (>= 0)
      ;; # = precision, integer (>= 0)
      ;;
      (defun rtoc (num # / p#)
    	(setq num (rtos num 2 #) # 1)
    	(while (and (/= (substr num # 1) ".")(<= # (strlen num)))
    	  (setq # (1+ #))
    	)
    	(setq # (1- #) p# #)
    	(if (= (setq # (rem # 3)) 0)(setq # 3))
    	(while (< # p#)
    	  (setq num (strcat (substr num 1 #) "," (substr num (1+ #)))
    		# (+ 4 #)
    		p# (1+ p#)
    	  )
    	)
    	num
      )
    
    ;  (setq clr (getvar 'clayer)) ; from dlanorh's code
    ;  (cond ( (null (tblsearch "LAYER"  "Coor Text")) (command "-layer" "_M" "Coor Text" "_C" 7 "" "")) (t (setvar 'clayer "Coor Text")))
      (and
        (or (initget "NoZ All Z")
            (setq key
                   (cond
                     ((getkword
                        "\nPick your go [No Elevation , All Coordinates , Z coordinates only] [NoZ/All/Z] < NoZ > :"
                      )
                     )
                     ("NoZ")
                   )
            )
        )
        (setq pnt (getpoint "\nSpecify base point : "))
        (setq dim (getvar 'DIMZIN))
        (setvar 'DIMZIN 0)
        (while pnt
    	  (mapcar 'set
    			  '(a b c)
    ;			  (mapcar '(lambda (k p) (strcat k (rtoc p 4)))
    			  (mapcar '(lambda (k p) (strcat k (rtoc p 2)))
    					  '("E=" "N=" "Z=")
    					  pnt
    			  )
    	  )
    	  (setvar 'DIMZIN dim)
    	  (command "_.LEADER"
    			   "_none"
    			   pnt
    			   "\\"
    			   ""
    			   (nth (vl-position key '("NoZ" "All" "Z"))
    					(list (strcat a "\\P" b) (strcat a "\\P" b "\\P" c) c)
    			   )
    			   ""
    	  )
    	  (setq pnt (getpoint "\nSpecify base point : "))
        ) ; while
      )
    ;  (setvar 'clayer clr)
      (princ)
    )

  6. #6
    I could stop if I wanted to
    Join Date
    2011-09
    Posts
    308
    Login to Give a bone
    0

    Default Re: Display insertion point coordinates in decimal feet

    Hi gang, Thanks for all the suggestions.

    The DIMZIN setting is not doing anything. I think it's because UNITS in these files is set to Architectural Inches - which is what it should be... except for this one block that they want to report in decimal feet. I should have been clear about that.

    Here is the whole code which works fine except for the populating of the 2 attributes which is still in Feet and fractional inches.

    Screen Shot 2021-02-19 at 1.46.46 PM.png

    Code:
    (defun POTEST (/ DZ CRDX CRDY CRDXY CRDA CRDB P DZORIG SCL)
    (setvar 'ATTDIA 0)
    
    (setq CL (getvar "CLAYER"))
    
    (cond ((= (getvar "INSUNITS") 1) (setq SCL 1)(setq CRDA 3)(Setq CRDB 2))
          ((= (getvar "INSUNITS") 2) (setq SCL 0.08333)(setq CRDA 3)(Setq CRDB 2))
          ((= (getvar "INSUNITS") 4) (setq SCL 25.4)(setq CRDA 2)(Setq CRDB 2))
          ((= (getvar "INSUNITS") 5) (setq SCL 2.54)(setq CRDA 2)(Setq CRDB 2))
          ((= (getvar "INSUNITS") 6) (setq SCL 0.0254)(setq CRDA 2)(Setq CRDB 2))
          (t (alert "Current DWG set to non-standard units.  Check UNITS settings")(exit))
    )
    
    
    
    ;;;;; Bring in block Point Of Test from SCAPE Tags.dwg
    (defun open_dbx (dwg / dbx)
       (if (< (atoi (substr (getvar "ACADVER") 1 2)) 16)
          (setq dbx (vlax-create-object "ObjectDBX.AxDbDocument"))
          (setq dbx (vlax-create-object
          (strcat "ObjectDBX.AxDbDocument."
             (substr (getvar "ACADVER") 1 2)
             )
          )
       )
    )
    (vla-open dbx dwg)
    dbx
    )
    (setq Dbx (open_dbx "V:/AutoCAD 2018/Drawings/SCAPE Tags.dwg"))
    (vla-CopyObjects
    Dbx
    (vlax-safearray-fill
    (vlax-make-safearray vlax-vbObject '(0 . 0))
    (list (vla-item (vla-get-blocks dbx) "Point Of Test"))
    )
    (vla-get-blocks
    (vla-get-activedocument (vlax-get-acad-object))
    )
    )
    (vlax-release-object dbx)
    
    ;;;;; Insert and populate block
    
    (command "-layer" "Make" "0-Dims" "Color" "3" "0-Dims" "Ltype" "CONTINUOUS" "" "Plot" "P" "" "")
    (setvar "CLAYER" "0-dims")
    
    (setq dz (getvar 'DIMZIN))
    (setvar 'DIMZIN 0)
    
    (while (setq p (getpoint "\n Specify point :"))
    (setq CRDX (strcat "X: " (rtos (car p) CRDA CRDB)))
    (setq CRDY (strcat "Y: " (rtos (cadr p) CRDA CRDB)))
      (command "_.-insert"
    
               "Point Of Intersection Key r01"
               "Scale"
               SCL
               "_none"
    
               p
    
               ""
    
    ;           ""
    ;           ""
               CRDX
               CRDY
      )
    
    
    )
    
    (setvar "CLAYER" CL)
    (setvar 'DIMZIN dz)
    )

  7. #7
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Display insertion point coordinates in decimal feet

    Can you upload that drawing with the attributed block to check it out closely?

  8. #8
    I could stop if I wanted to
    Join Date
    2011-09
    Posts
    308
    Login to Give a bone
    0

    Default Re: Display insertion point coordinates in decimal feet

    OK, in an attempt to solve this I have written a small test routine:

    Code:
    (defun C:TEST (/ CRDX CRDXFEET P)
    
    (setq p (getpoint "\n Specify point :"))
    (setq CRDX (rtos (car p) 2 2))
    (setq CRDXFEET (/ CRDX 12))
    (alert CRDXFEET)
    
    )

    What it should do (I think) is ask to pick a point and then pop up a dialog box with the X value of that point in decimal feet (like 123.5')

    It does not. I get the error:

    "Specify point :; error: no function definition: "

    Now if I remove the line in red, it will report the value of x in decimal inches... like so:

    Code:
    (defun C:TEST (/ CRDX CRDXFEET P)
    
    (setq p (getpoint "\n Specify point :"))
    (setq CRDX (rtos (car p) 2 2))
    (alert CRDX)
    
    )
    Screen Shot 2021-03-01 at 3.10.49 PM.png

    What am I missing?

    Thanks all!!!

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

    Default Re: Display insertion point coordinates in decimal feet

    The line in red is attempting to do math on a string. AutoLISP is not able to do such a thing. The line before the red line is the cause of the string.

    Another question that may shed some light on this, what are the coordinates you have picked?

    What is the expected output?

    Answers to both of those questions may help others provide suggestions or solutions to your problem.
    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

  10. #10
    I could stop if I wanted to
    Join Date
    2011-09
    Posts
    308
    Login to Give a bone
    0

    Default Re: Display insertion point coordinates in decimal feet

    OK, so what Am I missing? I understand that AutoCAD can't do math on a string, so I guess I need the mathematical value of the X and Y coordinates.

    The drawings are UNITS=Inches but I have been tasked with making this block display those coordinates in decimal feet. Long story - I can't use fields

    So if I pick a point who's X coordinate is 150", I need to to display 12.50'

    I can get 150 easily enough, but how can I get a numeric value from the picked point so I can divide it by 12?

    Does that make sense? I know I'm missing something stupid, I've been away from lisp for a while...

Page 1 of 2 12 LastLast

Similar Threads

  1. Decimal feet for linear dimensions
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2006-06-07, 01:57 PM
  2. Replies: 2
    Last Post: 2006-01-31, 08:12 PM
  3. Decimal feet as linear dimension unit
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 4
    Last Post: 2005-10-06, 11:54 PM
  4. Decimal Feet as dimensioning unit
    By chuck_cantieny in forum AutoCAD Wish List
    Replies: 1
    Last Post: 2004-12-15, 04:59 PM
  5. Decimal Feet Display for Building Elevations?
    By Jason in forum Revit Architecture - General
    Replies: 2
    Last Post: 2003-08-25, 06:32 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
  •