mike3_21_21 Posted May 14, 2015 Share Posted May 14, 2015 I've just learned that some of our old LISP do not work in C3D 2016 and was looking for some help. Any help would be appreciated and here is an example of one LISP that is not working anymore. (defun C:ROSNAP () (graphscr) (setq oldsnap (getvar "osmode")) (setq smd (getvar "snapmode")) (setq tll (entsel "Select Object: ")) (setq tlle (car tll)) (setq pt1 (cadr tll)) (setq nme (cdr (assoc 0 (entget tlle)))) (if (= nme "LINE") (progn (setq pt2 (osnap pt1 "mid,qui")) (setq pt3 (osnap pt1 "end,qui")) (command "SNAP" "R" pt2 pt3))) (if (= nme "POLYLINE") (progn (setq pt2 (osnap pt1 "mid,qui")) (setq pt3 (osnap pt1 "end,qui")) (command "SNAP" "R" pt2 pt3))) (if (= nme "ARC") (progn (setq pt2 (osnap pt1 "end,qui")) (setq pt3 (osnap pt1 "cen,qui")) (command "SNAP" "R" pt2 pt3))) (setvar "snapmode" smd) (setvar "osmode" oldsnap) ) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 14, 2015 Share Posted May 14, 2015 This is a known problem and you need to change COMMAND to VL-cmdf or Command-s Quote Link to comment Share on other sites More sharing options...
mike3_21_21 Posted May 14, 2015 Author Share Posted May 14, 2015 This is a known problem and you need to change COMMAND to VL-cmdf or Command-s Please point me in the direction of where I can learn more about this known issue. Thanks. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 15, 2015 Share Posted May 15, 2015 (edited) Just Google, I have to change a heap of code too. I just did around 60 in one go. ; this is the core so need to add findfile etc ; Convert command to command-s ; by BIG-AL May 2015 ; add rename and findfile (defun AH:command-s (exfile / newfile fo f2) (vl-load-com) (setq newfile (strcat exfile ".BAK")) (vl-file-rename exfile newfile) (setq fo (open newfile "R")) (setq f2 (open exfile "w")) (while (setq str (read-line fo)) (setq str (VL-string-subst "COMMAND-S" "COMMAND" (strcase str) )) (princ (strcat "\n" str)) (write-line str f2) ) (close fo) (close f2) (princ) ) (ah:command-s "C:/Temp/test.lsp") ; just add lots of lisps here Edited May 15, 2015 by BIGAL Quote Link to comment Share on other sites More sharing options...
mike3_21_21 Posted May 15, 2015 Author Share Posted May 15, 2015 What is the better replacement VL-cmdf or Command-s? Quote Link to comment Share on other sites More sharing options...
mike3_21_21 Posted May 15, 2015 Author Share Posted May 15, 2015 This is a known problem and you need to change COMMAND to VL-cmdf or Command-s It's not quite this simple. I've tried both and neither work for my original example in the first post. Quote Link to comment Share on other sites More sharing options...
tombu Posted May 15, 2015 Share Posted May 15, 2015 Command-s should work, good read: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/vlisp-what-to-do-with-command-s/td-p/5058168?nobounce What kind of error or output did you have with it? Quote Link to comment Share on other sites More sharing options...
mike3_21_21 Posted May 15, 2015 Author Share Posted May 15, 2015 Command-s should work, good read: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/vlisp-what-to-do-with-command-s/td-p/5058168?nobounceWhat kind of error or output did you have with it? I've read this with a big question mark over my head. I'd like to point out my problem is in C3D 2016. In my original LISP I get this error: Command: RoSnap Select Object: SNAP Command: r Unknown command "R". Press F1 for help. After changing "command" to "command-s" I get this error: Command: RoSnap Select Object: Application ERROR: Invalid type sent as command input ; error: Unknown (command-s) failure. Quote Link to comment Share on other sites More sharing options...
tombu Posted May 15, 2015 Share Posted May 15, 2015 While the "R" option works in 2015 it's no longer listed as an option. I haven't installed 2016 yet, have you tried at the command line to see if "Snap R " works in 2016? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 16, 2015 Share Posted May 16, 2015 When I looked at your code I thought this is interesting method never seen rotations done this way before. You may have to rewrite to rotate an entity about a point. Quote Link to comment Share on other sites More sharing options...
tombu Posted May 16, 2015 Share Posted May 16, 2015 (edited) Try this: (defun C:ROSNAP (/ tll tlle pt1 pt2 pt3) (graphscr) (setq tll (entsel "Select Object: ")) (if tll (setq tlle (car tll) pt2 nil pt1 (cadr tll) nme (cdr (assoc 0 (entget tlle))))) (cond ((= nme "LINE")(setq pt2 (osnap pt1 "midp") pt3 (osnap pt1 "endp"))) ((= nme "POLYLINE")(setq pt2 (osnap pt1 "midp") pt3 (osnap pt1 "endp"))) ((= nme "LWPOLYLINE")(setq pt2 (osnap pt1 "midp") pt3 (osnap pt1 "endp"))) ((= nme "ARC")(setq pt2 (osnap pt1 "endp") pt3 (osnap pt1 "cen"))) ) (if pt2 (setvar "snapang" (- (angle pt2 pt3)pi))) (princ) ) Related code you may find helpful: ;| FIX CROSSHAIRS - toggles snap angle between zero & horizontal in twisted views BY: TOM BEAUFORD BeaufordT@LeonCountyFL.gov LEON COUNTY PUBLIC WORKS ENGINEERING SECTION ID_SnpAng [Toggle Snap Angle]^P(if(not C:fix)(load "fix_hair"));'fix ==================================================================|; (defun c:fix () (if(= (+ (getvar "snapang")(getvar "viewtwist")) (* 2 PI)) (setvar "snapang" 0.0) (setvar "snapang" (- (getvar "viewtwist"))) ) (princ) ) Edited May 16, 2015 by tombu Add related code Quote Link to comment Share on other sites More sharing options...
Dadgad Posted May 16, 2015 Share Posted May 16, 2015 Osmode values used in lisps may be invalidated by the addition of the new geometric center snap option. Quote Link to comment Share on other sites More sharing options...
tombu Posted May 18, 2015 Share Posted May 18, 2015 Osmode values used in lisps may be invalidated by the addition of the new geometric center snap option. His original code stored the osmode and snapmode values to reset them at the end of the code. Oddly the code never modified either one so I removed them from the modified version I posted. I don't have 2016 installed so I figured setting the snapang value rather than a command call would solve the problem. Thanks for the heads up though, when I do get 2016 I'll have to check all my code for references to osmode. Bitcode 1024 has changed from "Clears all object snaps" to "Geometric CEnter". Currently bitcode 16384 is what I check for to see if osnaps are turned on, in 2016 can I assume that will be 32768? Quote Link to comment Share on other sites More sharing options...
mike3_21_21 Posted May 18, 2015 Author Share Posted May 18, 2015 When I looked at your code I thought this is interesting method never seen rotations done this way before. You may have to rewrite to rotate an entity about a point. I can't take credit for this code. It was written years ago before I started working here in '99. Quote Link to comment Share on other sites More sharing options...
mike3_21_21 Posted May 18, 2015 Author Share Posted May 18, 2015 His original code stored the osmode and snapmode values to reset them at the end of the code. Oddly the code never modified either one so I removed them from the modified version I posted. I don't have 2016 installed so I figured setting the snapang value rather than a command call would solve the problem. Thanks for the heads up though, when I do get 2016 I'll have to check all my code for references to osmode. Bitcode 1024 has changed from "Clears all object snaps" to "Geometric CEnter". Currently bitcode 16384 is what I check for to see if osnaps are turned on, in 2016 can I assume that will be 32768? I'm not sure if they ever worked to be honest. This LISP was written long before I ever started working here in '99. Quote Link to comment Share on other sites More sharing options...
tombu Posted May 18, 2015 Share Posted May 18, 2015 I'm not sure if they ever worked to be honest. This LISP was written long before I ever started working here in '99. It worked for a line in 2015. LWPOLYLINE's were introduced in r14 back in 1997. Since they weren't addressed in the code and the "R" Snap option hasn't been listed in help since about that time the code was pretty dated. Did the modified ROSNAP I posted work ok? With Civil/Survey drawing twisted views are the norm so I have a few related macros and routines. Quote Link to comment Share on other sites More sharing options...
mike3_21_21 Posted May 18, 2015 Author Share Posted May 18, 2015 It worked for a line in 2015. LWPOLYLINE's were introduced in r14 back in 1997. Since they weren't addressed in the code and the "R" Snap option hasn't been listed in help since about that time the code was pretty dated. Did the modified ROSNAP I posted work ok? With Civil/Survey drawing twisted views are the norm so I have a few related macros and routines. Yes it works. THANKS. Not the answer I was truly looking for, because I got a few others with "command" in them not working. I'll post here and see what you all think. Quote Link to comment Share on other sites More sharing options...
mike3_21_21 Posted May 18, 2015 Author Share Posted May 18, 2015 Here are just three. I don't want to over stay my welcome here. Now if anyone wants to play I'll upload the whole thing. Heck, I might. Thanks again. (defun C:SPLIT () (graphscr) (setq oldsnap (getvar "osmode")) (setq os (getvar "osmode")) (setvar "osmode" 1536) (setq l1 (getpoint "\nSelect line to be Split: ")) (setq l2 (getpoint "\nSelect Cutting Edge: ")) (setvar "osmode" os) (setq pt1 (osnap l1 "mid,qui")) (setq pt2 (osnap l1 "end,qui")) (setq pt3 (osnap l2 "mid,qui")) (setq pt4 (osnap l2 "end,qui")) (setq pt5 (inters pt1 pt2 pt3 pt4 nil)) (command "BREAK" l1 "F" pt5 "@") (setvar "osmode" oldsnap) ) (defun C:ARROW () (graphscr) (setq oldsnap (getvar "osmode")) (setq player (getvar "clayer")) (setq tll (entsel "Pick Point on Line Nearest End:")) (setq pt1 (cadr tll)) (setq tlle (car tll)) (setq layn (cdr (assoc '8 (entget tlle)))) (setq pt2 (osnap pt1 "end,qui")) (setq pt3 (osnap pt1 "nea,qui")) (setq size (getvar "dimscale")) (command "LAYER" "S" layn "") (command "INSERT" "ARROWHD" pt2 size "" pt3) (command "layer" "s" player "") (setvar "osmode" oldsnap) (setvar "clayer" oldlayer) ) (defun C:AUTODIM1 () (graphscr) (setq oldsnap (getvar "osmode")) (setq oldlayer (getvar "clayer")) (command "-layer" "s" "PR-2-NOTES" "") (setq rnd (getvar "dimzin")) (setq acr (getvar "luprec")) (setq obj1 (entsel "\nSelect Line to Dimension Above: ")) (setq obj2 (car obj1)) (setq pt1 (cdr (assoc '10 (entget obj2)))) (setq pt2 (cdr (assoc '11 (entget obj2)))) (setvar "dimzin" (setq dist (distance pt1 pt2)) (setq txt1 (rtos dist 2 acr)) (setq txt2 (strcat txt1 (chr 039))) (setq pt3 (cadr obj1)) (setq pt4 (osnap pt3 "mid,qui")) (setq pt5 (osnap pt3 "nea,qui")) (setq angler (angle pt4 pt5)) (setq angled (/ (* 180 angler) pi)) (setq perpr (+ angler (/ pi 2))) (setq centerpt (polar pt4 perpr (/ (getvar "dimscale") 16))) (setvar "dimzin" rnd) (command "TEXT" "C" centerpt angled txt2) (setvar "osmode" oldsnap) (setvar "clayer" oldlayer) ) Quote Link to comment Share on other sites More sharing options...
mike3_21_21 Posted May 18, 2015 Author Share Posted May 18, 2015 A co-worker of mine just noticed ",qui" in our codes. We took them out and things seem to be working. I sure like simple fixes. Quote Link to comment Share on other sites More sharing options...
tombu Posted May 18, 2015 Share Posted May 18, 2015 A co-worker of mine just noticed ",qui" in our codes. We took them out and things seem to be working. I sure like simple fixes. The qui or quick option for the osnap command is described in 2015 Help, but not 2016 Help. Guess they finally dropped it, never saw a use for it anyway. 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.