![]() |
|
|||||||
| AutoLISP Ask questions, give examples or troubleshoot your lisp programs. Feel free to post your code here (NO commercial adversiting). |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Sep 2009
Location: hertfordshire, uk
Posts: 5
|
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 |
|
|
|
|
|
#2 |
|
Member
Join Date: May 2010
Posts: 57
|
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)
)
Tharwat |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Sep 2009
Location: hertfordshire, uk
Posts: 5
|
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 |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|