Break lisp Issue

Break lisp Issue

Ranjit_Singh
Advisor Advisor
1,656 Views
4 Replies
Message 1 of 5

Break lisp Issue

Ranjit_Singh
Advisor
Advisor

I wrote this break lisp to simply select a point and break object. The goal was to select a point on any object/objects and the lisp will break each object at that point. It gives me At least one break point must be on polyline.*Invalid* error in one particular case. See attachment. The break occurs fine when 2 lines/plines are intersecting. But when one pline is just touching the other pline vertex, it pops the error message. I tried using vlide to figure out whats going on, but it doesnt tell me much. Any help? Thanks in advance.

 

(defun c:br (/ a b ctr curcmdecho curosmode curnomutt)
  (defun *error* (errmsg)
    (if
      (not
	(wcmatch errmsg
		 "Function cancelled,quit / exit abort,console break,end"
	)
      )
       (princ (strcat "\nError: " errmsg))
    )
    (setvar 'cmdecho curcmdecho)
    (setvar 'nomutt curnomutt)
    (setvar 'osmode curosmode)
    (vla-endundomark adoc)
    (princ)
  )
  (vla-startundomark
    (setq adoc (vla-get-activedocument (vlax-get-acad-object)))
  )
  (setq curosmode (getvar 'osmode))
  (setvar 'osmode 553)
  (setq curnomutt (getvar 'nomutt)
	curcmdecho (getvar 'cmdecho)
	a	   (getpoint "\nSelect Break Point: ")
	b (ssget "_c" a a)
	ctr	   0
  )
  (setvar 'cmdecho 0)
  (setvar 'nomutt 1)
  (repeat (sslength b)
    (command-s "._break" (ssname b ctr) a a)
    (setq ctr (1+ ctr))
  )
  (setvar 'osmode curosmode)
  (setvar 'nomutt curnomutt)
  (setvar 'cmdecho curcmdecho)
  (vla-endundomark adoc)
  (*error* "end")
)
0 Likes
Accepted solutions (1)
1,657 Views
4 Replies
Replies (4)
Message 2 of 5

Kent1Cooper
Consultant
Consultant

@Ranjit_Singh wrote:

.... The goal was to select a point on any object/objects and the lisp will break each object at that point. It gives me At least one break point must be on polyline.*Invalid* error in one particular case. ....


I'm not sure about this, because I expect if it's the cause, the same problem would sometimes also occur in other circumstances than what you describe, but....

 

I'm wondering about setting OSMODE to 553.  That includes the NEArest mode, which will "win out" over the other modes most of the time, because the NEArest point on an object will be closer to the crosshair location than [for example] its intersection with something else.  That means that when you pick where you think you're at an intersection, the actual point snapped to will often be on one of the objects, perhaps very near the intersection, but not actually at the intersection, and therefore not truly on the other object.  Try setting OSMODE to 41 [the same combination of other modes, but without NEArest included] instead.

Kent Cooper, AIA
0 Likes
Message 3 of 5

hmsilva
Mentor
Mentor

@Ranjit_Singh wrote:

I wrote this break lisp to simply select a point and break object. The goal was to select a point on any object/objects and the lisp will break each object at that point. It gives me At least one break point must be on polyline.*Invalid* error in one particular case. See attachment. The break occurs fine when 2 lines/plines are intersecting. But when one pline is just touching the other pline vertex, it pops the error message. I tried using vlide to figure out whats going on, but it doesnt tell me much. Any help? Thanks in advance.

 


Hi Ranjit.Singh,

the error is from 'heavy' polylines, probably the 'Break' command deals with these entities differently...

Test for entity type, if an 'heavy' polyline, test if 'a' point is not equal to entity startpoint or endpoint, if not, break , if equal, skip the break for that entity ...

 

EDIT: and declare your *error* function as local variabe...

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 4 of 5

ВeekeeCZ
Consultant
Consultant
Accepted solution

Don't know about the error... try this modification if that is any better.

Notice that there is "_none" for osnap mode for BREAK command.

 

Spoiler
(defun c:br (/ a b ctr curcmdecho curosmode curnomutt)
  (defun *error* (errmsg)
    (if
      (not
	(wcmatch errmsg
		 "Function cancelled,quit / exit abort,console break,end"
		 )
	)
      (princ (strcat "\nError: " errmsg))
      )
    (setvar 'cmdecho curcmdecho)
    (setvar 'nomutt curnomutt)
    (setvar 'osmode curosmode)
    (vla-endundomark adoc)
    (princ)
    )
  (vla-startundomark
    (setq adoc (vla-get-activedocument (vlax-get-acad-object)))
    )
  (setq curosmode (getvar 'osmode))
  (setvar 'osmode 553)
  (setq curnomutt (getvar 'nomutt)
	curcmdecho (getvar 'cmdecho)
	a	   (getpoint "\nSelect Break Point: ")
	b	   (setq ss (ssget "_C"
				   (polar a (* 1.25 pi) 0.01)
				   (polar a (* 0.25 pi) 0.01)
				   '((0 . "LWPOLYLINE,LINE,ARC"))))
	 ;(ssget "_c" a a)
	 ctr	   0
	 )
  (setvar 'cmdecho 0)
  (setvar 'nomutt 1)
  (repeat (sslength b)
    (command "._break" (ssname b ctr) "_none" a "_none" "@")
    (setq ctr (1+ ctr))
    )
  (setvar 'osmode curosmode)
  (setvar 'nomutt curnomutt)
  (setvar 'cmdecho curcmdecho)
  (vla-endundomark adoc)
  (*error* "end")
)

BTW there is no attachement.

Message 5 of 5

Ranjit_Singh
Advisor
Advisor

Thanks BekeeCZ! Worked like magic. All I had to do was add "_none" in my original code in the break command:)

0 Likes