lalcalac Posted March 5, 2017 Posted March 5, 2017 Hi everyone, im kinda new in Autolisp function and im trying to find/figure a routine that zoom extends, purges the drawing, set all line weights to default and quick save the file, if anyone already has something like this i would really apretiate the help. i´ve been also trying to figure a lisp that extends / stretch both lines of a specific corner a certain distance. As i said before, i really apretiate the help u could give. Thanks b4! Quote
Dadgad Posted March 6, 2017 Posted March 6, 2017 (edited) Welcome to CADTutor lalcalac. There is a great functionality in Autocad, which I think is largely overlooked, and very easy to use. The ACTION RECORDER is a keystroke recorder, which I use all the time. It can be accessed in the right click shortcut menu, to create macros on the fly, or to access those which you have created and saved previously. Edited March 6, 2017 by Dadgad Quote
BIGAL Posted March 6, 2017 Posted March 6, 2017 Or the old fashioned way open notepad and copy every step typed manually 1 line at a time, you may need to use a "-" in front so as to turn off the dialog prompts eg "-purge B" purges blocks, you also need a blank line where you need to press enter to exit then save the file as a script file Mycleanup.scr note the ".scr", to run type "Script mycleanup" -purge all * N qsave y Quote
lalcalac Posted March 6, 2017 Author Posted March 6, 2017 I didnt knew this Action Recorder, and i gotta say, is amazing, i kinda mixed the hints that u and Bigal gave me and it worked perfectly, now i just have to figure out how to do the corner thing, u guys are amazing, thanks a lot!!! Quote
Dadgad Posted March 6, 2017 Posted March 6, 2017 (edited) I didnt knew this Action Recorder, and i gotta say, is amazing, i kinda mixed the hints that u and Bigal gave me and it worked perfectly, now i just have to figure out how to do the corner thing, u guys are amazing, thanks a lot!!! Outstanding news, very glad that you like it! I really think a lot of folks have never tried or noticed it. As I don't write lisp myself, it is incredibly helpful to have this available on the fly. It can be a real timesaver when dealing with highly repetitive tasks. Try using it on that corner treatment. Edited March 6, 2017 by Dadgad Quote
lalcalac Posted March 6, 2017 Author Posted March 6, 2017 Ok, so far by now im getting a lot of useful things with this action recorder, but, i have this problem and i dont know what im doing wrong, im using the command lenghten to do the corner thing, and use the action recorder to automatically set delta and distance, but when the macro stops it sends me this error (image attached), hope can help me with this, thanks b4 Quote
Dadgad Posted March 6, 2017 Posted March 6, 2017 I see that you are defining Delta before selecting the object, which seems to be what you should do. What exactly is the Object type which you want to lengthen? Having just revisited your first post, I see that they are two LINES, which I guess are meeting at their end points, and defining the corner? Wondering if STRETCH might be a better command to use, or SCALE, as the LENGTHEN command only allows you to select a single object. If you used SCALE, and defined the Base Point as the vertex where they intersect, might that work? I often set up my Action Recorder macros, so that I can hit Continue playback without selection, but that would not seem to be an appropriate option here, although you might just try it, to be sure. If you could post a dwg., I would be happy to try it, if I could better understand what the linework looks like. I am wondering if LENGTHEN is the most appropriate command for what you are trying to do, it probably is, but without enough information, it is hard for me to be sure. Quote
lalcalac Posted March 6, 2017 Author Posted March 6, 2017 So heres the DWG to show what i am trying to do, im trying to get from option A to option B, i usually do it manually, drawing a cicrcle on the corner and extending the lines, but as u can see, it takes a lot of time cuz there are a lot of corners, (the dwg is just a small example), hope it helps to understand the situation, thanks b4! Corner Lines.dwg Quote
Dadgad Posted March 7, 2017 Posted March 7, 2017 (edited) Thanks for posting the .dwg, it definitely clears up your goal. Unfortunately, I see no EASY way to do this. Looks pretty labor-intensive. If one were to try to write a lisp, I am a bit curious, how the selection set would be defined. Sorry, I know that is not the answer you wanted to hear, nor the one I wanted to give you. Glad you like the Action Recorder. The more you use it, the better you will become at creating these macros. It does have a few bugs, but even so, it has saved me quite a bit of time since I started using it. Good luck with your corners, hopefully somebody else will have a creative approach for you. Edited March 10, 2017 by Dadgad Quote
BIGAL Posted March 7, 2017 Posted March 7, 2017 (edited) Ok you want a lisp I did years ago called TICS for Architectural tics extends lines a know distance you can bulk select etc, ; BY Alan H 2012 ; tics.lsp ; draw architectural tic marker tics.lsp ;defun exline (defun ah:exline (en / p1 p2 p3 p4 ang ) (setq p1 (vlax-safearray->list (vlax-variant-value(vla-get-startpoint en)))) (setq p2 (vlax-safearray->list (vlax-variant-value(vla-get-endpoint en)))) (setq ang (angle p1 p2)) (setq p3 (polar p1 (- ang pi) tic_len)) (setq p4 (polar p2 ang tic_len)) (command "line" p1 p3 "") (command "line" p2 p4 "") ) ; pline co-ords ; By Alan H (defun AH:getcoords (ent / I len) (setq co-ords (vlax-safearray->list (vlax-variant-value (vlax-get-property en "Coordinates" )))) (setq len (length co-ords)) (setq numb (/ len 2)) (setq I 0) (repeat numb (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) )) (setq co-ordsxy (cons xy co-ordsxy)) (setq I (+ I 2)) ) ) ;defun (defun AH:expoly (ordsxy / pt1 pt2 num x) (setq x (length ordsxy)) (if (= (vla-get-closed en) :VLAX-FALSE) (setq num x) (setq num (- x 1)) ; open ) ; closed (setq p2 (nth (setq x (- x 1)) ordsxy)) (repeat num (setq p1 (nth (setq x (- x 1)) ordsxy)) (setq ang (angle p1 p2)) (setq p3 (polar p1 (- ang pi) tic_len)) (setq p4 (polar p2 ang tic_len)) (command "line" p1 p3 "") (command "line" p2 p4 "") (setq p2 p1) ) ) ; starts here ; checklay make if missing (if (= (tblsearch "layer" "Tics") nil) (command "-layer" "n" "Tics" "c" 1 "Tics" "") ) (defun c:tics ( / tic_len ss y) (setq tic_len (getdist "\nEnter tick size mm <20> ")) (if (= tic_len nil) ; pressed enter so 20 (setq tic_len 20) ) ; Selection set to measure ;now pick multiple lines etc (setq exlay (getvar 'clayer)) (setvar "clayer" "tics") ; change layer name to suit (setq oldsnap (getvar 'osmode)) (setq ss (ssget)) ; no check if it returned something ; put a create layer here (setvar 'osmode 0) (repeat (setq y (sslength ss)) (setq en (vlax-ename->vla-object (ssname ss (setq y (- y 1))))) ; Entity type (setq entype (vla-get-ObjectName en)) (cond ((= entype "AcDbLine")(AH:exline en)) ((= entype "AcDbPolyline")(AH:getcoords en)(AH:expoly co-ordsxy)(setq co-ordsxy nil)) ) ) (setvar 'clayer exlay) (setvar 'osmode oldsnap) (princ) ) ;defun Edited March 13, 2017 by BIGAL Quote
Dadgad Posted March 7, 2017 Posted March 7, 2017 Ok you want a lisp I did years ago called TICS for Architectural tics extends lines a know distance you can bulk select etc, ;BY Alan H 2012 ; ; draw architectural tic marker tics.lsp ;pick layer required (setvar "cmdecho" 0) (setq exlay (getvar "clayer")) (if (or (= setsc nil)(= setsc 0))(scaleset)) (setq lay_search tics) (setq lay_colour ticscol) (setq l_type ticslin) (lay_miss) (setq obj nil) (while (= obj nil) (setq obj (entsel "\n Pick any object on the required layer :")) ) (setq tic_len (getreal "\nEnter tick size mm <2> ")) (if (= tic_len nil) (setq tic_len (* 2 setsc)) (setq tic_len (* tic_len setsc)) ) (setq player (cdr (assoc 8 (entget (car obj))))) (princ "\n Object is on the layer: ") (princ player) (princ "\n ") ; Selection set to measure (while (not (setq ss (ssget)))) ;; For each entity in the selection set, check if it is an entity that can ;; be used. ;now pick multiple lines etc (setvar "clayer" tics) (while (setq en (ssname ss 0)) ; Entity type (setq entyp (cdr (assoc 0 (entget en)))) ;layer type (setq aclayer (cdr (assoc 8 (entget en)))) (if (and (= entyp "LINE") (= player aclayer)) (progn (setq p1 (cdr (assoc 10 (entget en)))) (setq p2 (cdr (assoc 11 (entget en)))) (setq ang (angle p1 p2)) (setq p3 (polar p1 (- ang pi) tic_len)) (setq p4 (polar p2 ang tic_len)) (command "line" p1 p3 "") (command "line" p2 p4 "") ) ) ; Delete each measured entity from set (ssdel en ss) ;end while ) (setq p1 nil p2 nil p3 nil p4 nil tic_len nil ss nil en nil ) (setvar "clayer" exlay) (princ) BIGAL, nice one, that sounds like just what the doctor ordered! Quote
lalcalac Posted March 8, 2017 Author Posted March 8, 2017 Ok, im such a newbie, it appears this Command: ; error: no function definition: SCALESET on autocad, also seems this works so i am the problem it seems, tanks for the info. Appretiate the help! Quote
OMEGA-ThundeR Posted March 8, 2017 Posted March 8, 2017 Making simple lisp files is very easy. Just start the lisp code with your made up command: (Defun C:commandname () Then run the commands you would normally would type in AutoCAD (and it's corresponding settings) (command "-purge" "a" "*" "n" "-purge" "z" "-purge" "r" "*" "n" "audit" "y" "-purge" "a" "*" "n") (command "_zoom" "e") (command "qsave") And close the lisp routine with this piece of code (princ) ) Create the file in Notepad (or any preferred simply text editor) and save it as *.LSP file. Use APPLOAD command within autocad to load the file and run the lisp with the set command ('commandname' in above case). It's just as simple as that. Above code purges and cleans the drawing, then zoom -> extends the current model/layout and then saves the drawing. i don't know how to quickly set the lineweights afterwards or with a commandline command. Quote
lalcalac Posted March 9, 2017 Author Posted March 9, 2017 Ok so i tried again the code that Alan posted but, i still cant make it work, it keeps throwing an error, and i dont know why, as i said, im not very familiar with autolisp thing yet, would appretiate to know how you did it Dadgad, thanks b4:) Quote
Dadgad Posted March 10, 2017 Posted March 10, 2017 Ok so i tried again the code that Alan posted but, i still cant make it work, it keeps throwing an error, and i dont know why, as i said, im not very familiar with autolisp thing yet, would appretiate to know how you did it Dadgad, thanks b4:) I didn't run the lisp, was merely encouraged to see that BIGAL had one he felt would help you out. Better to wait for some feedback from BIGAL, as he wrote it, knows how it should be used, and may be able to help you troubleshoot it. The fact that you are unfamiliar with lisp is of little consequence, the computer neither knows or cares, it just follows the commands it is given. I don't understand lisp either, but I use them all the time, and they are a god send. In my case, much more often than not, the lisp god has a name, Lee Mac! Quote
BIGAL Posted March 10, 2017 Posted March 10, 2017 Its an old lisp and I did not double check it, the missing scaleset is because its part of a bigger group of lisps so is lay_miss. I will have time tomorrow to fix sorry about that. Note only works on lines version 2 would do plines. Quote
lalcalac Posted March 11, 2017 Author Posted March 11, 2017 O i see, well i broke my brain trying to figure it out lol, well ill wait for it, thanks 4 the help! Quote
BIGAL Posted March 12, 2017 Posted March 12, 2017 Ok code in post above is updated it does lines or plines adding a TIC line. Quote
lalcalac Posted March 12, 2017 Author Posted March 12, 2017 Thats a wonderfull lisp, but still its not the best thing for me, that works as a double extend that adds the extended line as a new one, i need to extend just the corner lines and keep them as the existing lines, i tried to do a code using the command LENGTHEN, the thing is that it needs objects to be selected one by one, but, fence works fine for this, thing is, i cant make it work using only a two point fence, not the multiple fence line (defun C:TESTFENCE (/ pt1 pt2 ss1) (command "LENGTHEN" "DE" "1") (setq pt1 (getpoint "\nClick any location outside object: ")) ;(setq pt2 (getpoint pt1)) (setq pt2 (getcorner pt1 "\nClick opposite corner: ")) (setq ss1 (ssget "F" (list pt1 pt2))) (princ ss1) ) i tried with this, but, it first tries to select fence then it shows the command, just the other way lol. thanks for the help, !! Quote
BIGAL Posted March 13, 2017 Posted March 13, 2017 To do only corners I think you would have to pick each corner individually then use a very small window to pick and extend the two lines. It needs a couple of extra bits to what is done already you need this which end have I picked so direction is correct for extension else the circle idea may be the way to go. Dont use "F" fence use "C" for crossing with two pts and a very small distance like 0.5 for the calculated sq. 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.