eyal Posted February 16, 2017 Share Posted February 16, 2017 Hi guys, I have a beautifull lisp that I found that creates lines at specific devisions from the user , my snap settings are usually on ( I select all my object snap so I can pick every point as my cusor change ) but when I want to use my lisp again I need to select all the object snap again. How can I keep my setting so it will not erase them? LINE_DIV.lsp Quote Link to comment Share on other sites More sharing options...
OMEGA-ThundeR Posted February 16, 2017 Share Posted February 16, 2017 You could add an command to fix the osnap again. I wouldn't know what changes the settings, but you can restore it (command "-osnap" "endpoint,midpoint,center,node,quadrant,tangent") Add and/or delete the snaps you want, and place this line of code somewhere (or at the end) of your lisp. Quote Link to comment Share on other sites More sharing options...
eyal Posted February 16, 2017 Author Share Posted February 16, 2017 Hi OMEGA-ThundeR, Thank you for responding but it didn't solve my problem. I added your code to last of my lisp and it seems to erase the setting again. maybe something is missing in your code, please check. I don't know how to check or write lisps. Thank you. Quote Link to comment Share on other sites More sharing options...
OMEGA-ThundeR Posted February 16, 2017 Share Posted February 16, 2017 Hmz.. strange... i shall test the code myself... brb Quote Link to comment Share on other sites More sharing options...
OMEGA-ThundeR Posted February 16, 2017 Share Posted February 16, 2017 Ok, i guess it has something to do with the 'osmode' variable and that will probably fix (or is) the problem but i don't know how to. But after adding the line of code after; (setvar 'osmode 16384) (somewhere in the first few lines of code in the lisp) i kinda got it to fix the snappoints again. so it would become something like this: (setvar 'osmode 16384) (command "-osnap" "endpoint,midpoint,center,node,quadrant,tangent") (setq spaces (test spaces1 ()) It's an dirty fix i guess. Someone else might give a better sollution. Quote Link to comment Share on other sites More sharing options...
eyal Posted February 16, 2017 Author Share Posted February 16, 2017 Thank you OMEGA-ThundeR, I found a solution. here is the fixed code. (defun c:somefunc (/ f curlayer curosmode ent exit a b spaces spaces1 testlst vlaobj1 vlaobj2 x y z) (defun *error* (msg) (setvar 'osmode curosmode) (princ msg) (princ) );defun error (while (setq vlaObj1 (vlax-ename->vla-object (setq ent (car (entsel)))) vlaObj2 (vlax-ename->vla-object (car (entsel))) curlayer (getvar 'clayer) curosmode (getvar 'osmode) spaces1 (getreal "\nEnter number of spaces: ")) (cond ((or (minusp spaces1) (< spaces1 1)) "Spaces should be greater than 1") (T (setvar 'clayer (cdr (assoc 8 (entget ent)))) (setvar 'osmode 16384) (setq spaces (test spaces1 ()) testlst (vl-sort (apply 'append (mapcar '(lambda (y) (mapcar '(lambda (x) (append (append (list (distance x y)) (list x)) (list y))) (list (vlax-curve-getStartPoint vlaObj1) (vlax-curve-getEndPoint vlaObj1)))) (list (vlax-curve-getStartPoint vlaObj2) (vlax-curve-getEndPoint vlaObj2)))) '(lambda (x y) (< (car x) (car y)))) a (cdar testlst) b (cdr (apply 'append (car (mapcar '(lambda (y) (mapcar '(lambda (x) (if (not (or (equal (cadar testlst) (cadr x) y) (equal (caddar testlst) (caddr x) y) (equal (cadar testlst) (caddr x) y) (equal (caddar testlst) (cadr x) y))) x)) testlst)) (list 1e-15)))))) (command "._undo" "_begin") (test2 a b spaces1 spaces) (command "._undo" "_end") (initget "Yes No") (setq f (cond ((getkword "\nFLip lines [Yes/No] <No>: ")) ("No"))) (cond ((wcmatch f "Yes,Y") (command "._undo" 1) (setq z (last a)) (setq a (cons (car a) (cdr b))) (setq b (cons (car b) (list z))) (test2 a b spaces1 spaces)) (T ()))))) (setvar 'clayer curlayer) (setvar 'osmode curosmode) (*error*) ) (defun test (x y) (cond ((< x 1) y) (T (test (fix (- x 1)) (cons (fix x) y))))) (defun test2 (a b c d) (mapcar '(lambda (x y) (command-s "._pline" x y "")) (mapcar '(lambda (x) (polar (car a) (angle (car a) (cadr a)) (* (/ (distance (car a) (cadr a)) c) x))) (if (not (zerop (rem c (fix c)))) d (cdr (reverse d)))) (mapcar '(lambda (x) (polar (car b) (angle (car b) (cadr b)) (* (/ (distance (car b) (cadr b)) c) x))) (if (not (zerop (rem c (fix c)))) d (cdr (reverse d)))))) Quote Link to comment Share on other sites More sharing options...
tombu Posted February 16, 2017 Share Posted February 16, 2017 Hi guys, I have a beautifull lisp that I found that creates lines at specific devisions from the user , my snap settings are usually on ( I select all my object snap so I can pick every point as my cusor change ) but when I want to use my lisp again I need to select all the object snap again. How can I keep my setting so it will not erase them? I modified the start of your code removing "EXIT" in defun as you shouldn't redefine autolisp functions and it wasn't used in your code anyway. I added an *error* function and localized it by adding *error* to the defun to make sure the variables were reset while not affecting *error* for any other lisp. Then moved setting curosmode & curlayer to the top outside the while loop so it would only be set once. Try replacing the start of your code with: (defun c:somefunc (/ *error* f curlayer curosmode ent a b spaces spaces1 testlst vlaobj1 vlaobj2 x y z) (defun *error* (msg) (setvar 'osmode curosmode) (setvar 'clayer curlayer) (princ msg) (princ) );defun error (setq curosmode (getvar 'osmode) curlayer (getvar 'clayer) ) (while (setq vlaObj1 (vlax-ename->vla-object (setq ent (car (entsel)))) vlaObj2 (vlax-ename->vla-object (car (entsel))) spaces1 (getreal "\nEnter number of spaces: ")) (cond ((or (minusp spaces1) (< spaces1 1)) "Spaces should be greater than 1") Quote Link to comment Share on other sites More sharing options...
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.