Write length between two points

Write length between two points

k005
Advisor Advisor
1,772 Views
22 Replies
Message 1 of 23

Write length between two points

k005
Advisor
Advisor

 

 

Hello friends, Good morning everyone.

 

How can I print a length between points P1 and P2 on the "KirisYaZiUzunluk" layer? text position = P1/P2

 

object snap : End point , intersection must be open.

0 Likes
Accepted solutions (2)
1,773 Views
22 Replies
Replies (22)
Message 2 of 23

hak_vz
Advisor
Advisor

@k005  Try this. I’m a little crowded so I don’t have time to work it out in details, but it should work ok.

 

 

(defun c:tonhalf (/ p1 p2 *error*)
	(defun *error* () (princ))
	(while
		(and
			(setq p1 (getpoint "\nSelect first point >"))
			(setq p2 (getpoint "\nSelect second point >"))
		)
		(entmake
			(list
			(cons 0 "TEXT")
			(cons 8 "KirisYaZiUzunluk")
			(cons 10 (mapcar '* (mapcar '+ p1 p2) '(0.5 0.5)))
			(cons 50 (angle p1 p2))
			(cons 1 (rtos (distance p1 p2) 2 2))
			)
		)
	)
	(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.
Message 3 of 23

k005
Advisor
Advisor

@hak_vz 

 

I did not see the article.

OK, no rush. Thanks for your opinion my friend.

0 Likes
Message 4 of 23

hak_vz
Advisor
Advisor
Accepted solution

It should work ok. Here you can change text height (cons 40 5) to what you want.

 

(defun c:tonhalf (/ p1 p2 *error*)
	(defun *error* () (princ))
	(while
		(and
			(setq p1 (getpoint "\nSelect first point >"))
			(setq p2 (getpoint "\nSelect second point >"))
		)
		(entmake
			(list
			(cons 0 "TEXT")
			(cons 8 "KirisYaZiUzunluk")
			(cons 10 (mapcar '* (mapcar '+ p1 p2) '(0.5 0.5)))
			(cons 40 5) ;text height
			(cons 50 (angle p1 p2))
			(cons 1 (rtos (distance p1 p2) 2 2))
			)
		)
	)
	(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.
Message 5 of 23

pbejse
Mentor
Mentor

@k005 wrote:

object snap : End point , intersection must be open.


  • What do you mean by that?
  • Do you want the TEXT on top or at the bottom?
  • Will it be just the distance value ? any prefix or suffix
  • What about text height?
  • Always right side up YES?

 

 

Message 6 of 23

k005
Advisor
Advisor

@hak_vz 

 

Thank you very much, it's ok. 🤗

Message 7 of 23

k005
Advisor
Advisor

@pbejse 

 

text height : textsize

and only length

0 Likes
Message 8 of 23

pbejse
Mentor
Mentor
Accepted solution

@k005 wrote:

text height : textsize

and only length


 

(Defun c:TOPL (/ pt1 pt2 _trans) 
(setq _trans (lambda (p)(trans p 1 0)))
(setq TextHeight (getvar 'textsize))  
  (if (setq pt1 (getpoint "\nPick the first Point: "))
    (progn
      (while (setq pt2 (getpoint pt1 "\nPick Next point:"))
            (entmakex
              (list
                (cons 0 "TEXT")
		(cons 8 "KirisYaZiUzunluk")
                (cons 10
                      (Setq p_  ( _trans  (polar
                                 (mapcar '(lambda (x y)
                                            (* 0.5 (+ x y))
                                          )
                                         pt1
                                         pt2
                                 )
                                 (+ (setq ang (angle  (_trans pt1)( _trans  pt2))) (/ pi 2.0))
                                 (* TextHeight 1.15)
                               ) )
                      ) 
                )
                (cons 11 p_)
                (cons 40  TextHeight)
                (Cons 50 
			(if (and
			(> ang (/ pi 2))
			(<= ang (* pi 1.5))
			)  (+ ang pi) ang ))
                '(72 . 4)
                '(73 . 3)
                (cons 1
                      (strcat "Uzunluk : "(rtos (distance pt1 pt2) 2 2))
                )
              )
            )
            (setq pt1 pt2)
          )
        )
      )
  (princ)
)

 

HTH

Message 9 of 23

k005
Advisor
Advisor

@pbejse 

 

 

I'm so sorry, I can use it more comfortably if we make a small prefix

"Uzunluk" : xxxx

0 Likes
Message 10 of 23

pbejse
Mentor
Mentor

@k005 wrote:

I'm so sorry, I can use it more comfortably if we make a small prefix

"Uzunluk" : xxxx


I dont know what to make of that statement. @k005 .

It sounded like using the program gives you discomfort 😄

 

Remember that i did ask for that option on my earlier post. 

The code on previous posts updated to

 

(cons 1
      (strcat "Uzunluk : "(rtos (distance pt1 pt2) 2 2))
)

 

HTH

 

Message 11 of 23

k005
Advisor
Advisor

@pbejse 

 

Working with the codes you have written is much more enjoyable, my friend. 😊

 

Thank you so much

0 Likes
Message 12 of 23

Kent1Cooper
Consultant
Consultant

I suggest a different approach:  Define a Dimension Style with both extension lines and both dimension lines suppressed, and with the prefix you want [and the text style and height, here using those of the Text in your sample drawing]:

Kent1Cooper_0-1628512212794.pngKent1Cooper_1-1628512285670.pngKent1Cooper_2-1628512328536.png

Then draw Aligned Dimensions.  All you need for a routine is this much:

(defun C:WHATEVER ()
  (command
    "_.layer" "_m" "KirisYaZiUzunluk" ""
    "_.dimstyle" "_restore" "YourStyleName"
    "_.dimaligned" pause pause "@"
  ); command
  (princ)
); defun

[Edit "YourStyleName" to whatever you call it.]

 

This has significant advantages over "loose" pieces of Text.  If you change the locations of the points, such as by STRETCHing or grip editing, everything adjusts automatically -- position, angle, numerical content, more-upright-readable text direction and side, etc.

Whatever.gif

Kent Cooper, AIA
Message 13 of 23

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:

....

This has significant advantages over "loose" pieces of Text.  ....


Here's another:  If you decide you need [for example] only one decimal place, or maybe three decimal places, and/or a different prefix [whether a different word, or something like omitting the spaces around the colon to make text elements a little shorter], and/or a suffix, too, or maybe a suffix instead of a prefix, you can change such things in the Dimension Style definition, and all the Dimensions will change accordingly, automatically.

 

Under routines that place independent Text, any such changes would require editing and re-loading the routine code, Erasing obsolete Text objects, and running the routine again for each one.  The kinds of changes demonstrated in the video in my previous Reply wouldn't require code changes, but would still require Erasing and redoing.

Kent Cooper, AIA
0 Likes
Message 14 of 23

k005
Advisor
Advisor

 

 

@Kent1Cooper 

 

No extension or shortening is required at this time. Thank you very much for your suggestion.

0 Likes
Message 15 of 23

k005
Advisor
Advisor

@hak_vz 

 

@pbejse 

 

Adding:

 

Can we draw little yellow dots on points P1 and P2?

 

dot size : textsize

 

I can't remember where the dots are from when there are so many beams...

For this reason, it can be dots or another dot mark..

0 Likes
Message 16 of 23

Kent1Cooper
Consultant
Consultant

@k005 wrote:

....

Can we draw little yellow dots on points P1 and P2?

....


That's another thing that can be accomplished in a dedicated Dimension Style:

Kent1Cooper_0-1629388083262.png

provided you are willing to have the dimension lines not suppressed as in my earlier suggestion [because the arrowheads don't show when the dimension lines are suppressed].  Set the Arrow size the same as the Text height, and the dimension line color to 2.  Then my earlier little routine would work unchanged, unless you want to build in a DRAWORDER command to put the Dimension behind the Line [or whatever]:

 

(defun C:WHATEVER ()
  (command
    "_.layer" "_m" "KirisYaZiUzunluk" ""
    "_.dimstyle" "_restore" "YourStyleName"
    "_.dimaligned" pause pause "@"
    "_.draworder" (entlast) "" "_back"
  ); command
  (princ)
); defun

 

WHATEVER.gif

Kent Cooper, AIA
0 Likes
Message 17 of 23

k005
Advisor
Advisor

@Kent1Cooper 

 

 

How can we do dimensioning without connecting it to this job?
i.e. without changing the dimensioning style..

0 Likes
Message 18 of 23

Kent1Cooper
Consultant
Consultant

Here's a further benefit of doing it with a Dimension Style, rather than [for example] @ronjonp's _makedot routine if you bring that over from the other topic.

 

Incorporating that routine into the other will create Polyline dots [Donuts with zero inside diameter], which will be independent of the things whose lengths are marked, and independent of the Text that marks the lengths.  But as the arrowheads on Dimensions, they'll be tied to the text, and if you have Associative Dimensioning turned on when you add them, also tied to the linework, and can't be independently displaced.

 

Also, if [or when?] you decide you don't want to see the dots, with _makedot dots, you would need to go around and find them all to ERASE.  But with Dimensions, you could grab an entire area of stuff with lengths marked, in a collective selection, and in Properties, limit consideration to only the Aligned Dimensions, and just turn off the dimension lines [which will also turn off the arrowhead dots]:

Kent1Cooper_0-1629390335960.png

Then all the dots will disappear, but they'll still be there in case you want to see them again -- just turn on the Dimension lines again.

Kent Cooper, AIA
0 Likes
Message 19 of 23

ronjonp
Advisor
Advisor

@Kent1Cooper 100% agree that a dimstyle is a better choice. Disjointed objects usually make for more work later.

0 Likes
Message 20 of 23

Kent1Cooper
Consultant
Consultant

@k005 wrote:

How can we do dimensioning without connecting it to this job? i.e. without changing the dimensioning style..


I don't understand.  I'm not suggesting changing any Dimension Styles that you use for other purposes.  I'm suggesting creating one specifically for this purpose.  Then you would change the current Dimension Style when doing these kinds of markings.  It would not affect any other Dimensions.  Setting it current is built into the code, and it could be made to save whatever Dimension Style was current, and re-set it when you're done.

 

If you want to use the special-purpose Dimension Style in other drawings, you don't need to create it again in every drawing.  The Design Center [ADC command, or Ctrl+2] can bring it in for you.  If you use it universally, you can have it in your drawing template files, and it will always be available in every new drawing [unless and until Purged if unused].

Kent Cooper, AIA
0 Likes