Mocaffiene Posted April 1, 2021 Posted April 1, 2021 I've got a code that can draw a line offset from where a user clicks two locations and i can only get it to offset by 2 or more. for some reason anytime i try to offset by 1 is draws the line directly on top of old line (setq pt1 (getpoint "\nSelect Start Point: ")) ;GETS LOCATION OF FIRST MOUSE CLICK (setq pt2 (getpoint "\nSelect End Point: ")) ;GETS LOCATION OF SECOND MOUSE CLICK (setq ptx1 (car pt1)) ;ptx1 is x-coor of pt1 (setq pty1 (cadr pt1)) ;pty1 is y-coor of pt1 (setq ptx2 (car pt2)) ;ptx2 is x-coor of pt2 (setq pty2 (cadr pt2)) ;pty2 is y-coor of pt2 (setq ptx4 (+ ptx2 1)) (setq pty4 (+ pty2 1)) (setq ptx5 (- ptx1 1)) (setq pty5 (+ pty1 1)) (setq pt4 (list ptx4 pty4 0)) (setq pt5 (list ptx5 pty5 0)) (command "LINE" pt4 pt5 "") Quote
Mocaffiene Posted April 1, 2021 Author Posted April 1, 2021 figured it out. have to disable object snapping before placing new line Quote
Lee Mac Posted April 1, 2021 Posted April 1, 2021 As you've discovered, point input supplied to AutoLISP command calls will be impacted by any Object Snap modes active at the time that the command is invoked. However, rather than disabling Object Snap or modifying the OSMODE system variable (which in turn would requre the use of a local error handler to ensure that the original environment is restored), you can override all active snap modes by preceding the point input with the "_non" or "_none" modifier, e.g.: (command "_.LINE" "_non" pt4 "_non" pt5 "") I describe this technique in my detail in my post here. Quote
Lee Mac Posted April 1, 2021 Posted April 1, 2021 To offer some food for thought, it is also worth noting that your code could be equivalently written in the following way: (if (and (setq p (getpoint "\nSpecify start point: ")) (setq q (getpoint p "\nSpecify end point: ")) ) (command "_.line" "_non" (mapcar '+ q '(1 1)) "_non" (mapcar '+ p '(-1 1)) "") ) 1 Quote
rkmcswain Posted April 1, 2021 Posted April 1, 2021 @Lee Mac - am I remembering right..... if you use (entmake) - running object snaps are ignored? Quote
Lee Mac Posted April 1, 2021 Posted April 1, 2021 16 minutes ago, rkmcswain said: @Lee Mac - am I remembering right..... if you use (entmake) - running object snaps are ignored? Your memory serves you correctly @rkmcswain - though if using entmake, the defining coordinates must also be translated from UCS to WCS, and so this may be intimidating for a novice. Quote
devitg Posted April 1, 2021 Posted April 1, 2021 I do not understand, it do not offset , meaning offset to be parallel Quote
BIGAL Posted April 2, 2021 Posted April 2, 2021 Something like this note side is based on p1 p2 direction. (defun c:test ( / ang off p1 p2 p3 p4) (if (and (setq p1 (getpoint "\nSpecify start point: ")) (setq p2 (getpoint p1 "\nSpecify end point: ")) ) (progn (setq ang (angle p1 p2)) (setq off (getreal "\nEnter offset value ")) (setq p3 (polar p1 (+ ang (/ pi 2.0)) off)) (setq p4 (polar p2 (+ ang (/ pi 2.0)) off)) (command "_.LINE" "_non" p3 "_non" p4 "") ) ) (princ) ) Quote
rkmcswain Posted April 2, 2021 Posted April 2, 2021 4 hours ago, Lee Mac said: the defining coordinates must also be translated from UCS to WCS, and so this may be intimidating for a novice. No worries @Lee Mac, novices are restricted to only working in WCS. 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.