Jump to content

Looking for a Lisp to simplify wall lines!


stlo

Recommended Posts

Try this, Note your dwg has offsets like 22 no where near 1/16 = 0.0625 need a real pline to test.

 

(defun c:del116 ( / ent co-ord start end ss1 ss2 obj obj2 obj3 oldsnap)

(setq ent (car  (entsel "\nPick pline ")))
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
(setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget ent))))
(setq obj (vlax-ename->vla-object ent))
(setq start (vlax-curve-getstartPoint obj))
(setq end (vlax-curve-getEndPoint obj))
(command "line" start end "")
(setq obj2 (vlax-ename->vla-object (entlast)))

(vla-offset obj2 0.0625)
(setq obj3 (vlax-ename->vla-object (entlast)))
(setq start (vlax-curve-getstartPoint obj3))
(setq end (vlax-curve-getEndPoint obj3))
(setq ss1 (ssget "F" (list start end) (list (cons 0 "LWPOLYLINE"))))

(vla-offset obj2 -0.0625)
(setq obj3 (vlax-ename->vla-object (entlast)))
(setq start (vlax-curve-getstartPoint obj3))
(setq end (vlax-curve-getEndPoint obj3))
(setq ss2 (ssget "F" (list start end) (list (cons 0 "LWPOLYLINE"))))

(if (and (= ss1 nil)(= ss2 nil))
(progn
(alert "pline outside range")
(vla-delete obj2)
)
(progn
(alert "pline within range")
(command "erase" ent "")
)
)
(setvar 'osmode oldsnap)
(princ)
)

 

  • Like 1
Link to comment
Share on other sites

Hi Bigal! Oh man, this is awesome! Thank you very much! I've tried to add some commands to what you did and it's working! Please let me know if it makes sense to you the way I did it! I found some reading about vla, so much to learn! 

(defun c:del116 ( / ent co-ord start end ss1 ss2 obj obj2 obj3 obj4 oldsnap) ;;I’ve added obj4 to be able to delete it later;;

(command "pedit" "M" (ssget) "" "y" "J" "" "") ;;I realise that I needed to create the polyline before;; 
(setq ent (car  (entsel "\nPick pline ")))
(setvar 'osmode 0)
(setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget ent))))
(setq obj (vlax-ename->vla-object ent))
(setq start (vlax-curve-getstartPoint obj))
(setq end (vlax-curve-getEndPoint obj))
(command "line" start end "")
(setq obj2 (vlax-ename->vla-object (entlast)))

(vla-offset obj2 0.0625)
(setq obj3 (vlax-ename->vla-object (entlast)))
(setq start (vlax-curve-getstartPoint obj3))
(setq end (vlax-curve-getEndPoint obj3))
(setq ss1 (ssget "F" (list start end) (list (cons 0 "LWPOLYLINE"))))

(vla-offset obj2 -0.0625)
(setq obj4 (vlax-ename->vla-object (entlast))) 
(setq start (vlax-curve-getstartPoint obj4))
(setq end (vlax-curve-getEndPoint obj4))
(setq ss2 (ssget "F" (list start end) (list (cons 0 "LWPOLYLINE"))))

(if (and (= ss1 nil)(= ss2 nil))
(progn
(alert "pline within range") ;;I’ve switch the order of the within and the without range in the code;;
(command "erase" ent "")
(vla-delete obj3) ;;deletes the offset lines;;
(vla-delete obj4) ;;deletes the offset lines;;
)
(progn
(alert "pline outside range")
(vla-delete obj2)
(vla-delete obj3) ;;deletes the offset lines;;
(vla-delete obj4) ;;deletes the offset lines;;
(command "CHANGE" (entlast) "" "P" "LA" "WALL" "") ;;Change the layer of the new polyline 
(command "copy" (Entsel) "" '(0 0) '(0 0)) ;;creates a copy on same layer
(command "CHANGE" (entlast) "" "P" "LA" "CLIP" "") ;; Change the layer of the new copied polyline
)
)
(setvar 'osmode 7679) ;;I’ve set my own number because it stayed on Osmode 0;;
(princ)
)

 

Link to comment
Share on other sites

Glad it works, my bad left a couple of lines out.

 

(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
............
...........
(setvar 'osmode oldsnap)

 

Edited by BIGAL
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...