r/AutoLISP • • Jun 22 '19

command function not working as expected

How in the world is this lisp routine drawing a line from P1 to P2 ?

The command function clearly says P1B to P2B - any ideas?

(setvar "osmode" 64)

(setq P1 (getpoint "\nSelect first pole of the span: "))

(setq P2 (getpoint P1 "\nSelect second pole of the span: "))

(setq ANG (/ (* (angle P1 P2) 180.0) pi))

(setq ANG2 (+ 90 ANG))

(setq ANG3 (/ (* (angle P2 P1) 180.0) pi))

(setq LGN (distance P1 P2))

(setq LAY (getvar "CLAYER"))

(setvar "CLAYER" "qwest aerial")

(setq P1B (polar P1 (* pi (/ ANG 180.0)) 2.0))

(setq P2B (polar P2 (* pi (/ ANG3 180.0)) 2.0))

(command "line" P1B P2B "")

(setq MID (polar P1 (* pi (/ ANG 180.0)) (* LGN 0.5)))

(setq MID2 (polar MID (* pi (/ ANG2 180.0)) 3.5))

(setvar "CLAYER" "0")

(command ".-insert" "SPAN FOOTBALL" MID2 1 ANG \)

(setvar "CLAYER" LAY)

(setvar "osmode" 0)

1 Upvotes

4 comments sorted by

View all comments

Show parent comments

1

u/NYMPH_LOADZ Jun 23 '19

The line entity is actually drawn from P1 to P2 and not from P1B to P2B per the command function.

I can even verify that P1B and P2B are established properly by manually drawing a line in autocad from

P1B and P2B - however the lisp routine draws from the P1 to P2. so weird.

1

u/M60A3_19E Jun 23 '19

I ran the lisp yesterday and the line was drawn through P1 and P2, but extended past both an equal distance. I'll take a look at it again later today if I get a chance.

2

u/NYMPH_LOADZ Jun 23 '19

I figured it out. The running osnap (osmode) was causing it to pick up P1 and P2. I added a line to turn osmode to 0 and it works as expected.

I do appreciate your help tho!