• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Visual LISP, AutoLISP and General Customization

    Reply
    Distinguished Contributor
    Posts: 139
    Registered: ‎02-10-2004

    Measure in millimeters but display values in meters...

    596 Views, 16 Replies
    07-13-2010 04:14 AM

    Hi,

    The attached lsp puts tick marks at equal distances along a line/polyline and tags them with the distanace value from the start point. I draw using millimeter units but things like chainage should be displayed in meter units. Using this routine displays the values in millimeter units which I then 'find and replace' to edit their values to meters.

    Can someone take a look at the lisp to see if it can be altered to input the mm value at the start but output the meter value to the text values?

    Attached jpg graphically shows my request.

    Regards

    Sean

    Please use plain text.
    Mentor
    Posts: 769
    Registered: ‎12-26-2005

    Re: Measure in millimeters but display values in meters...

    07-13-2010 05:52 AM in reply to: sean.keohane

    For you TEXT creation, line:

        (list (cons 1 (rtos chainage 2 3)))

    could be changed;

     

    to something like;

        (list (cons 1 (strcat  (rtos (/ chainage  1000.0) 2 3 ) "m " )  ) )

    S
    Please use plain text.
    *Expert Elite*
    Kent1Cooper
    Posts: 4,167
    Registered: ‎09-13-2004

    Re: Measure in millimeters but display values in meters...

    07-13-2010 05:53 AM in reply to: sean.keohane

    Sean.keohane wrote:

    .... I draw using millimeter units but things like chainage should be displayed in meter units. Using this routine displays the values in millimeter units which I then 'find and replace' to edit their values to meters.

     

    ....


     

    You should be able to do it by changing this line:

     

    (list (cons 1 (rtos chainage 2 3)))

     

    to something like this:

     

    (list (cons 1 (strcat (rtos (/ chainage 1000) 2 1) "m")))

    Kent Cooper
    Please use plain text.
    Distinguished Contributor
    Posts: 139
    Registered: ‎02-10-2004

    Re: Measure in millimeters but display values in meters...

    07-13-2010 06:00 AM in reply to: sean.keohane

    Thanks very much to both of you, that worked perfectly.

    I appreciate your help,

    Regards,

    Sean

    Please use plain text.
    Active Member
    Posts: 7
    Registered: ‎02-07-2013

    Re: Measure in millimeters but display values in meters...

    02-07-2013 12:22 AM in reply to: sean.keohane

    I have used the lisp discussed above but unfortunately the label (0+050.00, 0+100.00, etc) doesn't show, only the tick.

     

    Also, I have seen drawings that has a tick interval of 50m but the label is placed only every 100m. The tick length on the place where there is label is longer that the one without label. Can you please reconfigure the above lisp so it would fit in my description?

     

    Thank you in advance.

    Please use plain text.
    *Expert Elite*
    Posts: 2,136
    Registered: ‎11-24-2009

    Re: Measure in millimeters but display values in meters...

    02-07-2013 01:53 AM in reply to: bulutok

    bulutok wrote:

    I have used the lisp discussed above but unfortunately the label (0+050.00, 0+100.00, etc) doesn't show, only the tick.

     

    Also, I have seen drawings that has a tick interval of 50m but the label is placed only every 100m. The tick length on the place where there is label is longer that the one without label. Can you please reconfigure the above lisp so it would fit in my description?

     

    Thank you in advance.


    Text Style issues, you  can use a existing textstyle name

     

    ....
    (list (cons 50 (+ bearing PI))) (list (cons 7 "YourTextStyle" )) '((41 . 1.0) (51 . 0.0) (71 . 0) (72 . 0) (11 0.0 0.0 0.0) (210 0.0 0.0 1.0) (100 . "AcDbText") (73 . 0) )
    ....
    )

     

    or remove it altogether . which will use the current TEXTSTYLE

     

    HTH

     

    EDIT: Almost forgot, for your format

    ...

    (list (cons 1 (strcat "0+" (rtos chainage 2 2))))

    ...

     

     

    Please use plain text.
    Active Member
    Posts: 7
    Registered: ‎02-07-2013

    Re: Measure in millimeters but display values in meters...

    02-07-2013 02:21 AM in reply to: pbejse

    Thank you very much for the swift reply.

     

    I have used your latest suggestion but it didn't work out as I expected.

     

    I wanted to remove the "m" on the suffix of each label. The label on the starting point (0+000.00) doesn't show.

     

    Labels should look like this:

    0+000.00

    0+050.00

    0+100.00

    0+150.00

    etc.

     

    Also, the increment that I have entered is 50m. Why is it that the label doesn't have a 50m interval?

     

    Please have a look on the attached jpeg file in order to have a clear idea on what I wanted.

     

    Thanks again.

    Please use plain text.
    *Expert Elite*
    Posts: 2,136
    Registered: ‎11-24-2009

    Re: Measure in millimeters but display values in meters...

    02-07-2013 03:10 AM in reply to: bulutok

    bulutok wrote:

    Thank you very much for the swift reply.

     

    I have used your latest suggestion but it didn't work out as I expected.

     

    I wanted to remove the "m" on the suffix of each label. The label on the starting point (0+000.00) doesn't show.

     

    Labels should look like this:

    0+000.00

    0+050.00

    0+100.00

    0+150.00

    etc.

     

    Also, the increment that I have entered is 50m. Why is it that the label doesn't have a 50m interval?

     

    Please have a look on the attached jpeg file in order to have a clear idea on what I wanted.

     

    Thanks again.


    works fine here in 2009

     

    (defun c:Chainage (/)
    (vl-load-com)
    (defun _Line (p b o)
           (entmake
    	 (append
    	   '((0 . "line")
    	     (100 . "AcDbEntity")
    	     (67 . 0)
    	     (410 . "Model")
    	     (8 . "C_Chainage")
    	     (100 . "AcDbLine")
    	     )
    	   (list (cons 10 (polar p b o)))
    	   (list (cons 11 (polar p (+ b PI) o)))
    	   '((210 0.0 0.0 1.0))
    	   )
    	 )
      )
    (defun _text (p b o h c)
           (entmake
    	 (append
    	   '((0 . "TEXT")
    	     (100 . "AcDbEntity")
    	     (67 . 0)
    	     (410 . "Model")
    	     (8 . "C_Chainage")
    	     (100 . "AcDbText")
    	     )
    	   (list (cons 10 (polar p (+ b PI) (* o 2.0)))
    		 )
    	   (list (cons 40 h))
    	   (list (cons 1 (strcat "0+"
    				 (if (setq ld (nth (strlen (rtos  c 2 0)) '(x  "00" "0")))
    				   	ld "")
    				 (rtos c 2 2))))
    	   (list (cons 50 (+ b PI)))
    	   
    	   '((41 . 1.0)
    	     (51 . 0.0)
    	     (71 . 0)
    	     (72 . 0)
    	     (11 0.0 0.0 0.0)
    	     (210 0.0 0.0 1.0)
    	     (100 . "AcDbText")
    	     (73 . 0)
    	     )
    	   )
    	 )
      )
    (defun _ang (p1 p2)(+ (angle p1 p2) (/ PI 2.0)))
      
    (setq dist (getdist "Type in chainage increment: "))
      (setq offset (getdist "Type in tick size: "))
      (setq height (getdist "Type in iso text height: "))
      (setq	ss (ssget)
    	count 0
    	dist dist
    	offset offset
    	height height
    	)
      (repeat (sslength ss)
        (setq ent	   (ssname ss count)
    	  obj	   (vlax-ename->vla-object ent)
    	  chainage dist
    	  )
        (_line (setq p (vlax-curve-getstartpoint obj))
    	   (setq bearing (_ang p (vlax-curve-getPointAtDist obj (+ chainage 0.001))))
    		   offset)
        (_text p bearing offset height 0.0)
        (while
          (and
    	(setq point1 (vlax-curve-getPointAtDist obj chainage))
    	(setq point2 (vlax-curve-getPointAtDist obj (+ chainage 0.001)))
    	)
           (setq bearing (+ (angle point1 point2) (/ PI 2.0)))
           (_line point1 bearing offset)
           (_text point1 bearing offset height chainage)
           
           (setq chainage (+ chainage dist))
           )
        (setq count (1+ count))
        )
      )

     

     HTH

     

    BTW: what of the last point?

     

     

    Please use plain text.
    Active Member
    Posts: 7
    Registered: ‎02-07-2013

    Re: Measure in millimeters but display values in meters...

    02-07-2013 03:15 AM in reply to: pbejse

    Great! Works perfectly now.

     

    This would be of great help and I will be forever grateful to you.

     

    Thanks a lot and God bless!

    Please use plain text.
    *Expert Elite*
    Posts: 2,136
    Registered: ‎11-24-2009

    Re: Measure in millimeters but display values in meters...

    02-07-2013 03:22 AM in reply to: bulutok

    bulutok wrote:

    Great! Works perfectly now.

     

    This would be of great help and I will be forever grateful to you.

     

    Thanks a lot and God bless!


    You are welcome. even though this thread is a year ang change old the credit still goes to the original author sean.keohane 

     

    Cheers

     

    Please use plain text.