Jump to content

Recommended Posts

Posted

I was wondering if anyone knows of a program already written or how to right a simple program that will extract the elevation from a point and place the elevation in text over the node with the decimal point over the node of the point.

 

Any help would be appreciated.

  • Replies 66
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    23

  • CadProWannabe

    12

  • eldon

    8

  • wizman

    8

Top Posters In This Topic

Posted Images

Posted

Something along these lines?

 

(defun c:tpt (/ Make_Point Make_Text pt)

 (defun Make_Point (pt)
   (entmakex (list (cons 0 "POINT") (cons 10 pt))))

 (defun Make_Text (pt val)
   (entmakex (list (cons 0 "TEXT")
                   (cons 10 pt)
                   (cons 40 (getvar "TEXTSIZE"))
                   (cons 1 val)
                   (cons 72 1)
                   (cons 73 1)
                   (cons 11 pt))))

 (while (setq pt (getpoint "\nPick Point: "))
   (Make_Point (setq pt (trans pt 1 0)))
   (Make_Text pt (rtos (caddr pt))))

 (princ))

Posted

Lee-doesn't look like that would achieve "with the decimal point over the node of the point".

 

This issue has been hashed out before (different size text left & right of decimal).

Unless the location of the decimal with the text can be precisely known, you may have to create separate text items for the parts L & R of the decimal.

Posted

AutoCAD has always lacked a decimal justification.

 

Usually Hydrographic surveys benefit from the decimal justification (assuming the decimal point is a point and not a comma)

Posted
Lee-doesn't look like that would achieve "with the decimal point over the node of the point".

 

This issue has been hashed out before (different size text left & right of decimal).

Unless the location of the decimal with the text can be precisely known, you may have to create separate text items for the parts L & R of the decimal.

 

True, I just used Bottom Center Justification :)

Posted

what's the use of decimal justification?, here's an approximation:

 


(defun c:tpt (/ Make_Point Make_Text pt)
(setvar 'dimzin 0)
 (defun Make_Point (pt)
   (entmakex (list (cons 0 "POINT") (cons 10 pt))))

 (defun Make_Text (pt val)
   (setq pt1 (polar pt (* (/ 16.  180.) pi) (* (getvar 'textsize) 3.6099)))
   (entmakeX
           (list '(0 . "MTEXT")
                 '(100 . "AcDbEntity")
                 '(100 . "AcDbMText")
                 '(71 . 3)
                 '(8 . "0")
                 (list 10 (car pt1) (cadr pt1)(caddr pt))
                 (cons 40  (getvar 'textsize));
                 (cons 1
                   (strcat
                     "{\\fCourier New|b0|i0|c0|p49;"
                     val
                     "}"
                   ) 
                 ) 
           )
             ))

 (while (setq pt (getpoint "\nPick Point: "))
   ;(Make_Point (setq pt (trans pt 1 0)))
   (Make_Text pt (rtos (caddr pt) 2 3)))

 (princ))

Posted
what's the use of decimal justification?, here's an approximation:

 

(defun c:tpt (/ Make_Point Make_Text pt)

 (defun Make_Point (pt)
   (entmakex (list (cons 0 "POINT") (cons 10 pt))))

 (defun Make_Text (pt val)
   (setq pt1 (polar pt (* (/ 16.  180.) pi) (* (getvar 'textsize) 3.6099)))
   (entmakeX
           (list '(0 . "MTEXT")
                 '(100 . "AcDbEntity")
                 '(100 . "AcDbMText")
                 '(71 . 3)
                 '(8 . "0")
                 (list 10 (car pt1) (cadr pt1))
                 (cons 40  (getvar 'textsize));
                 (cons 1
                   (strcat
                     "{\\fCourier New|b0|i0|c0|p49;"
                     val
                     "}"
                   ) 
                 ) 
           )
             ))

 (while (setq pt (getpoint "\nPick Point: "))
   ;(Make_Point (setq pt (trans pt 1 0)))
   (Make_Text pt (rtos (caddr pt) 2 3)))

 (princ))

 

This tilts when I try to run it..

error as follows...

Command: appload

tpt.lsp successfully loaded.

 

Command: ; error: bad argument type: numberp: nil

Posted

Stevesfr, I'm not getting the error here, i modified it slightly, please try again, it's not the exact position but the closest i can get from modifying lee's code but i'm still recommending the text insertion point to be on the point and not on the decimal point.

Posted
what's the use of decimal justification?

 

You have obviously not experienced a hydrographic survey, where it would be very useful.

 

However your code is ingenious, but should be qualified by saying that it is limited to working with three decimal places, and with font Courier New.

 

But it could be amended to working with a different number of decimal places, and different fonts by those who want something different.

Posted

No Eldon, never worked on hydrographic survey, is that same with bathymetric? anyway, i'll just google it. You're right that it can be modified to different number of decimal places but only with right justifications and applicable only to monospaced fonts.

Posted
You have obviously not experienced a hydrographic survey, ...

 

That's encouraging...

 

 

 

I pass. :geek:

Posted

I pass. :geek:

 

I think you are muddling it up with a sewer survey, especially in accordance with your motion.

Posted

This may take us half-way there...

 

(defun c:tpt (/ Make_Point Make_Text pt BoxNum BoxHgt BoxWid)
 
(setvar 'dimzin 0)
 
 (defun Make_Point (pt)
   (entmakex (list (cons 0 "POINT") (cons 10 pt))))

 (defun Make_Text (pt val)

   (setq pt1 (polar pt (atan BoxHgt (* BoxNum BoxWid))
                    (sqrt (+ (expt (* BoxNum BoxWid) 2)
                             (expt BoxHgt 2)))))
   
   (entmakex (list (cons 0 "MTEXT")
                   (cons 100 "AcDbEntity")
                   (cons 100 "AcDbMText")
                   (cons 71 3)
                   (list 10 (car pt1) (cadr pt1) (caddr pt))
                   (cons 40 (getvar 'TEXTSIZE))
                   (cons 1
                     (strcat "{\\fCourier New|b0|i0|c0|p49;" val "}")))))

 (setq BoxNum (+ 0.5 (getvar 'LUPREC))
       BoxHgt (getvar 'TEXTSIZE)
       BoxWid (* (expt 1.00272389 (getvar 'LUPREC)) (getvar 'TEXTSIZE)))

 (while (setq pt (getpoint "\nPick Point: "))
   ;(Make_Point (setq pt (trans pt 1 0)))
   (Make_Text pt (rtos (caddr pt))))

 (princ))

Posted

I'll give a test run lee, i hardcoded it earlier because putting each letter in boxes seems to miss though its a monospaced font, but we'll see.

Posted

May be getting there Lee (but not the bullseye),

 

Looks fine, good job on handling any number of decimals, just maybe a little adjustment on

(+ 0.5 (getvar 'LUPREC))

 

too tired to think now, be back at it tom.

Posted

I updated the above code, with a small refinement, but still not bullseye. :(

Posted

If it is for a Hydrographic/ Bathymetric survey, then the plan postion of the soundings is usually to the nearest metre, so it should be more than adequate as it stands. But do not change the size of text later. (this is where a decimal justification would be useful)

 

Bathymetric surveys are about only measuring depths whereas Hydrographic surveys are about mapping and other things including measuring depths.

Posted

This illustrates the problem with using a method of "boxing" the text:

 

ex.jpg

 

TheGreen Boxes are those obtained using the geometric extents of the symbol in the text, and the Magenta lines are 1.0 x 1.0 squares, with X-Coordinate centered using the Green boxes.

 

The Textsize is 1.0

 

Notice that there are uneven spaces between the characters, making it difficult to get an exact distance to the decimal point.

 

Lee

 

 

Posted

This illustrates the problem with using a method of "boxing" the text:

 

[ATTACH]16702[/ATTACH]

 

TheGreen Boxes are those obtained using the geometric extents of the symbol in the text, and the Magenta lines are 1.0 x 1.0 squares, with X-Coordinate centered using the Green boxes.

 

The Textsize is 1.0

 

Notice that there are uneven spaces between the characters, making it difficult to get an exact distance to the decimal point.

 

Lee

 

 

 

Lee,

 

You can always force to true monospaced font. -David

Posted

Great idea David! I'd got hooked on Courier New...

 

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:tpt [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] Make_Point Make_Text pt BoxNum BoxHgt BoxWid[b][color=RED])[/color][/b]
 [i][color=#990099];; Lee Mac, David Bethel & Wizman  ~  10.01.10 (= 38)[/color][/i]
 
[b][color=RED]([/color][/b][b][color=BLUE]setvar[/color][/b] [b][color=DARKRED]'[/color][/b]dimzin [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b]
 
 [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] Make_Point [b][color=RED]([/color][/b]pt[b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]entmakex[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]0[/color][/b] [b][color=#a52a2a]"POINT"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]10[/color][/b] pt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] Make_Text [b][color=RED]([/color][/b]pt val[b][color=RED])[/color][/b]

   [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] pt1 [b][color=RED]([/color][/b][b][color=BLUE]polar[/color][/b] pt [b][color=RED]([/color][/b][b][color=BLUE]atan[/color][/b] BoxHgt   [b][color=RED]([/color][/b][b][color=BLUE]*[/color][/b] BoxNum BoxWid[b][color=RED])[/color][/b][b][color=RED])[/color][/b] 
                       [b][color=RED]([/color][/b][b][color=BLUE]sqrt[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]+[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]expt[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]*[/color][/b] BoxNum BoxWid[b][color=RED])[/color][/b] [b][color=#009900]2[/color][/b][b][color=RED])[/color][/b]
                                [b][color=RED]([/color][/b][b][color=BLUE]expt[/color][/b] BoxHgt [b][color=#009900]2[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   
   [b][color=RED]([/color][/b][b][color=BLUE]entmakex[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]0[/color][/b]   [b][color=#a52a2a]"MTEXT"[/color][/b][b][color=RED])[/color][/b]
                   [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]100[/color][/b] [b][color=#a52a2a]"AcDbEntity"[/color][/b][b][color=RED])[/color][/b]
                   [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]100[/color][/b] [b][color=#a52a2a]"AcDbMText"[/color][/b][b][color=RED])[/color][/b]
                   [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]71[/color][/b] [b][color=#009900]3[/color][/b][b][color=RED])[/color][/b]
                   [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=#009900]10[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] pt1[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cadr[/color][/b] pt1[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]caddr[/color][/b] pt[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
                   [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]40[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]getvar[/color][/b] [b][color=DARKRED]'[/color][/b]TEXTSIZE[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
                   [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]1[/color][/b]  [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#a52a2a]"{\\fMonospac821 BT|b0|i0|c0|p49;"[/color][/b] val [b][color=#a52a2a]"}"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] BoxNum [b][color=RED]([/color][/b][b][color=BLUE]+[/color][/b] [b][color=#009999]0.412636[/color][/b]   [b][color=RED]([/color][/b][b][color=BLUE]getvar[/color][/b] [b][color=DARKRED]'[/color][/b]LUPREC[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
       BoxHgt [b][color=RED]([/color][/b][b][color=BLUE]*[/color][/b] [b][color=#009999]0.892748[/color][/b]   [b][color=RED]([/color][/b][b][color=BLUE]getvar[/color][/b] [b][color=DARKRED]'[/color][/b]TEXTSIZE[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
       BoxWid [b][color=RED]([/color][/b][b][color=BLUE]*[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] [b][color=#009900]13[/color][/b] [b][color=#009999]15.[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]getvar[/color][/b] [b][color=DARKRED]'[/color][/b]TEXTSIZE[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]while[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] pt [b][color=RED]([/color][/b][b][color=BLUE]getpoint[/color][/b] [b][color=#a52a2a]"\nPick Point: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [i][color=#990099];(Make_Point (setq pt (trans pt 1 0)))[/color][/i]
   [b][color=RED]([/color][/b]Make_Text pt [b][color=RED]([/color][/b][b][color=BLUE]rtos[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]caddr[/color][/b] pt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...