Results 1 to 9 of 9

Thread: Polyline contour labeling in Civil 3D

  1. #1
    Member
    Join Date
    2008-07
    Posts
    2
    Login to Give a bone
    0

    Default Polyline contour labeling in Civil 3D

    I have been searching for a lisp routine or some other way to label the polyline contours in Civil 3D the way that Land Desktop did it. My company still uses user created polyline contours at elevation for begining of onsite grading and in strange situations were grading tools just can't produce the proper look, if anyone has a good way to do this besides old fashioned dtext on each line one at a time.

    Thanks

  2. #2
    I could stop if I wanted to
    Join Date
    2003-12
    Location
    Pittsburgh, PA
    Posts
    355
    Login to Give a bone
    0

    Default Re: Polyline contour labeling in Civil 3D

    here's one I use, feel free to modify and use
    Code:
    ;Label finish grade contour by LPS 2008
    
    (defun c:lc ()
    (vl-load-com)
    (defun rtd (a) (/ (* a 180.0) pi))
    
    (defun dxf(code elist)
    (cdr (assoc code elist))
    )
    (setq th (getvar "textsize")
             ts (getvar "textstyle")
             cl (getvar "clayer")
             os (getvar "osmode")
    )
    
    (setq ent (entsel "Pick contour to be labeled: ")
               p1 (vlax-curve-getclosestpointto (car ent) (cadr ent) )
               ed (entget (car ent))
    );setq
    
    (if (= (caddr p1) 0.0)
        (alert "Contour needs an elevation!!!")
          (progn
    
      (if (= (DXF 0 ED) "LWPOLYLINE")
    	(SETQ txt1 (rtos (DXF 38 ED)2 0))
    	(SETQ txt1 (rtos (CADDR (DXF 10 ED))2 0))
      )
    
    (setvar "osmode" 512)
    	(setq a1 (rtd(getangle "Specify angle of label: " p1)))
    
      	(setvar "clayer" "FG-CONT-ELEV")
    
    	(command "text" "s" "SIMPLEX" "M" P1 (* 0.1(GETVAR "DIMSCALE")) a1 txt1)
    
      	(setvar "textsize" th)
    	(setvar	"textstyle" ts)
    	(setvar	"clayer" cl)
                  (setvar "osmode" os)
    	
    	(PRINC)	
    );progn
    );if
    )
    Last edited by lpseifert; 2008-07-30 at 10:25 PM. Reason: added dxf function

  3. #3
    Member
    Join Date
    2008-07
    Posts
    2
    Login to Give a bone
    0

    Default Re: Polyline contour labeling in Civil 3D

    Thanks for the program, it does start, but as soon as i pick a contour it gives me an error

    Pick contour to be labeled: ; error: no function definition: DXF
    Command:

    unfortunately, i am not very good with the programming language and i am not sure want to change, and i did make sure it was a polyline with an elevation.

    Thanks

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

    Default Re: Polyline contour labeling in Civil 3D

    Quote Originally Posted by jwissler View Post
    Thanks for the program, it does start, but as soon as i pick a contour it gives me an error

    Pick contour to be labeled: ; error: no function definition: DXF
    Command:

    unfortunately, i am not very good with the programming language and i am not sure want to change, and i did make sure it was a polyline with an elevation.

    Thanks
    If I had to guess, this might be the function you are missing.
    Code:
    (defun DXF (ELEMENT ENTITY /) (cdr (assoc ELEMENT ENTITY)))
    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

  5. #5
    I could stop if I wanted to
    Join Date
    2003-12
    Location
    Pittsburgh, PA
    Posts
    355
    Login to Give a bone
    0

    Default Re: Polyline contour labeling in Civil 3D

    Oops, I have the DXF function in my acaddoc.lsp file and forgot to add it to the code I posted. Try it now...
    Opie had it right...
    I might add that the above code assumes there is a layer named FG-CONT-ELEV and a text style named SIMPLEX with a height of 0. Adjust to your needs.

  6. #6
    Member
    Join Date
    2000-12
    Posts
    27
    Login to Give a bone
    0

    Default Re: Polyline contour labeling in Civil 3D

    You could just come up with a General Line Segment Label that labels the Z elevation of the Start point and be sure the label snaps to the middle of the line and masks the contour.

    That is what we use for those situations.

    Matthew Anderson, PE
    Joseph A Schudt & Associates

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

    Default Re: Polyline contour labeling in Civil 3D

    This works for all the contours I encounter:
    Code:
     ; Annotate a Contour Line
    ; BY: Tom Beauford - 7/11/2005
    ; Tombu@LeonCountyFL.gov
    ; LEON COUNTY PUBLIC WORKS SURVEY & R/W SECTION
    ; (load "ContourAnnotate.lsp") ContourAnnotate 
    ;=============================================================
    (defun c:ContourAnnotate (/ mspace om osz e ent pt tblname Rot str mtextobj ent el)
      (setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
                om (getvar "osmode")
                osz (getvar "osnapz")
      )
      (setvar "osnapz" 0)
      (setvar "osmode" 512)
      (setq pt (getpoint"\nSelect point on Contour Line: ")
                e (nentselp pt) 
                ent (car e)
                pt (cadr e)
                tblname (car(ade_odgettables ent))
      )
      (setvar "osmode" 0)
      (setq Rot (getangle pt "\nPick or Enter angle..." )
                str (rtos (caddr pt) 2 0))
     
      (ade_errsetlevel 2) 
      (if(ade_odgettables ent)
        (cond
          ((ade_odgetfield ent (car(ade_odgettables ent)) "ELEV" 0)
          (setq str (itoa(ade_odgetfield ent (car(ade_odgettables ent)) "ELEV" 0))))
          ((ade_odgetfield ent (ade_odgettables ent) "ELEVATION" 0)
          (setq str (itoa(ade_odgetfield ent (ade_odgettables ent) "ELEVATION" 0))))
        )
       )
      (ade_errsetlevel 0) 
     
      (princ "\nElev = ")
      (princ str)
     
      (setq mtextobj (vla-addMText mspace (vlax-3d-point pt) 0.0 str))
      (vla-put-attachmentPoint mtextobj acAttachmentPointMiddleCenter)
      (vla-put-insertionPoint mtextobj (vlax-3d-point pt))
      (vla-put-Rotation mtextobj Rot)
      (vla-put-Color mtextobj 7)
      (vla-put-backgroundfill mtextobj :vlax-true); mask on with background color
      (setq el (entget (vlax-vla-object->ename mtextobj)))
      (setq el (subst (cons 45 1.15) (assoc 45 el) el)) ;Set MaskSize 1.15 × TextSize
      (entmod el)
      (setvar "osmode" om)
      (setvar "osnapz" osz) 
      (princ)
    )
    It works on ESRI contours brought in with Map as well.

  8. #8
    Active Member
    Join Date
    2007-09
    Location
    Croatia
    Posts
    55
    Login to Give a bone
    0

    Default Re: Polyline contour labeling in Civil 3D

    Quote Originally Posted by Opie View Post
    If I had to guess, this might be the function you are missing.
    Code:
    (defun DXF (ELEMENT ENTITY /) (cdr (assoc ELEMENT ENTITY)))
    Code:
    ;Label finish grade contour by LPS 2008
    (defun DXF (ELEMENT ENTITY /) (cdr (assoc ELEMENT ENTITY)))
    (defun c:lc ()
    (vl-load-com)
    (defun rtd (a) (/ (* a 180.0) pi))
    
    (defun dxf(code elist)
    (cdr (assoc code elist))
    )
    (setq th (getvar "textsize")
             ts (getvar "textstyle")
             cl (getvar "clayer")
             os (getvar "osmode")
    )
    
    (setq ent (entsel "Pick contour to be labeled: ")
               p1 (vlax-curve-getclosestpointto (car ent) (cadr ent) )
               ed (entget (car ent))
    );setq
    
    (if (= (caddr p1) 0.0)
        (alert "Contour needs an elevation!!!")
          (progn
    
      (if (= (DXF 0 ED) "LWPOLYLINE")
    	(SETQ txt1 (rtos (DXF 38 ED)2 0))
    	(SETQ txt1 (rtos (CADDR (DXF 10 ED))2 0))
      )
    
    (setvar "osmode" 512)
    	(setq a1 (rtd(getangle "Specify angle of label: " p1)))
    
      	(setvar "clayer" "FG-CONT-ELEV")
    
    	(command "text" "s" "SIMPLEX" "M" P1 (* 0.1(GETVAR "DIMSCALE")) a1 txt1)
    
      	(setvar "textsize" th)
    	(setvar	"textstyle" ts)
    	(setvar	"clayer" cl)
                  (setvar "osmode" os)
    	
    	(PRINC)	
    );progn
    );if
    )
    ---------------------------------------------------------------------------
    There is a new error:
    "command: LC Pick contour to be labeled: Specify angle of label: 30
    *Cancel*
    AutoCAD variable setting rejected: "clayer" "FG-CONT-ELEV" "
    Last edited by Opie; 2009-02-26 at 02:40 PM. Reason: [code] tags added

  9. #9
    Active Member
    Join Date
    2007-09
    Location
    Croatia
    Posts
    55
    Login to Give a bone
    0

    Default Re: Polyline contour labeling in Civil 3D

    Quote Originally Posted by marijan.marsic View Post
    ;Label finish grade contour by LPS 2008
    (defun DXF (ELEMENT ENTITY /) (cdr (assoc ELEMENT ENTITY)))
    (defun c:lc ()
    (vl-load-com)
    (defun rtd (a) (/ (* a 180.0) pi))

    (defun dxf(code elist)
    (cdr (assoc code elist))
    )
    (setq th (getvar "textsize")
    ts (getvar "textstyle")
    cl (getvar "clayer")
    os (getvar "osmode")
    )

    (setq ent (entsel "Pick contour to be labeled: ")
    p1 (vlax-curve-getclosestpointto (car ent) (cadr ent) )
    ed (entget (car ent))
    );setq

    (if (= (caddr p1) 0.0)
    (alert "Contour needs an elevation!!!")
    (progn

    (if (= (DXF 0 ED) "LWPOLYLINE")
    (SETQ txt1 (rtos (DXF 38 ED)2 0))
    (SETQ txt1 (rtos (CADDR (DXF 10 ED))2 0))
    )

    (setvar "osmode" 512)
    (setq a1 (rtd(getangle "Specify angle of label: " p1)))

    (setvar "clayer" "FG-CONT-ELEV")

    (command "text" "s" "SIMPLEX" "M" P1 (* 0.1(GETVAR "DIMSCALE")) a1 txt1)

    (setvar "textsize" th)
    (setvar "textstyle" ts)
    (setvar "clayer" cl)
    (setvar "osmode" os)

    (PRINC)
    );progn
    );if
    )

    ---------------------------------------------------------------------------
    There is a new error:
    "command: LC Pick contour to be labeled: Specify angle of label: 30
    *Cancel*
    AutoCAD variable setting rejected: "clayer" "FG-CONT-ELEV" "
    ------------------------------------------------------------------------------------------------------------------------
    By replacing this two rows;

    (setvar "clayer" "KOTIRANJE")

    (command "text" "s" "standard" "M" P1 (* 0.1(GETVAR "DIMSCALE")) a1 txt1)
    IT works!!

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. Contour Labeling Lisp
    By johnshar123xx in forum AutoLISP
    Replies: 11
    Last Post: 2017-03-03, 01:47 AM
  3. 2013: Contour Labeling not showing up
    By dkozanecki347793 in forum AutoCAD Civil 3D - General
    Replies: 2
    Last Post: 2012-12-21, 06:12 AM
  4. Contour Labeling
    By tim_newsome in forum AutoCAD Civil 3D - General
    Replies: 3
    Last Post: 2010-05-06, 03:06 AM
  5. Contour Labeling & Data Shortcuts
    By pat.pennington in forum AutoCAD Civil 3D - Surfaces
    Replies: 1
    Last Post: 2009-01-30, 03:40 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
  •