Jump to content

Possible LISP request - Break up a circle into equal parts


CADMASTER1128

Recommended Posts

  • 3 years later...
  • Replies 21
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    10

  • CADMASTER1128

    5

  • alanjt

    3

  • SteveK

    2

Cbrk.lsp doenot worked in some case,i don't know why but when i modify this lisp,now it working for me,but i donot know my lisp modifed is that correct? :lol:

can you update your code,lee

 (defun c:CBrk (/ ss tmp i j ent elst inc st s501 len R1 )
 (vl-load-com)

 (or Cbrk:num (setq Cbrk:num 2))

 (cond ((setq ss (ssget "_:L" '((0 . "ARC,CIRCLE"))))
        
        (initget 6)
        (and (setq tmp (getint (strcat "\nSpecify Number of Sections <" (itoa Cbrk:num) "> : ")))
             (setq Cbrk:num tmp))
        (setq i -1)
        (while (setq ent (ssname ss (setq i (1+ i))))
          (setq elst (entget ent) j -1) 
	
          (cond ((eq "CIRCLE" (cdr (assoc 0 elst)))
                   (setq inc (/ (* 2 pi) cBrk:num) st 0.));cond
          (t (progn (setq len (vla-get-arclength (vlax-ename->vla-object ent)) R1 (cdr (assoc 40 elst)))
	     (setq s501 (abs (- (cdr (assoc 51 elst))
                                       (setq st (cdr (assoc 50 elst)))
			 )))
	(if (<= len (* pi R1))
	  (if (> s501 pi) ;big angle but leng arc small
     			
     			(setq inc (/ (- (* 2 pi) s501) cBrk:num))
			(setq inc (/ s501 cBrk:num));setq
	  );if1
	  (if (> s501 pi) ;goc lon	     			    
			(setq inc (/ s501 cBrk:num));setq
	    		(setq inc (/ (- (* 2 pi) s501) cBrk:num))
	  );if1			
  );if
   );progn
  ));cond
          (repeat cbrk:num
            (entmake (list (cons   0 "ARC")
                           (assoc  8  elst)
                           (assoc 10  elst)
                           (assoc 40  elst)
                           (cons  50 (+ st (* (setq j (1+ j)) inc)))
                           (cons  51 (+ st (* (1+ j) inc)))))
            
            (entmake (list (cons   0 "LINE")
                           (assoc  8   elst)
                           (assoc 10   elst)
                           (cons  11 (polar (cdr (assoc 10 elst))
                                            (+ st (* j inc))
                                            (cdr (assoc 40 elst)))))))

          (if (eq "ARC" (cdr (assoc 0 elst)))
            (entmake (list (cons   0 "LINE")
                           (assoc  8   elst)
                           (assoc 10   elst)
                           (cons  11 (polar (cdr (assoc 10 elst))
                                            (+ st (* (1+ j) inc))
                                            (cdr (assoc 40 elst)))))))
          
        (entdel ent))))

 (princ))

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