Jump to content

Recommended Posts

Posted

Hi everyone,

 

i need help (a chunck of code) for checking if selected polyline is returning. In the picture belowe i draw a polyline with some point - vertex of polyline are in the base points of the text. In this case there is one point where the polyline is returning and this point is point 2. So in this case i want to get variable with value 1.

Is there possibilty to do that?

Thanks in advance

 

 

image.png

Posted (edited)

I guess you could make a temp copy of the polyline to explode and overkill. Check the total length of entity's left against the length of the unexploded polyline.

 

original length = non returning length

original length > returning length

 

-edit

You would then even know for what length its overlapping.

 

-edit added lisp

: RETURN
Select entities:
Polyline has 113.886 of overlap

 

: RETURN
Select entities:

Polyline does not overlap

 

;;----------------------------------------------------------------------------;;
;; Check if a polyline is overlapping
(defun C:RETURN (/ len len+ ss ss1 ent objs LastEnt)
  (setq len 0.0 
        len+ 0.0
        ss (ssadd)
  )  
  (if (setq ss1 (ssget "_+.:E:S" '((0 . "*POLYLINE"))))
    (progn
      (setq ent (ssname ss1 0))
      (setq len (+ (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent))))
      (setq LastEnt (entlast))
      (setq objs (vlax-invoke (vlax-ename->vla-object ent) 'explode))
      (foreach ent (mapcar 'vlax-vla-object->ename objs)
        (ssadd ent ss)        
      )
      (setvar 'nomutt 1)
      (command "-overkill" ss "" "")
      (setvar 'nomutt 0)
      (if (setq en (entnext LastEnt))
        (while en
          (ssadd en SS)
          (setq en (entnext en))
        )
      )
      (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
        (if (entget e)
          (progn
            (setq len+ (+ len+ (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e))))
            (entdel e)
          )
          (ssdel ent ss)          
        )
      )
      (if (> len len+)
        (prompt (strcat "\nPolyline has " (rtos (- len len+) 2 3) " of overlap"))
        (prompt "\nPolyline does not overlap")        
      )
    )
  )
  (princ)
)

 

Edited by mhupp
  • Like 1
  • Thanks 1
Posted

I figured out something else. Beacause in every case i will have polylines where the returnign parts will always be horizontal, so i can compare x,y coordinates for every vertex and compare the x coordinates. If there will be odd number ov vertex with the same x coordinates add 1 to variable, beacuse I will only have one returning per one x coordinate.

Can someone help with extracting coordinates and comparing every vertex with each other?

Posted (edited)
(setq coords (vl-remove-if 'not (mapcar (function (lambda (p) (if (= 10 (car p)) (cdr p)))) (entget <entity name>))))

 

Edited by mhupp
  • Thanks 1

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