hi sir, i want "2 space" front and back of chainage in this lisp.

hi sir, i want "2 space" front and back of chainage in this lisp.

kkr028
Enthusiast Enthusiast
659 Views
7 Replies
Message 1 of 8

hi sir, i want "2 space" front and back of chainage in this lisp.

kkr028
Enthusiast
Enthusiast

hi sir, i want "2 space" front of chainage in this lisp.

front 2 space and back 2 space.

actual "0.000"

i want "  0.000  "

 

 

 

(defun C:CHAINAGE ; = Chainage Text at Intervals
(/ interval ss n pl dst pt)
(setvar 'dimzin 0)
(command "_.layer" "_make" "Chainage" "")
(setvar 'textsize (getdist "\nChainage Text Size: "))
(setq
interval (getdist "\nChainage Interval: ")
ss (ssget '((0 . "*POLYLINE")))
); setq
(repeat (setq n (sslength ss))
(setq
pl (ssname ss (setq n (1- n)))
dst 0
); setq
(while (<= dst (vlax-curve-getDistAtParam pl (vlax-curve-getEndParam pl)))
(command "_.text"
"_non" (setq pt (vlax-curve-getPointAtDist pl dst))
"" ; height
(cvunit ; rotation
(+ (angle '(0 0 0) (vlax-curve-getFirstDeriv pl (vlax-curve-getParamAtPoint pl pt))) (/ pi 2))
"radian" "degree"
); cvunit
(rtos (/ dst 1000) 2 3)
); command
(setq dst (+ dst interval))
); while
); repeat
(princ)
); defun

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

ВeekeeCZ
Consultant
Consultant
(defun C:CHAINAGE ; = Chainage Text at Intervals
       (/ interval ss n pl dst pt)
  (setvar 'dimzin 0)
  (command "_.layer" "_make" "Chainage" "")
  (setvar 'textsize (getdist "\nChainage Text Size: "))
  (setq
    interval (getdist "\nChainage Interval: ")
    ss (ssget '((0 . "*POLYLINE")))
    ); setq
  (repeat (setq n (sslength ss))
    (setq
      pl (ssname ss (setq n (1- n)))
      dst 0
      ); setq
    (while (<= dst (vlax-curve-getDistAtParam pl (vlax-curve-getEndParam pl)))
      (command "_.text"
	       "_non" (setq pt (vlax-curve-getPointAtDist pl dst))
	       "" ; height
	       (cvunit ; rotation
		 (+ (angle '(0 0 0) (vlax-curve-getFirstDeriv pl (vlax-curve-getParamAtPoint pl pt))) (/ pi 2))
		 "radian" "degree"
		 ); cvunit
	       (strcat "  " (rtos (/ dst 1000) 2 3) "  ")
	       ); command
      (setq dst (+ dst interval))
      ); while
    ); repeat
  (princ)
  ); defun
0 Likes
Message 3 of 8

calderg1000
Mentor
Mentor

Regards @kkr028 

In my opinion the space in front of the text is enough, behind it it would not be necessary

(strcat " "(rtos (/ dst 1000) 2 3))

 


Carlos Calderon G
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 4 of 8

calderg1000
Mentor
Mentor
Accepted solution

Dear @kkr028 

I made some small changes to improve the insertion time of the texts. Command is somewhat slow.

(defun C:CHAINAGE(/ interval ss n pl dst pt); = Chainage Text at Intervals                                    
  (setvar 'dimzin 0)
  (command "_.layer" "_make" "Chainage" "")
  (setvar 'textsize (setq th (getdist "\nChainage Text Size: ")))
  (setq
    interval (getdist "\nChainage Interval: ")
    ss       (ssget '((0 . "*POLYLINE")))
  )                                               ; setq
  (repeat (setq n (sslength ss))
    (setq
      pl  (ssname ss (setq n (1- n)))
      dst 0
    )                                             ; setq
    (while (<= dst (vlax-curve-getDistAtParam pl (vlax-curve-getEndParam pl)))
;;;-----------------------------------------------
;;;(command "_.text" "_non"
      (setq pt (vlax-curve-getPointAtDist pl dst))
;;;"" ; height
;;;(setq ang(cvunit ; rotation
;;;(+ (angle '(0 0 0) (vlax-curve-getFirstDeriv pl (vlax-curve-getParamAtPoint pl pt))) (/ pi 2))
;;;"radian" "degree"
;;;)); cvunit
      (setq ang
             (+ (angle '(0 0 0)
                       (vlax-curve-getFirstDeriv pl (vlax-curve-getParamAtPoint pl pt))
                )
                (/ pi 2)
             )
      )
      (setq tt (strcat " " (rtos (/ dst 1000) 2 3) " "))
;;;); command
      (entmake (list '(0 . "text")
                     (cons 10 pt)
                     (cons 50 ang)
                     (cons 40 th)
                     (cons 1 tt)
               )
      )
      ;;-----------------------------------------------
      (setq dst (+ dst interval))
    )                                             ; while
  )                                               ; repeat
  (princ)
)                                                 ; defun

 


Carlos Calderon G
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 5 of 8

kkr028
Enthusiast
Enthusiast

fantastic sir. i love it. i toomuch tired when chainage marking. it is taking time to label chainage.

with this lisp you help me a lot (space and time).

thank you sir.

0 Likes
Message 6 of 8

calderg1000
Mentor
Mentor
Happy to help. Cheers

Carlos Calderon G
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

pbejse
Mentor
Mentor

@kkr028 wrote:

hi sir, i want "2 space" front of chainage in this lisp.

front 2 space and back 2 space.

actual "0.000"

i want "  0.000  "


Not a big fan of adding unnecessary spaces on numerical values, i'd rather push the  insertion point with a factor based on the text height.

 

Using @calderg1000  bit on entmake.

(entmake (list '(0 . "text")
             (cons 10 (polar pt ang (* 0.25 th)))
             (cons 50 ang)
             (cons 40 th)
             (cons 1 tt)
       )
)

But that's just me

 

HTH

 

 

0 Likes
Message 8 of 8

calderg1000
Mentor
Mentor

Regards @kkr028 

@pbejse's proposal is great, but I prefer a larger spacing factor that also allows the insertion of a TICK, as in C3D.
Please try this additional code.

(defun C:CHAINAGE (/ interval ss n pl dst pt)     ; = Chainage Text at Intervals                                    
  (setvar 'dimzin 0)
  (command "_.layer" "_make" "Chainage" "")
  (setvar 'textsize (setq th (getdist "\nChainage Text Size: ")))
  (setq
    interval (getdist "\nChainage Interval: ")
    ss       (ssget '((0 . "*POLYLINE")))
  )                                               ; setq
  (repeat (setq n (sslength ss))
    (setq
      pl  (ssname ss (setq n (1- n)))
      dst 0
    )                                             ; setq
    (while (<= dst (vlax-curve-getDistAtParam pl (vlax-curve-getEndParam pl)))
      (setq pt (vlax-curve-getPointAtDist pl dst))
      (setq ang
             (+ (angle '(0 0 0)
                       (vlax-curve-getFirstDeriv pl (vlax-curve-getParamAtPoint pl pt))
                )
                (/ pi 2)
             )
      )
      (setq tt (rtos (/ dst 1000) 2 3))
      (entmake (list '(0 . "text")
                     (cons 10 (polar pt ang (* 1.25 th)))
                     (cons 50 ang)
                     (cons 40 th)
                     (cons 1 tt)
               )
      )
      (entmake (list '(0 . "line")
                     (cons 10 (polar pt ang (- (abs th))))
                     (cons 11 (polar pt ang th))
               )
      )
      (setq dst (+ dst interval))
    )                                             ; while
  )                                               ; repeat
  (princ)
)

Carlos Calderon G
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