Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Distinguished Contributor
sean.keohane
Posts: 172
Registered: ‎02-10-2004
Message 1 of 19 (957 Views)

Measure in millimeters but display values in meters...

957 Views, 18 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

Valued Mentor
stevor
Posts: 888
Registered: ‎12-26-2005
Message 2 of 19 (947 Views)

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
*Expert Elite*
Kent1Cooper
Posts: 5,871
Registered: ‎09-13-2004
Message 3 of 19 (946 Views)

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
Distinguished Contributor
sean.keohane
Posts: 172
Registered: ‎02-10-2004
Message 4 of 19 (941 Views)

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

Active Member
bulutok
Posts: 7
Registered: ‎02-07-2013
Message 5 of 19 (535 Views)

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.

*Expert Elite*
pbejse
Posts: 2,511
Registered: ‎11-24-2009
Message 6 of 19 (523 Views)

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

...

 

 

Active Member
bulutok
Posts: 7
Registered: ‎02-07-2013
Message 7 of 19 (511 Views)

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.

*Expert Elite*
pbejse
Posts: 2,511
Registered: ‎11-24-2009
Message 8 of 19 (498 Views)

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?

 

 

Active Member
bulutok
Posts: 7
Registered: ‎02-07-2013
Message 9 of 19 (494 Views)

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!

*Expert Elite*
pbejse
Posts: 2,511
Registered: ‎11-24-2009
Message 10 of 19 (491 Views)

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

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.