zwonko Posted May 27, 2021 Posted May 27, 2021 Could someone be so kind and help me with lisp which is calculating elevation ordinate. Everything should be said in attached file. Basicly what I want is to click text with some ordinate, click dimension, click grade (slope), and get field with formula in other mtext. lisp_gabaryt.dwg Quote
Trudy Posted May 27, 2021 Posted May 27, 2021 Why you need formula text can i make it Just with text? Quote
zwonko Posted May 27, 2021 Author Posted May 27, 2021 I prefer formula, because I'm 100% sure that it is calculated (because of fielddisplay set to 1). Also sometimes, that, what I've shown on drawing is not only what I've need. Sometimes this ordinate triangles are not in vertical line, and I need to add extra calculation to results. But any help will be appreciated Maybe i've I get tha base with text it will be easier to convert it to what I prefer. Quote
Trudy Posted May 27, 2021 Posted May 27, 2021 Hello @zwonko i make some lisp. Start with "tt" and first time will ask you for precision and Height if you want to change use command "prec" (defun c:tt (/ elev dim grad mspace pt Mtext answ) (defun c:prec () (setq prec (getint "\nSet precison: ")) (setq H (getreal "\nSet text height: ")) ) (if prec (princ) (c:prec)) (if H (princ) (c:prec)) (setq ele (car (entsel "\nSelect first 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 dim (/ (vlax-get (vlax-ename->vla-object (car (entsel "\nSelect dimension: "))) 'Measurement) 100)) (setq grad (/ (atof (vl-string-right-trim "%" (vlax-get (vlax-ename->vla-object (car (entsel "\nSelect grade: "))) 'TextString))) 100)) (setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object) ) ) ) (initget "+ -") (setq answ (getkword "\nChose [+/-]<+> ")) (setq pt (getpoint "\nWhere to place the new elevation: ")) (setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object) ) ) ) (setq Mtext (vla-AddMText mspace (vlax-3d-point pt) H (strcat "%<\\AcExpr ((" elev answ (rtos dim 2 prec) "*" (rtos grad 2 prec) ")) \\f \"%lu2%pr" (rtos prec 2 0)"\">%"))) (vlax-put-property (vlax-ename->vla-object (entlast)) 'Height H) (princ) ) 1 1 Quote
zwonko Posted May 27, 2021 Author Posted May 27, 2021 (edited) Wow. It works great! Thank You so much! Edited May 27, 2021 by zwonko Quote
zwonko Posted June 1, 2021 Author Posted June 1, 2021 Is there possibility to make +/- clickable? Prefer something like in @Lee Mac textcalc (http://www.lee-mac.com/textcalculator.html) I've tried to add it by myself but it is to hard. I've spent few hourse and it still not working Quote
BIGAL Posted June 2, 2021 Posted June 2, 2021 My take on input (defun c:prec () (if (= prec nil)(setq prec 3)) (if (= H nil)(setq H 2.5)) (if (not AH:getvalsm)(load "Multi Getvals.lsp")) (setq ans (AH:getvalsm (list "Please enter val's" "Precision" 5 4 (rtos prec 2 0) "Text Height" 5 4 (rtos H 2 1)))) (setq prec (atoi (car ans)) H (atof (cadr ans)) ) ) Quote
zwonko Posted June 2, 2021 Author Posted June 2, 2021 Thx @BIGAL. I know MultiRadio buttons and It is great peace of code But the point is that setting precision as it is in code made by @Trudy is ok. I don't change it often. The thing that I wan't to change is +/- from keybord input to clickable (by mouse). And the best option will be as it is in @Lee Mac textcalc. I thougt that +/i could be done mutch more easier but multiradiobuttons but the +/- is very changable, one click to plus, one to minus, one plus, one minus, etc. So MultiRadio will mostly need two clicks instead of one like it is in @Lee Mac texcalc. Quote
Trudy Posted June 2, 2021 Posted June 2, 2021 I will see what i can do these days. If i understand you right you want buttons only for + and - Quote
zwonko Posted June 2, 2021 Author Posted June 2, 2021 3 hours ago, Trudy said: only for + and - Yes, only for +/-. Else is clickable (like grade, and dimensions). Precision and text size is setted only one/two times per drawing. Per hour. But plus minus is changable every dimension more or less. Also if it is not to hard could be somewhere added line of code that makes inserted mtext field anchored bottom center? Quote
BIGAL Posted June 3, 2021 Posted June 3, 2021 (edited) I have a simple "Flip" radio button Yes or No in a lot of code. Default is No and in Multi radio button the dcl closes when you pick a button or OK so only one pick required. The text could be +ve or -ve Edited June 3, 2021 by BIGAL Quote
zwonko Posted June 7, 2021 Author Posted June 7, 2021 OK, I will try to make it by multiradiobutttons. Quote
zwonko Posted July 4, 2021 Author Posted July 4, 2021 (edited) I've found a little time and modded the code for "MultiRadioButtons". Also moded the order of user actions So here it is: (defun c:tt (/ elev dim grad mspace pt Mtext answ) (defun c:prec () (setq prec (getint "\nSet precison: ")) (setq H (getreal "\nSet text height: ")) ) (if prec (princ) (c:prec)) (if H (princ) (c:prec)) (setq ele (car (entsel "\nSelect first 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 )) ) ) (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (if (= but nil)(setq but 1)) ;(setq answ (ah:butts but "+" '("Choose" "+ (PLUS)" "- (MINUS)" ))) (setq answ (ah:butts but "-" '("Choose" "+ (PLUS)" "- (MINUS)" ))) (if (= answ "+ (PLUS)") (setq answ "+") (setq answ "-")) (setq dim (/ (vlax-get (vlax-ename->vla-object (car (entsel "\nSelect dimension: "))) 'Measurement) 100)) (setq grad (/ (atof (vl-string-right-trim "%" (vlax-get (vlax-ename->vla-object (car (entsel "\nSelect grade: "))) 'TextString))) 100)) (setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object) ) ) ) (setq pt (getpoint "\nWhere to place the new elevation: ")) (setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object) ) ) ) (setq Mtext (vla-AddMText mspace (vlax-3d-point pt) H (strcat "%<\\AcExpr ((" elev answ (rtos dim 2 prec) "*" (rtos grad 2 prec) ")) \\f \"%lu2%pr" (rtos prec 2 0)"\">%"))) (vlax-put-property (vlax-ename->vla-object (entlast)) 'Height H) (princ (strcat "\nYour calculation is "elev answ (rtos dim 2 prec) "*" (rtos grad 2 prec) " "))(princ) ) Thanks You guys for help! Edited July 4, 2021 by zwonko 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.