Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Contour Labeling Routine

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
1115 Views, 2 Replies

Contour Labeling Routine

I need a routine that one can select a fence or a path along a whole lot of
contours which are not in 3DPoly but rather a heavyweight POLYLINE and then
have the Z value (elevation of this polyline) printed over the contour
preferably along the direction of the vertex picked.

I have something right now that works by selecting individual plines but I
need one you can select a whole lot and have the text inserted at the
correct position.

See my simple code below:
;THIS IS FOR LABELLING 3D CONTOURS
(defun C:3DC ()
(graphscr)
(setq p (entsel "\nSelect CONTOUR to label: "))
(setq e (entget (car p)))
(setq e1 (entget (entnext (cdr (assoc -1 e)))))
(setq x1 (cadr (assoc 10 e1)))
(setq y1 (caddr (assoc 10 e1)))
(setq z1 (cadddr (assoc 10 e1)))
(command ".text" "M" pause "" "" (rtos z1 2 2))
(command ".change" (entlast) "" "@" "" "" pause "")
(COMMAND ".MOVE" (entlast) "" "@")

(princ)
);defun


If anyone can help improve this or have new lisp I would much appreciate it.
Andreas
2 REPLIES 2
Message 2 of 3
jimmy.dhondt
in reply to: Anonymous

Had some time to spare today and it seemed like a nice challenge, so here it is (no error cheching or anything, not even sure if this is what you want, feel free to modify and improve).

(defun R->D (Rads)
(* 180.0 (/ Rads pi))
)
;
(defun CreateFence ( / PointPicked P1)
(setq FencePointsList nil)
(setq PointPicked (getpoint "\nSelect First Fence point.."))
(setq P1 PointPicked)
(setq FencePointsList (append FencePointsList (list PointPicked)))
(while (/= PointPicked nil)
(setq PointPicked (getpoint PointPicked"\nSelect Following Fence point.."))
(if (/= PointPicked nil)(progn
(setq FencePointsList (append FencePointsList (list PointPicked)))
(grdraw P1 PointPicked 6 3)
(setq P1 PointPicked)
)
)
)
(princ)
);end CreateFence
;
(defun CheckInterSect ()
(setq OldOsmode (getvar "OSMODE"))
(setvar "OSMODE" 0)
(if (= (getvar "DIMSCALE") 0)(setvar "DIMSCALE" 1))
(setq TxtHeight (* (getvar "DIMSCALE") 3.5))
(setq Cnt 0)
(setq Ent (ssget "_F" FencePointsList '((0 . "LINE,POLYLINE,LWPOLYLINE"))))
(while (/= (ssname Ent Cnt) nil)
(progn
(setq CntA 0)
(setq StartPoly (list (cadr (assoc 10 (entget (ssname Ent Cnt))))(caddr (assoc 10 (entget (ssname Ent Cnt))))))
(setq EndPoly (list (cadr (assoc 11 (entget (ssname Ent Cnt))))(caddr (assoc 11 (entget (ssname Ent Cnt))))))
(setq StartPolyZ (cadddr (assoc 10 (entget (ssname Ent Cnt)))))
(setq EndPolyZ (cadddr (assoc 11 (entget (ssname Ent Cnt)))))
(while (/= (nth cntA FencePointslist) nil)
(progn
(setq StartFence (list (car (nth CntA FencePointslist))(cadr (nth CntA FencePointslist))))
(setq CntA (+ CntA 1))
(if (/= (nth CntA FencePointslist) nil)
(progn
(setq EndFence (list (car (nth CntA FencePointslist))(cadr (nth CntA FencePointslist))))
(if (/= (inters StartPoly EndPoly StartFence EndFence) nil)
(progn
(setq TxtAngle (R->D (angle StartPoly EndPoly)))
(setq TxtPoint (inters StartPoly EndPoly StartFence EndFence))
(command ".text" "M" TxtPoint TxtHeight TxtAngle (rtos StartPolyZ 2 2))
);end progn
);end if
);end progn
);end if
);end progn
);end while
(setq Cnt (+ Cnt 1))
);end progn
);end while
(setvar "OSMODE" OldOsmode)
);end defun CheckInterSect
;
(defun c:PolyLineHeight ()
(CreateFence)
(CheckInterSect)
(command "_redraw")
(princ)
)


Kind regards,

Jimmy
Message 3 of 3
heriegis99
in reply to: jimmy.dhondt

Hi all,

 

kindly to share about how to contour labeling, which same as labeling contour function in autocad land development. at autocad LD we can define position of label using crossline over the contour polylines, then automatically appear label of contour. if someone have the LISP it would be nice.

 

FYI I using Autocad Civil 3D 2012

 

Regards,

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost