Saturday, November 21, 2009
Home   |   Search   |   About AUGI   |   My AUGI   |   Join Now

Go Back   AUGI Forums > AUGI Technical (English) > Programming > AutoLISP
 Welcome, Guest. 

Login

Join Now FAQ Members List Calendar Search Today's Posts Mark Forums Read

AutoLISP AutoLISP or Visual LISP, learn both here!

Reply
 
Thread Tools Display Modes
Old 2004-07-10, 07:26 AM   #1
zorroxxxx
Active Member
 
zorroxxxx's Avatar
 
Join Date: 2002-12
Posts: 89
zorroxxxx is glowing brightlyzorroxxxx is glowing brightlyzorroxxxx is glowing brightlyzorroxxxx is glowing brightlyzorroxxxx is glowing brightlyzorroxxxx is glowing brightlyzorroxxxx is glowing brightlyzorroxxxx is glowing brightly
Question LISP for Intersection Clean Up

Hi,

Does anyone have a LISP or Script that will clean up intersections? Both linear and radius intersections. I have been constantly trimming and after a few hundred thousand clicks, I figure there has to be an easier way. I've also have tried using BPOLY command but it creates polylines on top of existing lines, which I then have to delete. I am just learning LISP so I'm not sure how to conquer this problem.

I have attached a .BMP file which shows exactly what I'm looking for.

I run Vanilla ACAD 2002

Any help will be greatly appreciated

Gary
Attached Files
File Type: zip Intersections.zip (32.3 KB, 42 views)
zorroxxxx is offline   Reply With Quote
Old 2004-07-10, 03:21 PM   #2
mjfarrell
AUGI Addict
 
Join Date: 2001-10
Posts: 1,792
mjfarrell appears to be implodingmjfarrell appears to be imploding
Default RE: LISP for Intersection Clean Up

Take a look here:http://www.cadresource.com/library/lispbc.html
mjfarrell is offline   Reply With Quote
Old 2004-07-11, 06:23 AM   #3
zorroxxxx
Active Member
 
zorroxxxx's Avatar
 
Join Date: 2002-12
Posts: 89
zorroxxxx is glowing brightlyzorroxxxx is glowing brightlyzorroxxxx is glowing brightlyzorroxxxx is glowing brightlyzorroxxxx is glowing brightlyzorroxxxx is glowing brightlyzorroxxxx is glowing brightlyzorroxxxx is glowing brightly
Talking RE: LISP for Intersection Clean Up

Quote:
Originally Posted by mjfarrell

Hi Michael,

Your link went to the B-C section of the site. Did you have a specific file in mind? I browsed the section and did not see anything that would work. Is there one there that can be modified to do what I need?

Thanks in advance,

Gary
zorroxxxx is offline   Reply With Quote
Old 2004-07-12, 08:02 AM   #4
sinc
AUGI Addict
 
sinc's Avatar
 
Join Date: 2004-02
Location: Colorado
Posts: 1,531
sinc is shooting for the starssinc is shooting for the starssinc is shooting for the starssinc is shooting for the starssinc is shooting for the starssinc is shooting for the starssinc is shooting for the starssinc is shooting for the starssinc is shooting for the starssinc is shooting for the starssinc is shooting for the stars
Default RE: LISP for Intersection Clean Up

I've wanted something similar in the past, so I figured I'd have a go at it. This is my first attempt at using the ActiveX interface, so some things might have been accomplished more easily in another way, but this works.

It lets you select a set of objects (any drawing objects should work, although results are unpredictable for circles). Any objects that intersect two and only two of the other objects in the selection set will be broken between the intersection points. If a given object has more than two intersections, then the code wouldn't know which segments to remove. It would need to be extended to allow the user to specify which segments to remove, possibly by selecting inside the desired intersections as you proposed, although I haven't yet figured out the best way of going about it. Feel free to tackle it yourself.

The code loops until you hit enter or right-click without selecting any objects.

Code:
;; takes a selection set, and trims the gap between intersection points for
;; all objects that intersect two and only two of the other objects in the set
;; Richard Sincovec, July 11 2004

(vl-load-com)
(defun c:itrim (/ acadObj doc ssets ss count err i j items item	intxlist
		intitem)
  (setq	acadObj	(vlax-get-acad-object)
	doc	(vla-get-activeDocument acadObj)
	ssets	(vla-get-selectionSets doc)
  )
  (setq	err (vl-catch-all-apply
	      (function
		(lambda	()
		  (setq ss (vla-add ssets "ZYZ_ITRIM"))
		) ;lambda
	      ) ;function
	    ) ;vl-catch-all-apply
  ) ;setq
  (if (vl-catch-all-error-p err)
    ;; error is probably "ss already exists"
    ;; it shouldn't yet, but use it if it does
    (setq ss (vla-item ssets "ZYZ_ITRIM"))
  ) ;if
  (while ; (MAIN)
    (progn
      (vla-clear ss)
      (vla-selectOnScreen ss)
      (setq count (vla-get-count ss))
      (/= count 0)
    ) ;progn
     (setq i count
	   items nil
     ) ;setq
     (while (/= i 0)
       (setq i	      (1- i)
	     item     (vla-item ss i)
	     j	      count
	     intxlist nil
       ) ;setq
       (while (/= j 0)
	 (setq j       (1- j)
	       intitem (vla-item ss j)
	 ) ;setq
	 ;; I kept getting an exception on vlax-safearray->list
	 ;; if intersectWith found no points, and couldn't figure
	 ;; out offhand how to stop getting it, so I decided to catch
	 ;; and ignore it instead
	 (if (/= (vla-get-handle item) (vla-get-handle intitem))
	   (vl-catch-all-apply
	     (function
	       (lambda ()
		 (setq
		   intx	    (vlax-safearray->list
			      (vlax-variant-value
				(vla-IntersectWith
				  item
				  intitem
				  acExtendNone
				)
			      )
			    )
		   intxlist (append intxlist (list intx))
		 ) ;setq
	       ) ;lambda
	     ) ;function
	   ) ;vl-catch-all-apply
	 ) ;if
       ) ;while j
       ;; if we found two and only two intersections, store the entity for breaking
       ;; if we break it now, it will confuse the rest of the intersection checking
       (if (= (length intxlist) 2)
	 (setq
	   items (append
		   items
		   (list (cons (vlax-vla-object->ename item) intxlist))
		 )
	 )
       ) ;if
     ) ;while i
     ;; break the items
     (foreach item items
       (command	"break"
		(list (car item) (cadr item))
		(caddr item)
       )
     ) ;foreach
  ) ;while (MAIN)
  (vla-delete ss)
  (princ)
) ;defun
sinc is offline   Reply With Quote
Old 2004-07-13, 01:57 PM   #5
peter
Vice President / Director
 
peter's Avatar
 
Join Date: 2000-09
Location: Kenosha Wisconsin
Posts: 375
peter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the stars
Default RE: LISP for Intersection Clean Up

here is a little routine that I cooked up. Just select the 4 lines to trim and it should clip them the way you want.

Peter Jamtgaard

Code:
(defun C:TRIMIT3 (/ intCount 
                   lstPairs3                  
                   lstPoints3
                   lstPoints4
                   lstObjects
                   lstObjects2
                   lstObjects3
                   ssSelections  )

 (setq ssSelections (ssget (list (cons 0 "*line,arc"))))
 (repeat (setq intCount (sslength ssSelections))
  (setq intCount   (1- intCount)
        lstObjects (cons (vlax-ename->vla-object (ssname ssSelections intCount))
                         lstObjects
                   )
  )
 )
 (repeat (setq intCount (length lstObjects))
  (setq intCount     (1- intCount)
        objSelection (nth intCount lstObjects)
        lstPairs3    nil
  )
  (repeat (setq intCount2 (length (setq lstObjects2 (vl-remove objSelection lstObjects))))
   (if (not 
        (vl-catch-all-error-p
         (vl-catch-all-apply
         '(lambda (X Y)
           (setq varPOint (vla-intersectwith X Y 0))
          )
          (list objSelection (nth (1- intCount2) lstObjects2))
         )
        )
       )
    (progn
     (if (safearray-value (variant-value varPoint))
      (progn 
       (setq lstPoint  (vlax-safearray->list (variant-value varPoint))
             lstPairs3 (cons (cons (vlax-curve-getparamatpoint objSelection lstPoint)
                                     lstPoint                                   
                               )
                               lstPairs3
                         )
       )
      )
     )
    )
   )
   
   (setq intCount2 (1- intCount2))   
  )
  (if lstPairs3
   (progn
    (setq lstPairs3  (sortList lstPairs3 0)
          lstPoints3 (mapcar 'cdr lstPairs3)

    )
   )
  )
  (setq lstPoints4 (cons (cons objSelection (reverse lstPoints3))
                         lstPoints4
                   )
        lstPoints3 nil
        lstPairs   nil
  )  
 )
 (foreach lstN lstPoints4
  (setq objSelection (car lstN)
        lstN         (cdr lstN)
  )
  (repeat (/ (length lstN) 2)
   (vl-cmdf "break"           
            (vlax-vla-object->ename objSelection)            
            "F"
            (car lstN)
            (cadr lstN)
   )
   (setq lstN (cddr lstN))
  )
 )
)
(defun SortList (lstOfLists intItem)
 (vl-sort lstOfLists '(lambda (n1 n2) (<= (nth intItem n1) (nth intItem n2))))
)
peter is offline   Reply With Quote
Old 2004-07-14, 06:24 AM   #6
zorroxxxx
Active Member
 
zorroxxxx's Avatar
 
Join Date: 2002-12
Posts: 89
zorroxxxx is glowing brightlyzorroxxxx is glowing brightlyzorroxxxx is glowing brightlyzorroxxxx is glowing brightlyzorroxxxx is glowing brightlyzorroxxxx is glowing brightlyzorroxxxx is glowing brightlyzorroxxxx is glowing brightly
Talking RE: LISP for Intersection Clean Up

Thanks to all for solving my problem.

Richards' file worked great for individual intersections and Peter's file worked for individual and multiple intersections. Thanks to Michael for a link to a good LISP resource.

As a beginner in the world of LISP maybe someday I'll be able to help someone as you have.

THANKS!!!

Gary
zorroxxxx is offline   Reply With Quote
Old 2004-07-16, 12:42 AM   #7
zorroxxxx
Active Member
 
zorroxxxx's Avatar
 
Join Date: 2002-12
Posts: 89
zorroxxxx is glowing brightlyzorroxxxx is glowing brightlyzorroxxxx is glowing brightlyzorroxxxx is glowing brightlyzorroxxxx is glowing brightlyzorroxxxx is glowing brightlyzorroxxxx is glowing brightlyzorroxxxx is glowing brightly
Lightbulb RE: LISP for Intersection Clean Up

Peter,

Your file only seems to work in Acad 2004. I emailed it to my work and could not get it to run on Acad 2002.

Is there a way to modify your file to get it working in 2002?

Thanks in advance,

Gary
zorroxxxx is offline   Reply With Quote
Old 2004-07-28, 04:47 PM   #8
jwanstaett
I could stop if I wanted to
 
Join Date: 2002-02
Location: Kansas
Posts: 462
jwanstaett is a beam of lightjwanstaett is a beam of lightjwanstaett is a beam of lightjwanstaett is a beam of lightjwanstaett is a beam of lightjwanstaett is a beam of lightjwanstaett is a beam of lightjwanstaett is a beam of lightjwanstaett is a beam of lightjwanstaett is a beam of lightjwanstaett is a beam of light
Default RE: LISP for Intersection Clean Up

add

(vl-load-com)
to the start of peter file as richards did and it will work in in 2002
jwanstaett is offline   Reply With Quote
Old 2004-07-29, 05:40 PM   #9
Lemons
Moderator
 
Lemons's Avatar
 
Join Date: 2001-06
Location: Beautiful Charleston, South Carolina
Posts: 116
Lemons is reaching for the moonLemons is reaching for the moonLemons is reaching for the moonLemons is reaching for the moonLemons is reaching for the moonLemons is reaching for the moonLemons is reaching for the moonLemons is reaching for the moonLemons is reaching for the moonLemons is reaching for the moonLemons is reaching for the moon
Default RE: LISP for Intersection Clean Up

I just use a fillet crossing with a zero radius to do this:

(defun c:fc () (command "undo" "m") (command "fillet" "R" "0") (command "fillet" "c"))
Lemons is offline   Reply With Quote
Old 2004-07-29, 07:19 PM   #10
sinc
AUGI Addict
 
sinc's Avatar
 
Join Date: 2004-02
Location: Colorado
Posts: 1,531
sinc is shooting for the starssinc is shooting for the starssinc is shooting for the starssinc is shooting for the starssinc is shooting for the starssinc is shooting for the starssinc is shooting for the starssinc is shooting for the starssinc is shooting for the starssinc is shooting for the starssinc is shooting for the stars
Default

If you try the routines we posted, you'll see they do something different. They actually do the equivalent of breaking four lines and then running your fc function four times... (in the simplest case, anyway...)
__________________
-- Sinc
Civil-3D/Map 2009
http://www.ejsurveying.com
http://www.quuxsoft.com
(Sincpac-C3D)
sinc is offline   Reply With Quote
Reply


Go Back   AUGI Forums > AUGI Technical (English) > Programming > AutoLISP

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Learning Lisp Wolfgirl AutoLISP 37 2008-09-21 07:22 AM
Routine to add text below existing text jhohman AutoLISP 8 2004-06-29 09:05 PM
Changing file attributes with lisp pcs AutoLISP 4 2004-06-11 01:44 PM
Elevation Lisp? gapple AutoLISP 0 2004-06-10 12:25 PM
Need Help w/ a lisp..... smiller AutoLISP 2 2004-06-07 04:17 PM


All times are GMT +1. The time now is 12:38 PM.