Jump to content

Autoselect nearest closed polyline that surrounds text entity


alm865

Recommended Posts

Reading your comment and got me thinking. This creates a temporary point at the insertion point of the block and uses that for test to delete the poyline. then deletes all the temporary points after the command is done. It's kinda messy exploding blocks and pasting them back in might as well just leave them alone + its faster.

 

(defun c:foo (/ SS1 SS blk i lst en pts)
  (vl-load-com)
  (setq pts (ssadd))
  (if (setq SS1 (ssget "_X" '((0 . "Insert") (2 . "C1666"))))
    (foreach blk (mapcar 'cadr (ssnamex SS1))
      (setq pt (cdr (assoc 10 (entget blk)))) ;gets block insertion point
      (entmakex (list (cons 0 "POINT") (cons 10 pt)))  ;creates temporary point
      (ssadd (entlast) pts) ;adds temporary point to a selection set
    )
    (prompt "\nNo Plot ID Blocks in Drawing")
  )
  (if (setq SS (ssget "_X" '((0 . "LWPOLYLINE") (8 . "C1602_0") (70 . 1) (410 . "Model"))))
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
      (setq lst nil)  ;clears lst of previous cords
      (repeat (setq i (fix (1+ (vlax-curve-getEndParam e))))
        (setq lst (cons (trans (vlax-curve-getPointAtParam e (setq i (1- i))) 0 1) lst))
      )
      (if (ssget "_WP" lst '((0 . "POINT")))
        (entdel e)
      )
    )
    (prompt "\nNo Plot Boundary's in Drawing")
  )
  (vl-cmdf "_.Erase" pts "") ;delete all temporary points
  (princ)
)

 

9 hours ago, mk4176 said:

I still lack a lot of knowledge in programming. I basically do my things by understanding others code then modify it to suit my needs.

 

That's how I started out. just keep with it and it will get easier with time.

 

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