1958 Posted December 28, 2023 Posted December 28, 2023 Added some convenience: (defun c:11 (/ p0 ang dist) (defun 11error (errormsg /) (setvar "SNAPANG" old_snapang) ; reset variables (setvar "ORTHOMODE" old_orthomode) (setq *error* temperr) ; reset *error* (prompt "\nFunction Canelled.") ) (vl-load-com) (setq p0 (getpoint "Pick the first point >") ang (angtof (rtos (getreal "Enter angle >")) 0) ) (setq Old_snapang (getvar "SNAPANG")) ; to record what it was, might not be 0 (setq old_orthomode (getvar "ORTHOMODE")) (setq temperr *error*) ;store *error* ; can wait till here to set error function, after recording old variables (setq *error* 11error) (setvar "SNAPANG" ang) (setvar "ORTHOMODE" 1) (setq dist (distance p0 (getpoint p0 "Pick a second point >"))) (setvar "SNAPANG" Old_Snapang) ; moved this here, seto to old value (no assumption what it was) (setvar "ORTHOMODE" old_orthomode) (entmakex (list (cons 0 "LINE") (cons 10 p0) (cons 11 (polar p0 ang dist)))) (setq *error* temperr) ; reset error (princ) ) 2 Quote
Steven P Posted December 28, 2023 Posted December 28, 2023 47 minutes ago, Nikon said: (defun c: 35 ......... (defun c: 50 ........ (defun c: 68 .......... You can continue the list of angles I have over 100 lisps in automatic download. Opening files in AutoCAD takes a little longer, that's why I'm trying to make simple codes using macros... Speed is always a compromise between loading and running the automation and doing it manually. For example if I had routines that I used once a year that took 1/10th second to load each then it might not be optimistic to load them on every drawing. If I had routines that I used in virtually every drawing then even that 1/10th second each it is well worth loading them, BigAl usually has to hand or in his memory a line that loads a LISP on command, so you could type in '30' if the command isn't loaded then it is loaded. Makes opening drawings quicker (I think you need the LISPs in a trusted file location?). 1 Quote
Steven P Posted December 28, 2023 Posted December 28, 2023 28 minutes ago, 1958 said: Added some convenience: (defun c:11 (/ p0 ang dist) (defun 11error (errormsg /) (setvar "SNAPANG" old_snapang) ; reset variables (setvar "ORTHOMODE" old_orthomode) (setq *error* temperr) ; reset *error* (prompt "\nFunction Canelled.") ) (vl-load-com) (setq p0 (getpoint "Pick the first point >") ang (angtof (rtos (getreal "Enter angle >")) 0) ) (setq Old_snapang (getvar "SNAPANG")) ; to record what it was, might not be 0 (setq old_orthomode (getvar "ORTHOMODE")) (setq temperr *error*) ;store *error* ; can wait till here to set error function, after recording old variables (setq *error* 11error) (setvar "SNAPANG" ang) (setvar "ORTHOMODE" 1) (setq dist (distance p0 (getpoint p0 "Pick a second point >"))) (setvar "SNAPANG" Old_Snapang) ; moved this here, seto to old value (no assumption what it was) (setvar "ORTHOMODE" old_orthomode) (entmakex (list (cons 0 "LINE") (cons 10 p0) (cons 11 (polar p0 ang dist)))) (setq *error* temperr) ; reset error (princ) ) There is a slightly more optimised way to set and reset variables once you get more than about 2 or 3: ;;Include near the beginnin of the code: (setq vars '("CMDECHO" "NOMUTT" "SNAPANG")) ;; Variables to change as a list (setq old_Vars (mapcar 'getvar vars)) ;; get existing variable values (mapcar 'setvar vars '(0 1 1)) ;; set variables to new values (in order of the list above) ;;Reset the variables (mapcar 'setvar vars old_Vars) Change to suit. 2 Quote
Nikon Posted December 28, 2023 Author Posted December 28, 2023 (edited) On 28.12.2023 at 14:52, 1958 said: Added some convenience: They seem to work the same way... Edited January 7 by Nikon Quote
Nikon Posted December 28, 2023 Author Posted December 28, 2023 54 minutes ago, Steven P said: BigAl usually has to hand or in his memory a line that loads a LISP on command, so you could type in '30' if the command isn't loaded then it is loaded. Makes opening drawings quicker (I think you need the LISPs in a trusted file location?). I've been worried about the question for a long time: how can I upload lisps by name from some list (for example, in dwg), and not add rarely used ones to the startup... Quote
Steven P Posted December 28, 2023 Posted December 28, 2023 1 hour ago, Nikon said: 1958, please explain what convenience? They seem to work the same way... open up bother versions in their own notepad or similar and compare them side by side - a good way to learn, spot the difference and consider what was done and why? 1 Quote
1958 Posted December 28, 2023 Posted December 28, 2023 2 hours ago, Nikon said: 1958, please explain what convenience? They seem to work the same way... In the latter option, the dotted line indicates the direction along a given angle, rather than following the cursor. I apologize, but I and the author of the topic are Russian speakers, so I will repeat the answer in Russian. В последнем варианте пунктирная линия указывает направление по заданному углу, а не бегает за курсором. 1 1 Quote
1958 Posted December 28, 2023 Posted December 28, 2023 3 hours ago, Steven P said: There is a slightly more optimised way to set and reset variables once you get more than about 2 or 3 Thanks a lot for the tip! There are many things I don't know yet, I'm still learning, although I will soon be 66 years old. 2 Quote
Nikon Posted December 28, 2023 Author Posted December 28, 2023 (edited) On 28.12.2023 at 19:02, 1958 said: В последнем варианте пунктирная линия указывает направление по заданному углу, а не бегает за курсором Да, это действительно так. Edited January 6 by Nikon Quote
BIGAL Posted December 29, 2023 Posted December 29, 2023 (edited) (autoload "COPY0" '("COPY0")) (autoload "COPYCOMMAND" '("ZZZ")) (autoload "COVER" '("COVER")) (autoload "DIMFLIP" '("DIMFLIP")) (autoload "DRAWXFALL" '("DRAWXFALL")) (autoload "DRAWPIPE" '("DRAWPIPE")) (autoload "EDITRL" '("EDITRL")) Load on demand is easy just put in a startup lisp that is automatically loaded. Thinking some more though easier to put in a menu as an option. Load a lisp with all the defuns in it. I would make something like type A30 on command line and it runs a lisp that splits the A & 30. Look at attached code it does circles, fillet, offset etc F123 C345. Again load as required, if only every now and then. fillet reactor.lsp Edited December 29, 2023 by BIGAL 1 Quote
Nikon Posted December 29, 2023 Author Posted December 29, 2023 (edited) @BIGAL thank you very much, I don't really understand how it works yet, but I'll figure it out... Edited January 6 by Nikon Quote
Nikon Posted December 29, 2023 Author Posted December 29, 2023 Here is another macro for the angled line (an alternative to the above lisp): ^C^C_Ortho;_On;_snapang;\_LINE;\_'snapbase 0,0;\_'snapang 0; Quote
BIGAL Posted December 29, 2023 Posted December 29, 2023 For Nikon you can not use "." in the value you need to use "-" so F123-45 will work. The "." is a valid character in the input and gets treated different to a decimal point. So A30 would set the snapang to 30, then ask for pt1 pt2. If you get stuck just ask, can have 26 functions A-Z, C, O & F used. 1 Quote
Nikon Posted December 29, 2023 Author Posted December 29, 2023 (edited) On 29.12.2023 at 03:26, BIGAL said: (autoload "COPY0" '("COPY0")) When I type in the command line (autoload "11" '("11")) ; error: too many arguments How to make lisp load and immediately start executing the command. Edited January 7 by Nikon Quote
Steven P Posted December 29, 2023 Posted December 29, 2023 (edited) I think: (autoload "<fileName>" '("<LISP Name 1>" "<LISPName 2>")) ; where <LISPName x> are LISPs contained in <filename> The file should be saved in your trusted locations, no need to include the extension '.LSP' I think, might be wrong Edited December 29, 2023 by Steven P 1 Quote
Steven P Posted December 29, 2023 Posted December 29, 2023 Another alternative is create load of small LISPs in a single file, where the LISP name is what you want, and take away the "c:" prefix from the actual LISP to use - should be fairly fool proof if not the most elegant. Load this file at start-up (defun c:testthis ( / ) (load "....filepath....\\a.lsp" "a.lsp Failed to Load") ;;Using full path and not variable (testthis) ) 1 Quote
Nikon Posted December 29, 2023 Author Posted December 29, 2023 (edited) On 29.12.2023 at 13:16, Steven P said: (autoload "<fileName>" '("<LISP If the name is lisp - "11" and the call command is also "11" (_autoload "<11>" '("<11>")) ; error: too many arguments Or like this: (_autoload "11.lsp" '("<11>")) ; error: too many arguments Edited January 6 by Nikon Quote
Nikon Posted December 29, 2023 Author Posted December 29, 2023 3 hours ago, Steven P said: (autoload "<fileName>" '("<LISP (defun c:testthis ( / ) (load "C:\Program Files\Autodesk\AutoCAD 2015\Support \\a.lsp" "a.lsp Failed to Load") ;;Using full path and not variable (testthis) ) Command: LOAD ; error: too few arguments ? ? ? Quote
Steven P Posted December 29, 2023 Posted December 29, 2023 Got to apply these to your own circumstances. The < > are just to highlight what is expected so it <Filename> might be replaced be "11" The second option should work if you replace the details with your specific LISP file name instead of a.lsp. You might need to use double \\ instead of single in the file path 1 Quote
BIGAL Posted December 29, 2023 Posted December 29, 2023 (edited) The last line in the 11.lsp needs to be (c:11) this will run it once it is loaded. From then if needing to do again typing 11 will run it. (defun c:11 ( / ..... ..... .. ) (c:11) I think it would be easier though to have a menu option to do snapang line the menu can have a sub menu with all the angles. You can then use the menu for next or type the angle. Use ^c^c^p(if (not 11)(load "11")) 11 in the menu. Happy to help making a menu you can see how many options we had. Most of the menu's used a Load function. Edited December 29, 2023 by BIGAL 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.