Jump to content

Recommended Posts

Posted

Hi

 

I need a lisp routine that can draw a new polyline by connecting selected lines vertices in x or y value order.(İncreasing or decreasing does not matter)

 

Thank you very much

Posted

A double sort that may help.

 

Ps website is having problems ?

 

; sorts on 1st two items
(setq lst (vl-sort lst '(lambda (x y)
(cond
((= (cadr x)(cadr y))
(< (car x)(car y)))
((< (cadr x)(cadr y)))
))))

Posted
A double sort that may help.

 

Ps website is having problems ?

 

; sorts on 1st two items
(setq lst (vl-sort lst '(lambda (x y)
(cond
((= (cadr x)(cadr y))
(< (car x)(car y)))
((< (cadr x)(cadr y)))
))))

 

What will i write to command line to run this routine?

 

PS: yes web site has problems now.

Posted

You need to post some idea of what your trying to achieve. The internet problem is stopping my crystal ball from working.

Posted
You need to post some idea of what your trying to achieve. The internet problem is stopping my crystal ball from working.

 

I have hundreds of individualy drawn polylines.I need to draw new polylines on them but the new polylines need to be drawn in order with decreasing or increasing X values or (Y values optionaly)

 

Thank you

Posted

Still waiting for an image or dwg can not help without that.

Posted
Still waiting for an image or dwg can not help without that.

 

Unable to display content. Adobe Flash is required.

 

Please check the video in the link.The white poly is existing and i have hundreds of it.The magenta line is what i want to have to draw in order with x value or sometimes y value.I hope its now clear.

 

Thank you

Posted (edited)

Ok it makes sense now it can be done easily using sort a list of points based on X or Y. My 1st post is sort on X&Y will try to post something a bit later need to do some work now.

 

; pline co-ords example
; By Alan H

(defun getcoords (ent)
 (vlax-safearray->list
   (vlax-variant-value
     (vlax-get-property
   obj
   "Coordinates"
     )
   )
 )
)

; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z 
(defun co-ords2xy ()
(setq len (length co-ords))
(if (= (vla-get-objectname obj) "AcDbLwpolyline")
(setq numb (/ len 2)) ; even and odd check required
(setq numb (/ len 2)))
(setq I 0)
(repeat numb
(setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) ))
; odd (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords)(nth (+ I 2) co-ords) ))
(setq co-ordsxy (cons xy co-ordsxy))
(setq I (+ I 2))
)
)



; program starts here
(defun C:ahjoinX ( / co-ordsxy lst)
(setq obj (vlax-ename->vla-object (car (entsel "\nplease pick pline"))))
(setq co-ords (getcoords obj))
(co-ords2xy)
(setq lst (vl-sort co-ordsxy
(function (lambda (e1 e2)
(< (car e1) (car e2)))))
)
(command "_pline")
(while (= (getvar "cmdactive") 1 ) 
(repeat (setq x (length lst))
(command (nth  (setq x (- x 1)) lst))
)
(command "")
)
(princ)
)
(C:ahjoinx)

Edited by BIGAL
Posted

Thank you.That works for X values, but do i have to eachtime "appload" the lisp to run it?Is there a command to run that lisp?

Posted

Code changed to command line version type ahjoinx for next, it will do 1st on loading. Just a quick 1 the old code if you typed (ah:joinx) it would repeat.

 

Also you mentioned Y as choice this would use the cadr in the sort instead of car.

Posted

Thank you very much.That's exactly what i need.

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...