Jump to content

Recommended Posts

Posted

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

Posted

Why you need formula text can i make it Just with text? 

Posted

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.

Posted

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)
)

 

  • Like 1
  • Thanks 1
Posted (edited)

Wow. It works great! Thank You so much!  🤩

Edited by zwonko
Posted

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))
)
)

 

image.png.6758331118302dc6077359670a47c10b.png

Posted

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.

Posted

I will see what i can do these days.

If i understand you right you want buttons only for + and -

Posted
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?

 

Posted (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 by BIGAL
Posted

OK, I will try to make it by multiradiobutttons.

  • 4 weeks later...
Posted (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 by zwonko

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...