Jump to content

Recommended Posts

Posted

Hi.

I choose the LWPOLYLINE using a ENTSEL function.

Using code.

(setq cor (vlax-get (vlax-ename->vla-object (car (entsel))) 'coordinates))

Always get.

'(1x 1y 2x 2y 3x 3y ...)

How to get a list of coordinates, depending on which side you choose an LWPOLYLINE?

Example:

Select segment on side 1-2.

 

1.jpg

 

Get:

'(1x 1y 2x 2y 3x 3y ...)

 

Select segment on side 4-5.

 

2.jpg

 

Get:

'(5x 5y 4x 4y 3x 3y ...)

Posted

Try this .

 

(if (and (setq s (entsel "\n Pick a LWPOLYLINE :"))
        (eq (cdr (assoc 0 (entget (car s)))) "LWPOLYLINE")
        (mapcar '(lambda (p)
                   (if (eq (car p) 10)
                     (setq lst (cons (cdr p) lst))
                   )
                 )
                (entget (setq o (car s)))
        )
   )
 (if (< (distance (cadr s) (vlax-curve-getstartpoint o)) (distance (cadr s) (vlax-curve-getendpoint o)))
   (setq lst (reverse lst))
 )
)

Posted
Try this .

 

(if (and (setq s (entsel "\n Pick a LWPOLYLINE :"))
        (eq (cdr (assoc 0 (entget (car s)))) "LWPOLYLINE")
   )
 (progn
   (mapcar '(lambda (p)
              (if (eq (car p) 10)
                (setq lst (cons (cdr p) lst))
              )
            )
           (entget (setq o (car s)))
   )
   (if (< (distance (cadr s) (vlax-curve-getstartpoint o)) (distance (cadr s) (vlax-curve-getendpoint o)))
     (setq lst (reverse lst))
   )
 )
)

 

What about polylines such as this? ;)

(entmake
  '(
       (000 . "LWPOLYLINE")
       (100 . "AcDbEntity")
       (100 . "AcDbPolyline")
       (90 . 5)
       (70 . 0)
       (10 0.0 0.0)
       (10 1.0 0.0)
       (10 1.0 1.0)
       (10 -0.01 1.0)
       (10 -0.01 -4.0)
   )
)

Posted

I would suggest something along the lines of:

(defun c:test ( / e l s x )
   (if (and (setq s (entsel "\nSelect polyline: "))
            (= "LWPOLYLINE" (cdr (assoc 0 (setq x (entget (setq e (car s)))))))
            (setq l (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) x)))
       )
       (if (< (/ (vlax-curve-getdistatparam e (vlax-curve-getendparam e)) 2.0)
              (vlax-curve-getdistatpoint e (vlax-curve-getclosestpointto e (trans (cadr s) 1 0)))
           )
           (reverse l) l
       )
   )
)
(vl-load-com) (princ)

Posted
What about polylines such as this? ;)

 

I intended to use the vlax-curve-getdistatpoint function and I don't know why I have changed my mind , though my first codes in my first post earlier should work as per the OP's requirements .

 

Anyway that easily could be handled somehow to cover other shapes of LWpolylines as Lee's example . :)

 

(defun c:Test (/ s o lst)
 (if (and (setq s (entsel "\n Pick a LWPOLYLINE :"))
        (eq (cdr (assoc 0 (entget (setq o (car s))))) "LWPOLYLINE")
        (mapcar '(lambda (p)
                   (if (eq (car p) 10)
                     (setq lst (cons (cdr p) lst))
                   )
                 )
                (entget o)
        )
   )
 (if (> (vlax-curve-getdistatpoint o (vlax-curve-getclosestpointto o (cadr s)))
        (vlax-curve-getdistatparam o (vlax-curve-getendparam o))
     )
   (setq lst (reverse lst))
 )
)
 lst
)(vl-load-com)

Posted

Recently, I had exactly the same issue to solve. First, I had to determine where the polyline is picked.

After seeing Lee's code here, I did realize my code doesn't work on any UCS/View. But the (trans p 1 0) doesn't do the trick either.

This could be a valid solution for every situation, but I let the debate open, as I am not so sure.

(vlax-curve-getclosestpointtoprojection e (trans p 1 0) (trans (getvar 'viewdir) 1 0 T))

Posted

A simple method I use is to always say "pick start end" the idea here being if you are going to do say offsets you know which is left and right, even when the pick is up side down as per your image. The only problem I can see is with closed plines you probably need a pick again option with say a Circle indicating start point.

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