Jump to content

Recommended Posts

Posted

Dear Every one,

I have a problem with CAD and I was hoping you could help me out with it.

As part of a work, there is this polygon whose all sides are single polylines; This polygon also surrounds several points which are supposed to be assigned to one of these polylines based on their distances (Point X will be assigned to Side Y /indicated by changing into a specific color/, if respective distance is the least amount among distances from all sides).

I was wondering if there is a Routine or Lisp which can perform such a routine.

I do appreciate your time and attention in advance.

 

PS: Attached you can find a DWG as a sample of my work.

Drawing2.dwg

Posted

You need to set color and to green pipe LWPOLYLINE to be green like other SIDE LWPOLYLINES... Here test it on my DWG...

 

(defun c:colptsbysidepolys ( / sslw sspts lwl dl )

 (vl-load-com)

 (prompt "\nSelect colored LWPOLYLINE entities - SIDES...")
 (setq sslw (ssget '((0 . "LWPOLYLINE"))))
 (prompt "\nSelect inside POINT entities to color them by SIDES...")
 (setq sspts (ssget '((0 . "POINT"))))
 (foreach pt (vl-remove-if 'listp (mapcar 'cadr (ssnamex sspts)))
   (foreach lw (setq lwl (vl-remove-if 'listp (mapcar 'cadr (ssnamex sslw))))
     (setq dl (cons (distance (cdr (assoc 10 (entget pt))) (vlax-curve-getclosestpointto lw (cdr (assoc 10 (entget pt))))) dl))
   )
   (setq dl (reverse dl))
   (setq dl (vl-sort-i dl '<))
   (entupd (cdr (assoc -1 (entmod (if (assoc 62 (entget pt)) (subst (cons 62 (cdr (assoc 62 (entget (nth (car dl) lwl))))) (assoc 62 (entget pt)) (entget pt)) (append (entget pt) (cons 62 (cdr (assoc 62 (entget (nth (car dl) lwl)))))))))))
   (setq dl nil)
 )
 (princ)
)

Regards...

 

Drawing2.dwg

  • 3 weeks later...
Posted

Dear marko_ribar

this thread is only to inform you that i have found your comments useful and of course effective.

i do appreciate your time and concern

sincerely Reza Monemi

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