#Multiple Divide Routine
9 messages in this thread
Below is a multiple divide routine I hacked from Tip 389, But I have not
been able to get it to work. Can anyone offer suggestions. (DeFun C:MDIV (/
SS EN)
(PrinC "DIVIDE multiple objects")
(SetQ SS (SSGet))
(While (> (SSLength SS) 0)
(ProgN (SetQ EN (SSName SS 0))
(Command "DIVIDE" EN "10")
(SSDel EN SS) ) ) ) Thanks, Bob.
Robert:
You don't need the (progn and the associated ')'. I also presume that you
have the pdmode and pdsize variables set such that you can see that the
entity division has occurred. I would also recommend that you include a
test for objects that can't be divided (e.g. inserts).
C#
Sheesh, good thing you're not that far off the mark when you're playing horse
shoes… You could kill someone<g>.
The DIVIDE and MEASURE commands require an (<ename> <point>) list.
-TonyT.
Tony:
Well, I didn't reply that I knew what the problem was… what I said was
accurate, and I plead innocence (a faint excuse designed to disguise what
others would call stupidity <g>). I've never used Divide or Measure in a
LISP routine…<g>.
C#
Bob,
wow! that's one heckuva way to capitalize! Boggles the eyes!
When passing an entity to commands such as DIVIDE (and BREAK etc.), you
want to provide both an entity and a point pick (like what ENTSEL gives
you). So do this:
(command "DIVIDE" (list en (cdr (assoc 10 d))) "10")
Of course this will only work for line and polylines.
Also, the PROGN is superflous.
Anil
Thanks for the help. I'II revise my use of capitals.
Bob
Robert – The DIVIDE and MEASURE commands require a list containing both the
entity name, and the selection point. You could kluge it like this:
(command "divide" (list en '(0 0 0)) "10")
-TonyT.
Thank you. Your suggestion (kluge) works just fine.
Bob
Robert – Hey, nice job of hacking; I like the way you handle the multiple
entities. The reason that it fails is that DIVIDE rquires a list of the
entity name and an a pick point (see entsel for an example). I used
(list en (cdr(assoc 10 (entget en))))
as the input to the DIVIDE command. I made a few other changes, too, just
for grins:
(defun c:mdiv (/ ss en pt)
(while (setq ss (ssget))
(while (setq en (ssname ss 0))
(setq pt (cdr (assoc 10 (entget en))))
(command ".divide" (list en pt) 10)
(ssdel en ss)
)
)
(princ)
)