Changing multiple mext to match chainage

Changing multiple mext to match chainage

Anonymous
Not applicable
1,169 Views
7 Replies
Message 1 of 8

Changing multiple mext to match chainage

Anonymous
Not applicable

I am looking for some help in changing multiple mtext on a section profile to match the chainage.

 

Attached is a screenshot of what I have just now and what I want to achieve. I am looking for some way to automate the function.

 

Thanks to anyone that can help.

0 Likes
Accepted solutions (1)
1,170 Views
7 Replies
Replies (7)
Message 2 of 8

_gile
Consultant
Consultant

Hi,

 

You can ude the (free) Increment plugin on Autodesk Apps Store.

It can do this and some more.

A screen cast is comming soon.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 8

hak_vz
Advisor
Advisor
Accepted solution

Try this. It creates mtext element at horizontal distance from the origin.

 

 

(defun c:chn ( /  )
(setq origin (getpoint "\nSelect origin >")
      textsize (getreal "\n Text size? >")
	  )
	(repeat 500
		(setq pt (getpoint "\nSelect chainage point >")
		      di (rtos (-(car pt)(car origin)) 2 2)
		)

		(entmake
			  (list
					  (cons 0 "MTEXT")           
					  (cons 100 "AcDbEntity")    
					  (cons 8 "0")               
					  (cons 100 "AcDbMText")     
					  (cons 10 (list (car pt) (- (cadr pt)0.5)))         		
					  (cons 40 textsize)         
					  (cons 71 6)  
					  (cons 50 (/ pi 2))					  
					  (cons 1 di)         

				)
		)

	)
)

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 4 of 8

_gile
Consultant
Consultant

 

 

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 5 of 8

ВeekeeCZ
Consultant
Consultant

@hak_vz wrote:

Try this. It creates mtext element at horizontal distance from the origin.

 

 

...
	(repeat 500
		(setq pt (getpoint "\nSelect chainage point >")
		      di (rtos (-(car pt)(car origin)) 2 2)
		)

		(entmake
...

 


Right, why not to use a simple routine, right to for right job...

 

... but I can imagine that the (while (until user pick another point) (entmake tex)) function would be much suitable and more comfortable to user then your (repeat 500 (in the fact, why 500?)) then need to hit ESC to break the loop.

 

(while (setq pt (getpoint "\nSelect chainage point >"))
  (entmake ...))

 

 

; ----------------------------------

BTW. Very nice tool, @_gile

Message 6 of 8

hak_vz
Advisor
Advisor

@ВeekeeCZ wrote:

.

 

... but I can imagine that the (while (until user pick another point) (entmake tex)) function would be much suitable and more comfortable to user then your (repeat 500 (in the fact, why 500?)) then need to hit ESC to break the loop.

 

(while (setq pt (getpoint "\nSelect chainage point >"))
  (entmake ...))


 

I agree, WHILE loop would serve better. I typed this code during my 5 min break, that's why it's not edited, variables are all global, it only works in one direction ...... cmdecho on/off is not set, instead of MTEXT plain TEXT would do the trick.....

 

I prefer to exit commands by hitting ESC. As a old school CAD user I type in majority of commands , and rarely use commands with GUI's. To be shure that I'm out of command I frequently hit ESC key 🙂

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 7 of 8

Anonymous
Not applicable

This is pretty much exactly what I was looking for.

 

Is there anyway that I could specify the distance and change the style the text comes in?

0 Likes
Message 8 of 8

hak_vz
Advisor
Advisor

(defun c:chn ( /  *error* origin textsize textstyle offset pt di decimal_places)
    (defun *error* ()
        (setvar "cmdecho" 1)(princ)
    )
    (setq
        origin (getpoint "\nSelect origin >")
        textsize (getreal "\n Text size  >")
        textstyle (getstring "\n Text style def = 'standard'  >" )
        decimal_places (getint "\n Decimal places  def = 2  >")
        offset (getreal "\n Text offset from tickline def = 1  >")
    )
    (if (not (tblsearch "style" textstyle)) (setq textstyle "STANDARD"))
    (if (not textsize) (setq textsize (getvar "textsize")))
    (if (not decimal_places) (setq decimal_places 2))
    (if (not offset) (setq offset 1))
    (setvar "cmdecho" 0)
    (while
        (setq pt (getpoint "\nSelect chainage point >")
              di (rtos (-(car pt)(car origin)) 2 decimal_places)
        )
        (entmake
            (list
                (cons 0 "MTEXT")           
                (cons 100 "AcDbEntity")    
                (cons 8 "0")               
                (cons 100 "AcDbMText")     
                (cons 10 (list (car pt) (- (cadr pt) offset)))                 
                (cons 40 textsize)   
                            (cons 7 textstyle)
                (cons 71 6)  
                (cons 50 (/ pi 2))                      
                (cons 1 di)         
            )
        )   
    (setvar "cmdecho" 1)
    )
    (princ)
)

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.