PDA

View Full Version : Draw 2circles from 1 center point


windowsxp5
2005-09-22, 04:45 PM
Hi to All,
I am looking for a lisp;
Get 2radius by selecting text and Draw 2circles from 1 center point.
An explanation image attaching here:
Thanks in advance

rad.77676
2005-09-22, 06:10 PM
Try this:


(defun c:dbl ()
(setq rad1 (getstring "\n First Radius "))
(setq rad2 (getstring "\n Second Radius "))
(setq cntr (getpoint "\n Select Center Point "))
(if (/= cntr nil)
(progn
(command ".circle" cntr rad1)
(command ".circle" cntr rad2)
)
)

)


Hope this helps!
Rob

rad.77676
2005-09-22, 06:11 PM
oops, guess it would help if I wasn't asleep.
I forgot you want to select text.

Are your labels text or attributes?
Rob

kennet.sjoberg
2005-09-22, 10:24 PM
Here is something for you to start with, but it do not treat stupid text

(defun c:2c (/ Ent1 Ent2 Pkt1 )
(if
(and
(setq Ent1 (car (entsel "Select text: " )) )
(not (redraw Ent1 3 ))
(setq Ent2 (car (entsel "Select text: " )) )
(not (redraw Ent2 3 ))
(setq Pkt1 (getpoint "Select point " ) )
)
(progn
(if (and (= (cdr (assoc 0 (entget Ent1 ))) "TEXT" ) (= (cdr (assoc 0 (entget Ent2 ))) "TEXT" ) )
(progn ; Here can be a lot of pain, text can be 15 15.2 15,2 15Kg and so on, and the only legal type is 15.2 or 15
(if (or (= 0.0 (atof (cdr (assoc 1 (entget Ent1 ))))) (= 0.0 (atof (cdr (assoc 1 (entget Ent2 ))))) )
(alert "One of the text generate a 0 radius \n Quitting !" )
(progn
(command "._circle" Pkt1 (atof (cdr (assoc 1 (entget Ent1 )))) )
(command "._circle" Pkt1 (atof (cdr (assoc 1 (entget Ent2 )))) )
)
)
)
(princ " wrong object type " )
)
)
(princ "not enough input" )
)
(redraw Ent1 4 )
(redraw Ent2 4 )
(princ)
)

: ) Happy Computing !

kennet

windowsxp5
2005-09-24, 11:38 AM
thanks kennet..it works..well done..

thanks Rob..your dbl.lsp also works.. is it posible to Fetch value from attributes to circle command?

xp5

CAB2k
2005-09-24, 03:02 PM
kennet,
You may be better off changing this
(if (or (= 0.0 (atof (cdr (assoc 1 (entget Ent1 ))))) (= 0.0 (atof (cdr (assoc 1 (entget Ent2 ))))) )

to this, as the distof is more forgiving.
(if (or (= 0.0 (distof (cdr (assoc 1 (entget Ent1 ))))) (= 0.0 (distof (cdr (assoc 1 (entget Ent2 ))))) )

kennet.sjoberg
2005-09-25, 01:12 AM
You may be better off changing ...to this, as the distof is more forgiving.
Yes, correct ab2draft, but as a say
Here is something for you to start with...
Actually I do not simply use atof or distof my self, ( I am not so forgiving )
I use a subroutine that check the string from the first character until a space (if it exist)
then check if that part is made of legal characters "0-9" "+" "-" "." and ","
replace the "," with "." and then check again in different ways to see if the sting is legal.

: ) Happy Computing !

kennet

peter
2005-09-25, 05:44 PM
I was just thinking that we should have a function that acted like an entsel function but allowed the user to include a selection set filter like the ssget function.

Like this

The syntax to allow for a single selection of text is:

(entselwithfilter '(list (cons 0 "text")) "Select text: ")

Peter Jamtgaard P.E.


(defun entselWithFilter (lstOfFilters strPrompt / ssSelections)
(vl-load-com)
(if strPrompt
(princ (strcat "\n" strPrompt))
)
(while (not (setq ssSelections (ssget ":S:E" (eval lstOfFilters))))
(princ "\nInvalid Selection Please Select Again: ")
)
(list (ssname ssSelections 0) (getvar "lastpoint"))
)