i want to mark polyline curves on horizontal lines by using lisp

i want to mark polyline curves on horizontal lines by using lisp

nilesh.bhosale
Advocate Advocate
1,220 Views
8 Replies
Message 1 of 9

i want to mark polyline curves on horizontal lines by using lisp

nilesh.bhosale
Advocate
Advocate

I have a task to mark polyline curves horizontally by selecting the polyline it should automatically draw the horizontal 

line on which all the curves shall be mark on it 

SAMPLE DRAWING ATTACHED FOR UNDERSTAING

0 Likes
Accepted solutions (1)
1,221 Views
8 Replies
Replies (8)
Message 2 of 9

Kent1Cooper
Consultant
Consultant

If your indication of curve numbers within the string of dimensions is just to illustrate for us, and you don't really need them called out separately, you can use >StretchPolylinesStraight.lsp< and then just use the QDIM command on the resulting straightened-out Polyline.  It preserves the vertex locations along the result if that's desirable, unlike your example of a single Line object.

Kent1Cooper_0-1641907261959.png

[I pulled the dimension-line location up a little on two very short ones, but otherwise QDIM handled them all.]

 

Would they always be strictly alternating between line and arc segments, with line segments at both ends?  If so, it might not be hard to throw something in to call out which straight Dimensions represent curves.

Kent Cooper, AIA
0 Likes
Message 3 of 9

Kent1Cooper
Consultant
Consultant

And another question:  What determines the height of the "rectangles" [only three-sided] along the portions representing the arc segments, and why is the one for Curve No-7 different in height from the rest?

Kent Cooper, AIA
0 Likes
Message 4 of 9

nilesh.bhosale
Advocate
Advocate

please refer bellow attached drawing 

rectangle height can be taken in such way that it should not higher than the curve length, rectangle height is  not major concern here.

all the rectangles should be with same height

 

0 Likes
Message 5 of 9

devitg
Advisor
Advisor

@nilesh.bhosale 

could it be so? 

 

 

0 Likes
Message 6 of 9

nilesh.bhosale
Advocate
Advocate

YES Sir,

this is what i need can you share its lisp codes ??

 

 

 

0 Likes
Message 7 of 9

hak_vz
Advisor
Advisor
Accepted solution

Here you have lisp code that creates horizontal polyline whose length equals to total length of the road. After you enter rectangle height (for curve segments) and pick road polyline it ask you to pick a point where you want your diagram created and it creates rectangles for curved segments at distance from road poly start point. If you need it in opposinte direction mirror the diagram. For counting curves place dummy text (let say xxx) and use express tools command TCOUNT for counting, option override with prefix let say "#-". I didn't put text creation in the code since you may have trouble working with mirrored text.

 

(defun c:prel (/ *error* adoc take pointlist2d pick_poly rh eo coords bulge_list dist_list i total_lenght p1 p2 cnt sum_dist old);
  (defun *error* (msg)
    (and
      msg
      (not (wcmatch (strcase msg) "*CANCEL*,*QUIT*,*BREAK*,*EXIT*"))
      (princ (strcat "\nError: " msg))
    )
    (setvar 'osmode old)
	(setvar 'cmdecho 1)
    (princ)
    )
	(defun take (amount lst / ret)(repeat amount (setq ret (cons (car lst) (take (1- amount) (cdr lst))))))	
	(defun pointlist2d (lst / ret) (while lst (setq	ret (cons (take 2 lst) ret) lst (cddr lst))) (reverse ret))
	(defun pick_poly (msg)
		(setq e (car(entsel msg)))
		(if (and (not e) (= (getvar 'Errno) 7)) (pick_poly msg) e)
	)
	(setq acdoc (vla-get-activedocument (vlax-get-acad-object)))
    (vla-startundomark acdoc)
	(setq rh (getreal "\nEnter rectangle height >"))
	(setq eo (vlax-ename->vla-object (pick_poly "\nSelect road curve > ")))
	(setq bulge_list nil dist_list nil)
	(setq coords (pointlist2d(vlax-get eo 'coordinates)))
	(setq total_lenght (vla-get-length eo))
	(setq i -1)
	(while (< (setq i (1+ i))(1- (length coords)))
	(setq bulge_list (cons (vla-getbulge eo i) bulge_list))
	(setq dist_list (cons (- (vlax-curve-getDistAtPoint eo (nth (1+ i) coords))(vlax-curve-getDistAtPoint eo (nth i coords))) dist_list))
	)
	(setq dist_list (reverse dist_list) bulge_list (reverse bulge_list))
	(setq p1 (getpoint "\nSelect point >"))
	(setq p2 (polar p1 0 total_lenght))
	(entmakex
		(apply 'append
			(cons
			  (list
				'(0 . "LWPOLYLINE")
				'(100 . "AcDbEntity")
				'(100 . "AcDbPolyline")
				'(410 . "Model")
				'(38 . 0)
				'(67 . 0)
				'(70 . 0)
				(cons 90 2)
			  )
			  (mapcar 'list (mapcar '(lambda (a) (cons 10 a)) (list p1 p2)))
			) 
		)
	)
	(setq i -1 cnt 0 sum_dist 0.0)
	(setq old (getvar 'osmode))
	(setvar 'osmode 0)
	(setvar 'cmdecho 0)
	
	(while (< (setq i (1+ i)) (length bulge_list))
		(cond 
			((/= (nth i bulge_list) 0.0)
				(setq cnt (1+ cnt))
				(command "_.rectang" "_none" p1 "_none" (mapcar '+ (mapcar '+ p1 (list (nth i dist_list) 0)) (list 0 rh)))
				(command "_.move" (entlast) "" "_none" p1 "_none" (polar p1 0 sum_dist))
			)
		)
		(setq sum_dist (+ sum_dist (nth i dist_list)))
	)
	(setvar 'osmode old)
	(setvar 'cmdecho 1)
	(vla-endundomark acdoc)
	(princ)
)

   

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 8 of 9

john.uhden
Mentor
Mentor

This might be easier on your processor

Presuming:

e = entity name

ent = list of entity data

blist = list of bulges

plist = list of vertex points

dlist = list of distances (from 0) of each vertex

dseglist = list of segment distances

(setq blist (mapcar 'cdr (vl-remove-if-not '(lambda (x)(= (car x) 42)) ent)))
(setq plist (mapcar 'cdr (vl-remove-if-not '(lambda (x)(= (car x) 10)) ent)))
(setq dlist (mapcar '(lambda (x)(vlax-curve-getdistatpoint e x)) plist))
(setq copy dlist dseglist nil)
(repeat (1- (length dlist)) (setq dseglist (cons (- (cadr copy)(car copy)) dseglist) copy (cdr copy)))

Of course if dseglist is localized, you don't have to set it to nil.

Just gotta take care of closed polylines.

John F. Uhden

0 Likes
Message 9 of 9

nilesh.bhosale
Advocate
Advocate

Sir thank you very much this is working perfectly fine

 

 

0 Likes