AutoLISP.com Forum Index  

Go Back   AutoLISP.com Forum Index > AutoCAD > AutoLISP

AutoLISP Ask questions, give examples or troubleshoot your lisp programs. Feel free to post your code here (NO commercial adversiting).

Reply
 
Thread Tools Display Modes
Old 07-27-2010, 01:17 PM   #1
jimpcfd
Junior Member
 
Join Date: Sep 2009
Location: hertfordshire, uk
Posts: 5
Default break arcs & circles

Hi i'm looking for some help with a routine, i need it to find all circles and arcs in a drawing and put a break (gap of 5mm) in each, i need it to know the lengths of the arcs & circles so that it would then know how many gaps each arc & circles need.
for example a length of 20mm to 50mm would have 1 5mm gap and 51mm to 100mm would have 2 5mm gaps and 101mm to 150mm would have 3 5mm gaps.

i do have one which was just for line which works well if need i could put it on this post.

thanks
jimpcfd
jimpcfd is offline   Reply With Quote
Old 07-28-2010, 06:08 AM   #2
Tharwat
Member
 
Join Date: May 2010
Posts: 57
Default

Hi.

You can start with this one, but the problem is that the command BREAK couldn't assign a point for Arcs and Circles.

everything is correct, except the command Break , so there might be someone could go forward with it to give a solution.
Code:
(defun c:test (/ objs i all abc)
(if (setq objs (ssget "_x" '((0 . "CIRCLE,ARC"))))
 (progn
  (setq i 0
        all (sslength objs))
    (while (< i all)
     (setq abc (entget (ssname objs i)))
       (command "_.break" abc ........... 20)
          (setq i (1+ i))
          ))
  (alert "*** No Arcs or Circles found ***" ))
  (princ)
  )
Regards,

Tharwat
Tharwat is offline   Reply With Quote
Old 07-28-2010, 08:15 AM   #3
jimpcfd
Junior Member
 
Join Date: Sep 2009
Location: hertfordshire, uk
Posts: 5
Default break arcs & circles

i do have a routine which i've had for many year, which allows you to select arcs & circlei ndividually.

this is some of it below


; start at end of line and bridge segments to other end
(cond
((equal etype "LINE")
(progn
(setq pt1 (cdr (assoc '10 e)))
(setq pt2 (cdr (assoc '11 e)))
(setq len (distance pt1 pt2))
(setq ang (angle pt1 pt2))
(setq llen (/ (- len (* nbridge width))
nbridge))
(setq llen2 (/ llen 2))
(while (> nbridge 0)
(progn
(setq pt2 (polar pt1 ang llen2))
(setq pt1 (polar pt2 ang width))
(command "_break" "_none" pt2 "_none" pt1)
(setq nbridge (1- nbridge))
(setq llen2 llen)
)
)
))
((equal etype "ARC")
(progn
(setq pt0 (cdr (assoc '10 e))) ; center
(setq rad (cdr (assoc '40 e))) ; radius
(setq ang1 (cdr (assoc '50 e))) ; start angle
(setq ang2 (cdr (assoc '51 e))) ; end angle
(setq ang (abs (- ang1 ang2))) ; arc angle
(setq dir (getvar "ANGDIR"))
(if (or (and (zerop dir) (> ang1 ang2))
(and (= 1 dir) (> ang2 ang1)))
(setq ang (- (* 2 pi) ang))
)
(setq len (* ang rad)) ; arc circumference
(setq llen (/ (- len (* nbridge width))
nbridge))
(setq ang2 (* (/ width len) ang)) ; width angle
(setq ang (* (/ llen len) ang)) ; sector angle
(setq ang1 (+ ang1 (/ ang 2))) ; first break angle
(while (> nbridge 0)
(progn
(setq pt2 (polar pt0 ang1 rad))
(setq pt1 (polar pt0 (+ ang1 ang2) rad))
(command "_break" "_none" pt2 "_none"pt1)
(setq ang1 (+ ang1 ang ang2))
(setq nbridge (1- nbridge))
)
)
))
((equal etype "CIRCLE")
(progn
(setq pt0 (cdr (assoc '10 e))) ; center
(setq rad (cdr (assoc '40 e))) ; radius
(setq ang (* 2 pi))
(setq len (* ang rad)) ; arc circumference
(setq llen (/ (- len (* nbridge width))
nbridge))
(setq ang2 (* (/ width len) ang)) ; width angle
(setq ang (* (/ llen len) ang)) ; sector angle
(setq ang1 (- (/ pi 2) (/ ang2 2))) ; first break angle
(while (> nbridge 0)
(progn
(setq pt2 (polar pt0 ang1 rad))
(setq pt1 (polar pt0 (+ ang1 ang2) rad))
(command "_break" "_none" pt2 "_none" pt1)
(setq ang1 (+ ang1 ang ang2))
(setq nbridge (1- nbridge))
)
)
))
)
(setq sscount (1- sscount))
)
)
); progn
); if
); if
); progn
); if
(setvar "BLIPMODE" blip)
(princ)
)


thanks
jimpcfd
jimpcfd is offline   Reply With Quote
Reply

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

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

Forum Jump


All times are GMT -4. The time now is 11:27 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright © 2010, AutoLISP.com
All Rights Reserved