Jump to content

Recommended Posts

Posted

Hi guys, is there a way to remove or erase portion of polyline in shortest way by lisp, as shown at the figure attached..

PORTION REMOVED.jpg

  • Replies 21
  • Created
  • Last Reply

Top Posters In This Topic

  • Tharwat

    9

  • martinle

    6

  • notview

    4

  • Lee Mac

    3

Top Posters In This Topic

Posted Images

Posted

Thank you LM. TRIM command is done well in figure at left, but figure at right will not erase, only trim portion.

 

 

Figure at right is polyline with two vertex. Is this possible to make lisp routine, if select two vertex polyline it will erase, combining to TRIM.

 

 

The figure shown above is only portion of my work, sometimes many polyline crossing each other, TRIM command alone will not solve my problem.

 

 

Thank you for your help!

Posted

Try this :

 

(defun c:Test  (/ s o a b c)
;;;	Tharwat 27.4.2015	;;;
 (if
   (and (setq s (entsel "\n Select a Polyline to trim segment :"))
        (wcmatch (cdr (assoc 0 (entget (setq o (car s))))) "*POLYLINE")
        )
    (cond ((= (cdr (assoc 90 (entget o))) 2) (entdel o))
          (t
           (setq a (fix (vlax-curve-getparamatpoint  o  (vlax-curve-getclosestpointto o (cadr s))))
                 b (vlax-curve-getpointatparam o a)
                 c (vlax-curve-getpointatparam o (1+ a))
                 )
           (command "_.Break" o "_none" b "_none" c "")
           )
          )
    )
 (princ)
 )

Posted

It's great!! Tharwat.

 

 

It help me a lot.. Only command at a time, can you make this continue until escape and, or, select more than one then trim/erase the selected segments.

 

 

Thank you Tharwat!! It solved my problem.. hahaha..

Posted
It's great!! Tharwat.

Thank you Tharwat!! It solved my problem.. hahaha..

 

Excellent , happy to hear that :D

 

It help me a lot.. Only command at a time, can you make this continue until escape and, or, select more than one then trim/erase the selected segments.

 

No you can not use multiple selection with this task but if you wan to keep the program running until you hit enter , just replace the IF function with while .

 

Try not to use Escape button for any command unless you have no way to , so hit enter would avoid errors messages and exit commands safely ( in general ) .

 

Good luck .

Posted

Thank you to advice and to your time of this code, it save me a lot of time.

 

 

Superb! Everything is fine.

 

 

Thank you Tharwat!

Posted
Thank you to advice and to your time of this code, it save me a lot of time.

 

 

Superb! Everything is fine.

 

 

Thank you Tharwat!

 

You are welcome anytime . :)

Posted

Hello Tharwat.

I have problems when I'm out in the BCS with this Lisp.

There it did not work. Could you gaze again what could be missing here?

 

Martin

Posted
Hello Tharwat.

I have problems when I'm out in the BCS with this Lisp.

There it did not work. Could you gaze again what could be missing here?

 

Martin

 

Hi Martin , happy to see you posting again :)

 

Yeah, I guess the routine works only with WCS . Can you upload a sample drawing to allow me to try it out with that system ?

Posted

Hello Tharwat, unfortunately I do not know how you attach a file.

Martin

Posted

Take a look at the right side hand down of the forum and there must be a button called Go Advanced , hit the button then you should be able to find the attach button and lots of other interesting things ;)

Posted

Unfortunately I could not make it working on other than WCS , I am sorry :(

Posted

Hello Tharwat,

ok. Thank you.

:(:(:(

Posted

If you transfer your drawing into WCS , the program should work as expected otherwise no luck with it .

Posted

The following modifications should enable UCS compatibility:

(defun c:test ( / a e s x )
   ;;;    Tharwat 27.4.2015    ;;;
   (if
       (and
           (setq s (entsel "\nSelect polyline to trim segment: "))
           (setq e (car s)
                 x (entget e)
           )
           (= "LWPOLYLINE" (cdr (assoc 0 x)))
       )
       (if (= 2 (cdr (assoc 90 x)))
           (entdel e)
           (progn
               (setq a (fix (vlax-curve-getparamatpoint e (vlax-curve-getclosestpointto e (trans (cadr s) 1 0)))))
               (command
                   "_.break" s "_f"
                   "_non" (trans (vlax-curve-getpointatparam e a) 0 1)
                   "_non" (trans (vlax-curve-getpointatparam e (1+ a)) 0 1)
               )
           )
       )
   )
   (princ)
)

Good solution Tharwat :thumbsup:

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