Lisp Routine that will draw an arc with an arrowhead at both ends

Lisp Routine that will draw an arc with an arrowhead at both ends

tinapirog
Observer Observer
1,152 Views
4 Replies
Message 1 of 5

Lisp Routine that will draw an arc with an arrowhead at both ends

tinapirog
Observer
Observer

I frequently have to draw swing ties on drawings to show locations of things. I usually draw an arc and put a block I call "arrow" on each end of the arc, rotated to align with whatever angle the arc is drawn. It is a tedious task when you have many to do. Would be great to have a routine that will draw the arc, put the arrow at both ends, an even allow you to put text on the arc to show the distance. This text should be editable, since lots of ties are not exact.

 

0 Likes
1,153 Views
4 Replies
Replies (4)
Message 2 of 5

Kent1Cooper
Consultant
Consultant

Assuming the Arrow Block is oriented this way at zero rotation:

Kent1Cooper_0-1637331743532.png

and its insertion point is at the tip, and you always want it Inserted at scale factors of 1, and it's not defined for uniform scaling, the Arc-and-arrowheads part can be done with this:

 

(vl-load-com) ; if needed
(defun C:AABE ; = Arc with Arrows at Both Ends
  (/ arc)
  (command-s "_.arc")
  (setq arc (entlast))
  (command
    "_.insert" "ARROW" "_non" (vlax-curve-getStartPoint arc)
      "" "" (angtos (angle '(0 0) (vlax-curve-getFirstDeriv arc (vlax-curve-getStartParam arc))))
    "_.insert" "ARROW" "_non" (vlax-curve-getEndPoint arc)
      "" "" (angtos (+ (angle '(0 0) (vlax-curve-getFirstDeriv arc (vlax-curve-getEndParam arc))) pi))
  ); command
  (princ)
)

 

If any of my assumptions are incorrect, different realities can be accounted for.

 

As for the Text, what is "the distance" that it should show?  The length of the Arc itself?  The straight-line distance between its ends?  Something else?  An image or sample drawing of the desired result would be helpful for consideration of location, rotation, justification, height, etc.

Kent Cooper, AIA
Message 3 of 5

ВeekeeCZ
Consultant
Consultant

Just thought about using the built-in arrow. 

 

(vl-load-com) ; if needed
(defun C:AABE ; = Arc with Arrows at Both Ends
  (/ arc db1)

  (setq db1 (getvar 'dimblk1))
  (setvar 'dimblk1 "Open30") ;; this brings a block into drawing
  (setvar 'dimblk1 db1)
  
  (command-s "_.arc")
  (setq arc (entlast))
  (command
    "_.insert" "_Open30" "_non" (vlax-curve-getStartPoint arc)
      "" "" (angtos (+ (angle '(0 0) (vlax-curve-getFirstDeriv arc (vlax-curve-getStartParam arc))) pi))
    "_.insert" "_Open30" "_non" (vlax-curve-getEndPoint arc)
      "" "" (angtos (angle '(0 0) (vlax-curve-getFirstDeriv arc (vlax-curve-getEndParam arc))))
  ); command
  (princ)
)

 

0 Likes
Message 4 of 5

tinapirog
Observer
Observer
Thank you! It does work.
0 Likes
Message 5 of 5

3wood
Advisor
Advisor

A simple Arc Length Dimension can work.

1. DIMARC the arc.

2. DIMTEDIT to locate the text.

3. Change dimension text to suit.

I attached an example dimension style for you to modify to suit.

DIMARC.gif