Jump to content

Lwpoliline division into segments in a variable.


Kowal

Recommended Posts

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

Link to comment
Share on other sites

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