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

Thread: Contour elevation labelling..........help

  1. #1
    Member
    Join Date
    2011-10
    Posts
    40
    Login to Give a bone
    0

    Wink Contour elevation labelling..........help

    hello all,

    i wrote below piece of code for labelling elevation to contour(Polyline). it works but it labels at end of contour. what i want is to label in middle of contour with proper aligning text label . can anybody modified it for me..?

    Code:
     
     
    (defun c:qq()
    (setq ss (ssget'((0 . "LWPOLYLINE"))))
    (setq sslngth (sslength ss))
    (Setq idx 0)
    (repeat sslngth
      (setq ename (ssname ss (setq sslngth (1- sslngth))))
       (setq edata (entget ename))
       (setq xy (cdr (Assoc 38 edata)))
       (setq xy1(cdr (Assoc 10 edata)))
      (setq xx(rtos xy 2 0))
      (command "text" xy1 10 30 xx "")
    )
    )
    sample dwg attached ..........!
    Attached Files Attached Files

  2. #2
    I could stop if I wanted to
    Join Date
    2002-08
    Posts
    231
    Login to Give a bone
    0

    Default Re: Contour elevation labelling..........help

    Hello,

    You can use also the dynamic fields !

    Code:
    (vl-load-com)
    (defun c:Label_Side_Elevation ( / js htx AcDoc Space nw_style n obj ename pr pt deriv rtx nw_obj)
    	(princ "\nSelect polylines: ")
    	(setq js
    		(ssget
    			(list
    				'(0 . "LWPOLYLINE")
    				(cons 67 (if (eq (getvar "CVPORT") 1) 1 0))
    				(cons 410 (if (eq (getvar "CVPORT") 1) (getvar "CTAB") "Model"))
    			)
    		)
    	)
    	(cond
    		(js
    			(initget 6)
    			(setq htx (getdist (getvar "VIEWCTR") (strcat "\nSpecify text height <" (rtos (getvar "TEXTSIZE")) ">: ")))
    			(if htx (setvar "TEXTSIZE" htx))
    			(setq
    				AcDoc (vla-get-ActiveDocument (vlax-get-acad-object))
    				Space
    				(if (= 1 (getvar "CVPORT"))
    					(vla-get-PaperSpace AcDoc)
    					(vla-get-ModelSpace AcDoc)
    				)
    			)
    			(cond
    				((null (tblsearch "LAYER" "Label Elevation"))
    					(vlax-put (vla-add (vla-get-layers AcDoc) "Label Elevation") 'color 96)
    				)
    			)
    			(cond
    				((null (tblsearch "STYLE" "Romand-Label"))
    					(setq nw_style (vla-add (vla-get-textstyles AcDoc) "Romand-Label"))
    					(mapcar
    						'(lambda (pr val)
    							(vlax-put nw_style pr val)
    						)
    						(list 'FontFile 'Height 'ObliqueAngle 'Width 'TextGenerationFlag)
    						(list "romand.shx" 0.0 (/ (* 15.0 pi) 180) 1.0 0.0)
    					)
    				)
    			)
    			(repeat (setq n (sslength js))
    				(setq
    					obj (ssname js (setq n (1- n)))
    					ename (vlax-ename->vla-object obj)
    					pt (vlax-curve-GetpointAtParam ename (setq pr (* 0.5 (vlax-curve-getEndParam ename))))
    					deriv (vlax-curve-getFirstDeriv ename pr)
    					rtx (- (atan (cadr deriv) (car deriv)) (angle '(0 0 0) (getvar "UCSXDIR")))
    				)
    				(if (or (> rtx (* pi 0.5)) (< rtx (- (* pi 0.5)))) (setq rtx (+ rtx pi)))
    				(setq nw_obj
    					(vla-addMtext Space
    						(vlax-3d-point (setq pt (polar pt (+ rtx (* pi 0.5)) (getvar "TEXTSIZE"))))
    						0.0
    						(strcat
    							"%<\\AcObjProp Object(%<\\_ObjId "
    							(itoa (vla-get-ObjectID (vlax-ename->vla-object obj)))
    							">%).Elevation \\f \"%lu2%pr0\">%"
    						)
    					)
    				)
    				(mapcar
    					'(lambda (pr val)
    						(vlax-put nw_obj pr val)
    					)
    					(list 'AttachmentPoint 'Height 'DrawingDirection 'InsertionPoint 'StyleName 'Layer 'Rotation)
    					(list 5 (getvar "TEXTSIZE") 5 pt "Romand-Label" "Label Elevation" rtx)
    				)
    			)
    		)
    	)
    	(prin1)
    )

  3. #3
    Member
    Join Date
    2011-10
    Posts
    40
    Login to Give a bone
    0

    Default Re: Contour elevation labelling..........help

    ya, it works great ! but it highlights that value in closed filled color. that what i dont want..only value with Arial font.

    and one more think if you know anyother alternatives to do the same. let me know plzz..






    Quote Originally Posted by Bruno.Valsecchi View Post
    Hello,

    You can use also the dynamic fields !

    Code:
    (vl-load-com)
    (defun c:Label_Side_Elevation ( / js htx AcDoc Space nw_style n obj ename pr pt deriv rtx nw_obj)
        (princ "\nSelect polylines: ")
        (setq js
            (ssget
                (list
                    '(0 . "LWPOLYLINE")
                    (cons 67 (if (eq (getvar "CVPORT") 1) 1 0))
                    (cons 410 (if (eq (getvar "CVPORT") 1) (getvar "CTAB") "Model"))
                )
            )
        )
        (cond
            (js
                (initget 6)
                (setq htx (getdist (getvar "VIEWCTR") (strcat "\nSpecify text height <" (rtos (getvar "TEXTSIZE")) ">: ")))
                (if htx (setvar "TEXTSIZE" htx))
                (setq
                    AcDoc (vla-get-ActiveDocument (vlax-get-acad-object))
                    Space
                    (if (= 1 (getvar "CVPORT"))
                        (vla-get-PaperSpace AcDoc)
                        (vla-get-ModelSpace AcDoc)
                    )
                )
                (cond
                    ((null (tblsearch "LAYER" "Label Elevation"))
                        (vlax-put (vla-add (vla-get-layers AcDoc) "Label Elevation") 'color 96)
                    )
                )
                (cond
                    ((null (tblsearch "STYLE" "Romand-Label"))
                        (setq nw_style (vla-add (vla-get-textstyles AcDoc) "Romand-Label"))
                        (mapcar
                            '(lambda (pr val)
                                (vlax-put nw_style pr val)
                            )
                            (list 'FontFile 'Height 'ObliqueAngle 'Width 'TextGenerationFlag)
                            (list "romand.shx" 0.0 (/ (* 15.0 pi) 180) 1.0 0.0)
                        )
                    )
                )
                (repeat (setq n (sslength js))
                    (setq
                        obj (ssname js (setq n (1- n)))
                        ename (vlax-ename->vla-object obj)
                        pt (vlax-curve-GetpointAtParam ename (setq pr (* 0.5 (vlax-curve-getEndParam ename))))
                        deriv (vlax-curve-getFirstDeriv ename pr)
                        rtx (- (atan (cadr deriv) (car deriv)) (angle '(0 0 0) (getvar "UCSXDIR")))
                    )
                    (if (or (> rtx (* pi 0.5)) (< rtx (- (* pi 0.5)))) (setq rtx (+ rtx pi)))
                    (setq nw_obj
                        (vla-addMtext Space
                            (vlax-3d-point (setq pt (polar pt (+ rtx (* pi 0.5)) (getvar "TEXTSIZE"))))
                            0.0
                            (strcat
                                "%<\\AcObjProp Object(%<\\_ObjId "
                                (itoa (vla-get-ObjectID (vlax-ename->vla-object obj)))
                                ">%).Elevation \\f \"%lu2%pr0\">%"
                            )
                        )
                    )
                    (mapcar
                        '(lambda (pr val)
                            (vlax-put nw_obj pr val)
                        )
                        (list 'AttachmentPoint 'Height 'DrawingDirection 'InsertionPoint 'StyleName 'Layer 'Rotation)
                        (list 5 (getvar "TEXTSIZE") 5 pt "Romand-Label" "Label Elevation" rtx)
                    )
                )
            )
        )
        (prin1)
    )

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

    Default Re: Contour elevation labelling..........help

    Try ContourAnnotate.lsp. It works on your attached drawing or any Map data or polylines with elevations. It places the text right-side up even in twisted views. It uses the current Text Style and Size and places the text on the same layer as the contour so it turns off with the layer. Give it a try.

  5. #5
    Certifiable AUGI Addict ccowgill's Avatar
    Join Date
    2004-08
    Location
    Iron Station, NC
    Posts
    3,198
    Login to Give a bone
    0

    Default Re: Contour elevation labelling..........help

    Quote Originally Posted by sanrajbhar677632 View Post
    ya, it works great ! but it highlights that value in closed filled color.
    what if you set FIELDDISPLAY to 0?

  6. #6
    I could stop if I wanted to
    Join Date
    2002-08
    Posts
    231
    Login to Give a bone
    0

    Default Re: Contour elevation labelling..........help

    only value with Arial font
    Two way possible, define a new style with arial or force in Mtext the style with the good font

    highlights that value in closed filled color
    Same answer that ccowgill FIELDDISPLAY

    With font forced in Mtext

    Code:
    (vl-load-com)
    (defun c:Label_Side_Elevation ( / js htx AcDoc Space n obj ename pr pt deriv rtx nw_obj)
      (princ "\nSelect polylines: ")
      (setq js
        (ssget
          (list
            '(0 . "LWPOLYLINE")
            (cons 67 (if (eq (getvar "CVPORT") 1) 1 0))
            (cons 410 (if (eq (getvar "CVPORT") 1) (getvar "CTAB") "Model"))
          )
        )
      )
      (cond
        (js
          (initget 6)
          (setq htx (getdist (getvar "VIEWCTR") (strcat "\nSpecify text height <" (rtos (getvar "TEXTSIZE")) ">: ")))
          (if htx (setvar "TEXTSIZE" htx))
          (setq
            AcDoc (vla-get-ActiveDocument (vlax-get-acad-object))
            Space
            (if (= 1 (getvar "CVPORT"))
              (vla-get-PaperSpace AcDoc)
              (vla-get-ModelSpace AcDoc)
            )
          )
          (cond
            ((null (tblsearch "LAYER" "Label Elevation"))
              (vlax-put (vla-add (vla-get-layers AcDoc) "Label Elevation") 'color 96)
            )
          )
          (repeat (setq n (sslength js))
            (setq
              obj (ssname js (setq n (1- n)))
              ename (vlax-ename->vla-object obj)
              pr (* 0.5 (vlax-curve-getEndParam ename))
              pt (vlax-curve-GetpointAtParam ename pr)
              deriv (vlax-curve-getFirstDeriv ename pr)
              rtx (- (atan (cadr deriv) (car deriv)) (angle '(0 0 0) (getvar "UCSXDIR")))
            )
            (if (or (> rtx (* pi 0.5)) (< rtx (- (* pi 0.5)))) (setq rtx (+ rtx pi)))
            (setq nw_obj
              (vla-addMtext Space
                (vlax-3d-point (setq pt (polar pt (+ rtx (* pi 0.5)) (getvar "TEXTSIZE"))))
                0.0
                (strcat
                  "{\\fArial|b0|i0|c0|p34;"
                  "%<\\AcObjProp Object(%<\\_ObjId "
                  (itoa (vla-get-ObjectID (vlax-ename->vla-object obj)))
                  ">%).Elevation \\f \"%lu2%pr0\">%"
                )
              )
            )
            (mapcar
              '(lambda (pr val)
                (vlax-put nw_obj pr val)
              )
              (list 'AttachmentPoint 'Height 'DrawingDirection 'InsertionPoint 'StyleName 'Layer 'Rotation 'BackgroundFill)
              (list 5 (getvar "TEXTSIZE") 5 pt "Standard" "Label Elevation" rtx 0)
            )
          )
        )
      )
      (prin1)
    )

  7. #7
    Active Member
    Join Date
    2015-08
    Posts
    59
    Login to Give a bone
    0

    Default Re: Contour elevation labelling..........help

    Quote Originally Posted by Tom Beauford View Post
    Try ContourAnnotate.lsp. It works on your attached drawing or any Map data or polylines with elevations. It places the text right-side up even in twisted views. It uses the current Text Style and Size and places the text on the same layer as the contour so it turns off with the layer. Give it a try.
    gave it a try.... don't work.. bunch of stuff in the program that is or is not needed for simple contour labeling.
    i.e. load tcasesup.lsp ??????
    Steve

  8. #8
    I could stop if I wanted to
    Join Date
    2002-08
    Posts
    231
    Login to Give a bone
    0

    Default Re: Contour elevation labelling..........help

    For Object Data, i make this if you want try.
    I know bug with tag OD if special character
    Attached Files Attached Files

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

    Default Re: Contour elevation labelling..........help

    Quote Originally Posted by steveo View Post
    gave it a try.... don't work.. bunch of stuff in the program that is or is not needed for simple contour labeling.
    i.e. load tcasesup.lsp ??????
    Steve
    Sorry, try adding
    Code:
     (vl-load-com)
    to the start of the routine. It's required to be loaded for using any visual lisp. Most who use it a lot have it loaded automaticly. I don't add it to my routines. There is extra labeling stuff in there. I forget sometimes that not everyone installs the free Express Tools that come with AutoCAD. If you don't have it just remark it out, it's not used for the contour elevations anyway. I use the Express Tool tcase for labeling things like street names which in our GIS are all capitalized.

  10. #10
    Active Member
    Join Date
    2015-08
    Posts
    59
    Login to Give a bone
    0

    Default Re: Contour elevation labelling..........help

    Quote Originally Posted by Tom Beauford View Post
    Sorry, try adding
    Code:
     (vl-load-com)
    to the start of the routine. It's required to be loaded for using any visual lisp. Most who use it a lot have it loaded automaticly. I don't add it to my routines. There is extra labeling stuff in there. I forget sometimes that not everyone installs the free Express Tools that come with AutoCAD. If you don't have it just remark it out, it's not used for the contour elevations anyway. I use the Express Tool tcase for labeling things like street names which in our GIS are all capitalized.
    Tom... now I get the following error...
    Select point on Contour Line or Street Segment:
    Error: no function definition: ADE_ODGETTABLES

    vl-load-com added ok and I have express tools ok in Acad2008 thanks for reply.
    Steve

Page 1 of 2 12 LastLast

Similar Threads

  1. Help With Contour Labeling Elevation Precision
    By aspencer.226869 in forum AutoCAD Civil 3D - General
    Replies: 4
    Last Post: 2018-07-17, 01:44 PM
  2. Extract a User Specified contour elevation from a surface
    By Wish List System in forum Civil 3D Wish List
    Replies: 7
    Last Post: 2015-10-08, 09:33 PM
  3. Contour labels all reading the same elevation?
    By patricks in forum Revit Architecture - General
    Replies: 2
    Last Post: 2008-03-18, 05:43 PM
  4. Looking for GIS elevation contour data.
    By bmonk in forum AutoCAD Map 3D - General
    Replies: 1
    Last Post: 2007-07-20, 12:14 PM
  5. Labelling contour lines and spot elevations in AutoCAD 2007
    By bh.mccarthy in forum AutoCAD General
    Replies: 8
    Last Post: 2007-04-11, 03:58 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
  •