Jump to content

Trimming inside or Rectangle?


BLOACH85

Recommended Posts

Yea its been rough ive been up for atleast 36 hours and 4 chain-saw blades latter. But Thank God no one was hurt. But ok i tested it and it showed me the crossing entitys now what am i suppose to do with that??

Link to comment
Share on other sites

I have this so far... but will only break when things intersect twice... only tested on lines also...

 

(defun ssinter    (ss rec / vlst i j obj1 iarr iLst ptLst)
 (setq i (length ss))
 (while (not (minusp (setq i (1- i))))
   (setq obj1 (nth i ss)
     iarr (vlax-variant-value (vla-intersectwith obj1 rec acextendnone)))
   (if    (> (vlax-safearray-get-u-bound iarr 1) 0)
         (progn
     (setq iLst (vlax-safearray->list iArr))
     (while (not (zerop (length iLst)))
       (setq ptLst (cons (list (car iLst) (cadr iLst) (caddr iLst)) ptLst)
          iLst (cdddr iLst)))
     (setq ptLst (cons (vlax-vla-object->ename obj1) ptLst)
       mainLst (cons ptLst mainLst))))))

(defun c:test  (/ rect mainLst)
 (vl-load-com)
 (setq rect (car (entsel "\nSelect Rectangle...")))
 (ssinter (mapcar 'vlax-ename->vla-object
          (vl-remove-if '(lambda (x) (eq x rect))
            (mapcar 'cadr (ssnamex (ssget "X" (list (cons 410 (getvar "CTAB"))))))))
      (vlax-ename->vla-object rect))
 (alert (vl-princ-to-string mainLst))
 (mapcar '(lambda (x) (command "_break" (list (car x) (cadr x)) (caddr x))) mainLst)
 (princ))

Link to comment
Share on other sites

ok see i guess im really having trouble so how should i put this in my routine? to where it all envokes in one command?

Link to comment
Share on other sites

Just replace the line that asks to select a rectangle with the entity name of your offset rectangle.

 

I.e. the variable rect should be the entity name (ename) of the rectangle you wish to trim inside. - don't worry about deleting the rectangle before running this LISP either.

Link to comment
Share on other sites

I can't work out how to do it for multiple intersections, or a single intersection... so annoying.

 

My LISP only works if the object intersects the rectangle exactly twice... if only once, it will return and error, and if more than twice, the object won't get trimmed properly.... :(

Link to comment
Share on other sites

ok Sorry It works fine. But I see that the defun C:test ok now what should i take out of your routine to put into my routine to make it one? Do you see what im saying?

Link to comment
Share on other sites

Take a look at this routine for some ideas:

;;;=======================[ BreakObjects.lsp ]==============================
;;; Author: Copyright© 2006-2008 Charles Alan Butler 
;;; Contact @  www.TheSwamp.org
;;; Version:  2.1  Nov. 20,2008
;;; Purpose: Break All selected objects
;;;    permitted objects are lines, lwplines, plines, splines,
;;;    ellipse, circles & arcs 
;;;                            
;;;  Function  c:MyBreak -       DCL for selecting the routines
;;;  Function  c:BreakAll -      Break all objects selected with each other
;;;  Function  c:BreakwObject  - Break many objects with a single object
;;;  Function  c:BreakObject -   Break a single object with other objects 
;;;  Function  c:BreakWith -     Break selected objects with other selected objects
;;;  Function  c:BreakTouching - Break objects touching selected objects
;;;  Function  c:BreakSelected - Break selected objects with any objects that touch it 
;;;  Revision 1.8 Added Option for Break Gap greater than zero
;;;  NEW r1.9  c:BreakWlayer -   Break objects with objects on a layer
;;;  NEW r1.9  c:BreakWithTouching - Break touching objects with selected objects
;;;  Revision 2.0 Fixed a bug when point to break is at the end of object
;;;  Revision 2.1 Fixed another bug when point to break is at the end of object
;;;
;;;
;;;  Function  break_with  - main break function called by all others and
;;;                          returns a list of new enames, see c:BreakAll
;;;                          for an example of using the return list
;;;
;;; Requirements: objects must have the same z-value
;;; Restrictions: Does not Break objects on locked layers 
;;; Returns:  none

BreakObj21.zip

Link to comment
Share on other sites

Take a look at this routine for some ideas:

;;;=======================[ BreakObjects.lsp ]==============================
;;; Author: Copyright© 2006-2008 Charles Alan Butler 
;;; Contact @  www.TheSwamp.org
;;; Version:  2.1  Nov. 20,2008
;;; Purpose: Break All selected objects
;;;    permitted objects are lines, lwplines, plines, splines,
;;;    ellipse, circles & arcs 
;;;                            
;;;  Function  c:MyBreak -       DCL for selecting the routines
;;;  Function  c:BreakAll -      Break all objects selected with each other
;;;  Function  c:BreakwObject  - Break many objects with a single object
;;;  Function  c:BreakObject -   Break a single object with other objects 
;;;  Function  c:BreakWith -     Break selected objects with other selected objects
;;;  Function  c:BreakTouching - Break objects touching selected objects
;;;  Function  c:BreakSelected - Break selected objects with any objects that touch it 
;;;  Revision 1.8 Added Option for Break Gap greater than zero
;;;  NEW r1.9  c:BreakWlayer -   Break objects with objects on a layer
;;;  NEW r1.9  c:BreakWithTouching - Break touching objects with selected objects
;;;  Revision 2.0 Fixed a bug when point to break is at the end of object
;;;  Revision 2.1 Fixed another bug when point to break is at the end of object
;;;
;;;
;;;  Function  break_with  - main break function called by all others and
;;;                          returns a list of new enames, see c:BreakAll
;;;                          for an example of using the return list
;;;
;;; Requirements: objects must have the same z-value
;;; Restrictions: Does not Break objects on locked layers 
;;; Returns:  none

 

WOWWW :shock:

 

That is one hell of a LISP CAB --- I don't even know where to start... :P

 

Amazing work :)

 

Lee

Link to comment
Share on other sites

  • 13 years later...
20 hours ago, Husso said:

I can't join this site because they ask stupid questions. I doubt their seriousness.

 

Its to combat spam and its only for like your first 5 or so posts.

  • Thanks 1
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...