zwonko Posted June 10, 2021 Share Posted June 10, 2021 I have some lisp to make xlines better for me, for example, xlv (vertical) , xlh (horizontal), and xlo (horizontal in odrinate, gettinng ordinate from text). Need also following two: 1) xline grade (xlg) - user sets te grade in [%] (Please input grade in [%]) and inserting xline with selected grade. Got thing to do is that user can press for example "m" to mirror xline, before it will be made on drawing. 2) xline slope (xls) - slopes on our drawing are like 1:1, 1:1,5, 1:2, etc. Where first is Y (vertical) second is X (horizontal), so it look like Y:X, or V:H. So the program is simmilar to 1) but the input is different (please input slope [Y:X]) Quote Link to comment Share on other sites More sharing options...
dan20047 Posted June 10, 2021 Share Posted June 10, 2021 I recommend sharing when you are also asking, for example show your better xline lisps For slopes I just draw my xlines @ for the slope, for example 1%: : XLINE Infinite line: Bisect/Horizontal/Vertical/Angle/Parallel/<Point along Line>: Direction: @100,1 Quote Link to comment Share on other sites More sharing options...
zwonko Posted June 10, 2021 Author Share Posted June 10, 2021 They are so simple that everyone can do it and they don't look well. But the code is here if somebody want it: (defun c:xlh () (command "XLINE" "h" pause) ) (defun c:xlv () (command "XLINE" "v" pause) ) (defun c:xlo () (setq ele (car (entsel "\nSelect elevation: "))) (if (equal (vlax-get (vlax-ename->vla-object ele)'ObjectName) "AcDbMText") (progn (command "explode" ele) (setq elev (vlax-get (vlax-ename->vla-object (entlast))'TextString )) (command "undo" "1") ) (progn (setq elev (vlax-get (vlax-ename->vla-object ele)'TextString )) ) ) (setq elev (atof elev)) (setq elev (* elev 1000)) (setq elev (rtos elev 2 3)) (setq elevv (strcat "0," elev)) (command "XLINE" "h" elevv "") ) Quote Link to comment Share on other sites More sharing options...
zwonko Posted June 10, 2021 Author Share Posted June 10, 2021 17 minutes ago, dan20047 said: I recommend sharing when you are also asking, for example show your better xline lisps For slopes I just draw my xlines @ for the slope, for example 1%: : XLINE Infinite line: Bisect/Horizontal/Vertical/Angle/Parallel/<Point along Line>: Direction: @100,1 Thanks for that! Quote Link to comment Share on other sites More sharing options...
dan20047 Posted June 10, 2021 Share Posted June 10, 2021 your XLO lisp is not so simple! nice work seems like you can work out the slopes if you want to FYI - here is a routine I use to erase my temp xlines (defun c:EXLA ( / ss1) (princ "\nErase all xlines:") (if (setq ss1 (ssget "X" (list (cons 0 "XLINE")(cons 67 (if (SAA_is_paper) 1 0))))) (progn (command "erase" ss1 "") (princ (strcat "\nErased " (itoa (sslength ss1)) " xlines")) ) ;_progn (princ "\nNo xlines to erase") ) ;_if (princ) ) ;;;========================================================================= ;;; SAA_is_paper - returns nil for modelspace, T for paperspace ;;; by Vladimir Nesterovsky ;;; use (cons 67 (if (SAA_is_paper) 1 0)) for ssget "X" of mspace vs. pspace ;;; note that pspace will get all objects in layouts, not just current ;;;========================================================================= (defun SAA_is_paper () (> 2 (getvar "cvport") (getvar "tilemode"))) Quote Link to comment Share on other sites More sharing options...
zwonko Posted June 10, 2021 Author Share Posted June 10, 2021 51 minutes ago, dan20047 said: seems like you can work out the slopes if you want to i takes me hours to make that, even it is just a cut off from the code made here by someone else: Quote Link to comment Share on other sites More sharing options...
dan20047 Posted June 11, 2021 Share Posted June 11, 2021 (edited) That is definitely how I've learned, cribbing from other routines. What are you still trying to accomplish? It seems that if you are creating an xline with a specific slope, it is just as easy to type: XLINE (enter 1st point) @100,2 I'm not sure how you would speed up much other than avoid typing the @ symbol. Unless you want to add multiple xlines of the same specific slope (and didn't want to just use the copy command.) Edited June 11, 2021 by dan20047 1 Quote Link to comment Share on other sites More sharing options...
zwonko Posted June 11, 2021 Author Share Posted June 11, 2021 I just doesnt know that I can put it like @100,2. So if want slope 1:1.5 i just type @1.5,1 and that it. Thanks! 1 Quote Link to comment Share on other sites More sharing options...
mhupp Posted June 11, 2021 Share Posted June 11, 2021 (edited) 5 hours ago, zwonko said: I just doesnt know that I can put it like @100,2. So if want slope 1:1.5 i just type @1.5,1 and that it. Thanks! here is a quick little program so you dont mix up x and y inputs (defun c:xlslope (/ rise run pt) (setq rise (getstring "\nInput Rise: ")) (setq run (getstring "\nInput Run: ")) (setq pt (getpoint "\nStarting Point")) (vl-cmdf "_.Xline" pt (strcat "@" run "," rise) "") (princ) ) Edited June 11, 2021 by mhupp Quote Link to comment Share on other sites More sharing options...
zwonko Posted June 11, 2021 Author Share Posted June 11, 2021 (edited) Thanks again @mhupp thats great! I hope you don't mind, I modded it a little: (defun c:xlslope (/ rise run pt) (setq run (getstring "\nInput Run: ")) (vl-cmdf "_.Xline" "0,0" (strcat "@" run ",1") "") (vl-cmdf "_.move" (ssget "_L") "" "0,0" pause) (princ) ) Now it is following the cursor. The bad thing is that if user interrupt "move", created entity don't dissapear. and the one for grade is: (defun c:xlgrade (/ rise run pt) (setq grade (getstring "\nInput grade [%]: ")) (vl-cmdf "_.Xline" "0,0" (strcat "@100," grade) "") (vl-cmdf "_.move" (ssget "_L") "" "0,0" pause) (princ) ) Edited June 11, 2021 by zwonko Quote Link to comment Share on other sites More sharing options...
dan20047 Posted June 12, 2021 Share Posted June 12, 2021 another method without need for move (defun c:xlgrade (/ rise run pt) (setq grade (getreal "\nInput grade [%]: ")) (command "_.Xline" "angle" (rtd (angle (list 0.0 0) (list 100.0 grade))) (SAA_CMDACTIVE nil)) (princ) ) (defun rtd (a)(/(* a 180.0)pi)) ;;;========================================================== ;;; Continue pausing until exited command mode ;;; nil = pause ;;; otherwise pass string to use ;;; credit unknown - possibly Roy Harkow ;;; usage example: (command "line" (SAA_CMDACTIVE nil)) ;;;========================================================== (defun SAA_CMDACTIVE ( passcmd / ) (if (null passcmd) (setq passcmd pause)) (while (not (= 0 (getvar "cmdactive"))) (if (= 'LIST (type passcmd)) (foreach x passcmd (command x) ) ;_foreach (command passcmd) ) ;_if ) ;end while ) 2 Quote Link to comment Share on other sites More sharing options...
zwonko Posted June 12, 2021 Author Share Posted June 12, 2021 Don't understand this code but works better Thanks Quote Link to comment Share on other sites More sharing options...
dan20047 Posted June 12, 2021 Share Posted June 12, 2021 you're welcome. Happy to explain, which parts are not clear? Quote Link to comment Share on other sites More sharing options...
zwonko Posted June 13, 2021 Author Share Posted June 13, 2021 (edited) oh, You musn't, I'm so low at lisps, that I can't understand it now. But I will try to learn, just it takeing me too much time, and I have deadlines now. For now I understand that You changed xline to angle xline and add some function that will keep it going till user abort. Also there is function which is change angles drgree-radian. Thanks again! P.S. When I will found time I will try to let it mirror the xline (change xline 2% to -2%) Edited June 13, 2021 by zwonko Quote Link to comment Share on other sites More sharing options...
dan20047 Posted June 13, 2021 Share Posted June 13, 2021 not the most elegant, but here is a version with mirror and changing grade, but no preview of xline angle (defun c:xlgrade (/ grade) (setq grade (getreal "\nInput grade [%]: ")) (command "_.Xline" "angle" (rtd (angle (list 0.0 0) (list 100.0 grade))) (SAA_CMDACTIVE nil)) (princ) ) (defun c:xlgrade2 (/ input grade) (setq grade (getreal "\nInput grade [%]: ") input T ) ;_setq (while (and input grade) (initget 128) (setq input (getpoint (strcat "Enter point for " (rtos grade 2 2) "% xline, or new grade, or m to mirror:"))) (cond ;; if input is a list, then must be a point, add xline ((= (type input) 'LIST) (command "_.Xline" "angle" (rtd (angle (list 0.0 0) (list 100.0 grade))) input "") ) ;_subcond ;; if m or M, then mirror ((and input (= (strcase input) "M")) (setq grade (* -1 grade)) ) ;_subcond ;; if string converts to a number, then change grade ((and input (or (= (type (SAA_stonum input)) 'REAL) (= (type (SAA_stonum input)) 'INT) ) ;_or ) ;_and (setq grade (SAA_stonum input)) ) ;; if other string was entered, then echo message ((= (type input) 'STR) (princ "\nInvalid input - enter point, number for new grade, or m to mirror") ) ;; if not a point, string, or number, must be nil (fron enter), thus exit (T (princ "\nDone")) ) ;_cond ) ;_while (princ) ) (defun rtd (a)(/(* a 180.0)pi)) ;;;========================================================== ;;; Continue pausing until exited command mode ;;; nil = pause ;;; otherwise pass string to use ;;; credit unknown - possibly Roy Harkow ;;; usage example: (command "line" (SAA_CMDACTIVE nil)) ;;;========================================================== (defun SAA_CMDACTIVE ( passcmd / ) (if (null passcmd) (setq passcmd pause)) (while (not (= 0 (getvar "cmdactive"))) (if (= 'LIST (type passcmd)) (foreach x passcmd (command x) ) ;_foreach (command passcmd) ) ;_if ) ;end while ) ;;;========================================================== ;;; convert a pure numeric string to a number, or leave it alone - from Looking Glass Microproducts ;;;========================================================== (defun SAA_stonum (instr / temp_real temp_int) (Cond ; Not a number, just return the string ((Null (Setq temp_real (DisToF instr))) ; not a number instr ) ; Has a decimal point, must be a real number ((WCmatch instr "*`.*") temp_real) ; Must be a real ((/= temp_real (Setq temp_int (Fix temp_real)) ) temp_real ) ; Must be an integer (T temp_int) ) ) Quote Link to comment Share on other sites More sharing options...
zwonko Posted June 15, 2021 Author Share Posted June 15, 2021 That a piece of code! Thanks! 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.