Yes, it probably does, and what it would do wrong would depend on which
Osnap modes you have running. In the left drawing, the points it calculates
at intermediate places along the width of the circular end are going to
osnap to the end or mid (or whatever you have on) of the pre-existing line
you selected the endpoints of. But in the right example, there's no line
there, so there's nothing to osnap to (unless there's something else in the
neighborhood when you do this in an actual drawing). Osnap modes won't
affect the routine's calculation of the various points, only the result of
osnap applied to them in the process of its drawing something.
In addition to Bob's suggestion, another easy thing is to turn off running
Osnap anywhere after the four points are selected and before the Pline
command function. The simplest way to do that would be something like:
(setvar "osmode" 0)
But if you want to restore them afterwards, you should precede that with
something like:
(setq osmodes (getvar "osmode"))
to save whatever the setting is before you turn it off, and after the
transition is drawn, restore it with something like:
(setvar "osmode" osmodes)
There are other ways to do it, too (look into the lisp 'osnap' function with
'non' applied through it, or look at the 16384 bitcode in the Osmode System
Variable, which you can add to the current value instead of setting it to
zero), but this is pretty common (you'll find similar code in lots of
examples on the Newsgroup).
--
Kent Cooper
wrote...
I wrote a program to make a duct transition from rectangular to round (in
2D). The user is prompted to select the two endpoints of the rectangular
duct and then the two endpoints of the round duct. Then it should draw the
required lines based on the four points. I didn't do anything with the
OSMODE because I wanted to use my regular snaps to select the endpoint of
the line. When I run the program the result is different depending on the
characteristics of the lines that I take the en
dpoints of. For example, if I have two lines representing each end of the
transition and pick the two endpoints of the one line and then the two
endpoints of the other line it draws the transition incorrectly. However,
if I draw four lines representing each side of the ends of the two ducts
with the transition in the same place I get the correct result. I'm
guessing it has something to do with the OSMODE stuff. Any suggestions?
Here is the code. I am also attaching a clip of the
two different issues.
(defun *error* (msg)
(princ msg)
(princ)
)
;;This program creates a rectangular to round transition
(defun c:rect2rnd4 ()
;;Define the points for the rectangular end of the transition
(setq ptl1 (getpoint "\nSelect first rectangular point"))
(setq ptl2 (getpoint "\nSelect second rectangular point"))
;;Define the points for the round end of the transition
(setq ptl3 (getpoint "\nSelect the first round point"))
(setq ptl4 (getpoint "\nSelect the second round point"))
;;Define the angle of the ductwork
(setq theta1 (angle ptl2 ptl1))
(setq theta2 (angle ptl4 ptl3))
;;Determine the round duct diameter
(setq rounddia (distance ptl3 ptl4))
(setq rectwidth (distance ptl1 ptl2))
(If (>= theta1 pi)
(progn
(setq theta1 (- theta1 pi))
(setq pttemp ptl1)
(setq ptl1 ptl2)
(setq ptl2 pttemp)
)
)
(If (>= theta2 pi)
(progn
(setq theta2 (- theta2 pi))
(setq pttemp ptl3)
(setq ptl3 ptl4)
(setq ptl4 pttemp)
)
)
;;Create
the transition
(command "_pline"
(polar ptl4 theta2 (* rounddia 0.75))
"_w" 0 0
ptl1
(polar ptl4 theta2 (* rounddia 0.5))
ptl2
(polar ptl4 theta2 (* rounddia 0.25))
""
)
(princ)
)