Kowal Posted June 7, 2015 Share Posted June 7, 2015 Hi, I have a question. How to divide into segments lwpoliline to use the function vlax-curve-getClosestPointTo. How to skip the process of inserting and removing entmake function object. Can create an object in a variable? Here is my code, and function Lee Mac ;================================================================== (defun LM:groupn ( l n / r x ) (repeat (/ (length l) n) (repeat n (setq x (cons (car l) x) l (cdr l) ) ) (setq r (cons (reverse x) r) x nil ) ) (if l (setq r (cons l r))) (reverse r) ) ;================================================================== (defun Line (p1 p2) (entmakex (list (cons 0 "LINE") (cons 10 p1) (cons 11 p2)))) ;================================================================== (defun lw_poly (lst /) (entmakex (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (length lst)) '(70 . 128) ) ;_ list (mapcar '(lambda (x) (cons 10 x)) lst) ) ;_ append ) ) ;================================================================== (defun segm (LPts / r) (while (setq r (append r (list (list (car LPts) (cadr LPts)))) LPts (cdr LPts) ) ) (reverse (cdr (reverse r))) ) ;================================================================== (prompt "\ctp") (defun c:ctp (/ ent obj p e cor lst elst) (vl-load-com) (setq ent (car (entsel "\nWybierz polilinie: "))) (setq p (getpoint "\nPoint: ")) (setq obj (vlax-Ename->Vla-Object ent)) (setq cor (vlax-get obj 'Coordinates)) (setq lst (segm (LM:groupn cor 2))) (setq elst (mapcar '(lambda (%) (lw_poly %)) lst)) (mapcar '(lambda (%) (line p (vlax-curve-getClosestPointTo % p))) elst) (mapcar 'entdel elst) (princ) ) Quote Link to comment Share on other sites More sharing options...
tombu Posted June 7, 2015 Share Posted June 7, 2015 Origional thread with LM:groupn code Lee Mac provided at http://www.cadtutor.net/forum/showthread.php?81235-Argument-function-create-inner-list For anyone trying to figure out what that code was about. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.