Routine for double arrows

Routine for double arrows

kzD1219
Collaborator Collaborator
3,600 Views
10 Replies
Message 1 of 11

Routine for double arrows

kzD1219
Collaborator
Collaborator

Is there any routine or command that can produce a line/polyline with an arrowhead block we use on either end of the line?  Currently we are using a dimension line and exploding it.  Yes I know that isn't great, but I don't need the dimension, just the line and arrows. 

 

 

Untitled.jpg

0 Likes
Accepted solutions (1)
3,601 Views
10 Replies
Replies (10)
Message 2 of 11

ВeekeeCZ
Consultant
Consultant

Sure there are plenty. This one use a polyline's width. Other way may be use blocks. 

 

(defun c:arrow2 ( / di nm p1 p2 )
  (if (and (setq p2 (getpoint "\nArrow Point From: "))
           (setq p1 (getpoint "\nArrow Head: " p2))
           (setq di 1.5; SIZE
                 ; (/ (distance p1 p2) 3.0)
                 nm (trans '(0. 0. 1.) 1 0 t)))
    (entmake (list '(0 . "LWPOLYLINE")
                   '(100 . "AcDbEntity")
                   '(100 . "AcDbPolyline")
                   '(90 . 3)
                   '(70 . 0)
                   (cons 10 (trans p1 1 nm))
                   '(40 . 0.0)
                   (cons 41 (/ di 2.0))
                   (cons 10 (trans (polar p1 (angle p1 p2) di) 1 nm))
                   (cons 10 (trans (polar p2 (angle p2 p1) di) 1 nm))
                   (cons 40 (/ di 2.0))
                   '(41 . 0.0)
                   (cons 10 (trans p2 1 nm))
                   (cons 210 nm)
                   ))))
(princ)
)
0 Likes
Message 3 of 11

ВeekeeCZ
Consultant
Consultant

Or using blocks... you can either draw line or selection multiple of arc, polyline, lines.

 

(vl-load-com)

(defun c:ArrowDouble ( / pnt enl ent ss i)

  (if (setq pnt (getpoint "\nFirst point <select>: "))
    (progn
      (setq enl (entlast))
      (command "_.LINE" "_none" pnt pause "")
      (if (not (equal enl (setq enl (entlast))))
	(setq ss (ssadd enl))))
    (setq ss (ssget "_:L" '((0 . "LWPOLYLINE,LINE,ARC")))))

  (if ss
    (repeat (setq i (sslength ss))
      (setq ent (ssname ss (setq i (1- i))))
      
      (command "._INSERT"
               "_Open30" ; Block Arrow Name
               "_Scale" 1
               "_Rotate" "_none" (trans (vlax-curve-getFirstDeriv ent (vlax-curve-getParamAtPoint ent (vlax-curve-getStartPoint ent))) 0 1) "_none" (trans '(0 0 0) 0 1) 
               "_none" (trans (vlax-curve-getStartPoint ent) 0 1))

      (command "._INSERT"
               "_Open30"
               "_Scale" 1
               "_Rotate" "_none" (trans '(0 0 0) 0 1) "_none" (trans (vlax-curve-getFirstDeriv ent (vlax-curve-getParamAtPoint ent (vlax-curve-getEndPoint ent))) 0 1)
               "_none" (trans (vlax-curve-getEndPoint ent) 0 1))))
  (princ)
)
0 Likes
Message 4 of 11

kzD1219
Collaborator
Collaborator

@ВeekeeCZ wrote:

Or using blocks... you can either draw line or selection multiple of arc, polyline, lines.

 

(vl-load-com)

(defun c:ArrowDouble ( / pnt enl ent ss i)

  (if (setq pnt (getpoint "\nFirst point <select>: "))
    (progn
      (setq enl (entlast))
      (command "_.LINE" "_none" pnt pause "")
      (if (not (equal enl (setq enl (entlast))))
	(setq ss (ssadd enl))))
    (setq ss (ssget "_:L" '((0 . "LWPOLYLINE,LINE,ARC")))))

  (if ss
    (repeat (setq i (sslength ss))
      (setq ent (ssname ss (setq i (1- i))))
      
      (command "._INSERT"
               "_Open30" ; Block Arrow Name
               "_Scale" 1
               "_Rotate" "_none" (trans (vlax-curve-getFirstDeriv ent (vlax-curve-getParamAtPoint ent (vlax-curve-getStartPoint ent))) 0 1) "_none" (trans '(0 0 0) 0 1) 
               "_none" (trans (vlax-curve-getStartPoint ent) 0 1))

      (command "._INSERT"
               "_Open30"
               "_Scale" 1
               "_Rotate" "_none" (trans '(0 0 0) 0 1) "_none" (trans (vlax-curve-getFirstDeriv ent (vlax-curve-getParamAtPoint ent (vlax-curve-getEndPoint ent))) 0 1)
               "_none" (trans (vlax-curve-getEndPoint ent) 0 1))))
  (princ)
)

Unfortunately I am not good at figuring out lisp routines that easily.  How do I get this routine to use the DIM-AH block that we have?  I like the polyline option you posted, however I need the routine to use a the arrowhead block that we have.

0 Likes
Message 5 of 11

ВeekeeCZ
Consultant
Consultant

@kzD1219 wrote:

@ВeekeeCZ wrote:

Or using blocks... you can either draw line or selection multiple of arc, polyline, lines.

 

(vl-load-com)

(defun c:ArrowDouble ( / pnt enl ent ss i)

  (if (setq pnt (getpoint "\nFirst point <select>: "))
    (progn
      (setq enl (entlast))
      (command "_.LINE" "_none" pnt pause "")
      (if (not (equal enl (setq enl (entlast))))
	(setq ss (ssadd enl))))
    (setq ss (ssget "_:L" '((0 . "LWPOLYLINE,LINE,ARC")))))

  (if ss
    (repeat (setq i (sslength ss))
      (setq ent (ssname ss (setq i (1- i))))
      
      (command "._INSERT"
               "_Open30" ; Block Arrow Name
               "_Scale" 1
               "_Rotate" "_none" (trans (vlax-curve-getFirstDeriv ent (vlax-curve-getParamAtPoint ent (vlax-curve-getStartPoint ent))) 0 1) "_none" (trans '(0 0 0) 0 1) 
               "_none" (trans (vlax-curve-getStartPoint ent) 0 1))

      (command "._INSERT"
               "_Open30"
               "_Scale" 1
               "_Rotate" "_none" (trans '(0 0 0) 0 1) "_none" (trans (vlax-curve-getFirstDeriv ent (vlax-curve-getParamAtPoint ent (vlax-curve-getEndPoint ent))) 0 1)
               "_none" (trans (vlax-curve-getEndPoint ent) 0 1))))
  (princ)
)

Unfortunately I am not good at figuring out lisp routines that easily.  How do I get this routine to use the DIM-AH block that we have?  I like the polyline option you posted, however I need the routine to use a the arrowhead block that we have.


I should have highlight the comment.

0 Likes
Message 6 of 11

kzD1219
Collaborator
Collaborator

Where is says "block Arrow name" I am replacing that with my block name correct?  I can't seem to get the lisp to work does it have to be in quotation marks or brackets?  And do I need in it both places that say " Open30 "?

0 Likes
Message 7 of 11

ВeekeeCZ
Consultant
Consultant

Like this:

 

 

(vl-load-com)

(defun c:ArrowDouble ( / pnt enl ent ss i)

  (if (setq pnt (getpoint "\nFirst point <select>: "))
    (progn
      (setq enl (entlast))
      (command "_.LINE" "_none" pnt pause "")
      (if (not (equal enl (setq enl (entlast))))
	(setq ss (ssadd enl))))
    (setq ss (ssget "_:L" '((0 . "LWPOLYLINE,LINE,ARC")))))

  (if ss
    (repeat (setq i (sslength ss))
      (setq ent (ssname ss (setq i (1- i))))
      
      (command "._INSERT"
               "DIM-AH"
               "_Scale" 1
               "_Rotate" "_none" (trans (vlax-curve-getFirstDeriv ent (vlax-curve-getParamAtPoint ent (vlax-curve-getStartPoint ent))) 0 1) "_none" (trans '(0 0 0) 0 1) 
               "_none" (trans (vlax-curve-getStartPoint ent) 0 1))

      (command "._INSERT"
               "DIM-AH"
               "_Scale" 1
               "_Rotate" "_none" (trans '(0 0 0) 0 1) "_none" (trans (vlax-curve-getFirstDeriv ent (vlax-curve-getParamAtPoint ent (vlax-curve-getEndPoint ent))) 0 1)
               "_none" (trans (vlax-curve-getEndPoint ent) 0 1))))
  (princ)
)

Twice, because you have 2 ends. Text behind the semicolon is just a commentary for a user - for you to know where put the name. 

 

You can try to run "-INSERT" command into command-line and follow the prompts. Its the same.

0 Likes
Message 8 of 11

kzD1219
Collaborator
Collaborator

Ok, I see that now.  Last question...is there a way to have the scale of the block change with what drawing scale I am working at.  For example when I am working at 1"=40' and using a leader line, the block comes in at a scale of 4.  If at 1"=60' it is a scale of 6.

 

I really do appreciate the help!

0 Likes
Message 9 of 11

Kent1Cooper
Consultant
Consultant

No need for AutoLisp routines, etc., nor dealing with Blocks at different scales, nor Exploding a Dimension.  Just define a Dimension Style with both extension lines suppressed, and your preferred arrowheads [arrowheads like the ones in your image can't be done  with a variable-width Polyline], and when drawing any linear Dimension with it, choose the Text option, and give it a single space as a text override.

 

That will work with different scales just as other Dimensions do, and unlike either  a variable-width-Polyline-constructing routine or  a Block-Insertion-at-both-ends routine, the arrowheads will adjust perfectly if you stretch or grip-edit it to a different "route."

Kent Cooper, AIA
0 Likes
Message 10 of 11

ВeekeeCZ
Consultant
Consultant

Try like this. But I am not really versed in the imperial system, so you might need to fix the math.

 

(vl-load-com)

(defun c:ArrowDouble ( / pnt enl ent ss i)

  (if (setq pnt (getpoint "\nFirst point <select>: "))
    (progn
      (setq enl (entlast))
      (command "_.LINE" "_none" pnt pause "")
      (if (not (equal enl (setq enl (entlast))))
	(setq ss (ssadd enl))))
    (setq ss (ssget "_:L" '((0 . "LWPOLYLINE,LINE,ARC")))))

  (if ss
    (repeat (setq i (sslength ss))
      (setq ent (ssname ss (setq i (1- i))))
      
      (command "._INSERT"
               "DIM-AH"
               "_Scale" (/ 1. (getvar 'CANNOSCALEVALUE) 120)
               "_Rotate" "_none" (trans (vlax-curve-getFirstDeriv ent (vlax-curve-getParamAtPoint ent (vlax-curve-getStartPoint ent))) 0 1) "_none" (trans '(0 0 0) 0 1) 
               "_none" (trans (vlax-curve-getStartPoint ent) 0 1))

      (command "._INSERT"
               "DIM-AH"
               "_Scale" (/ 1. (getvar 'CANNOSCALEVALUE) 120)
               "_Rotate" "_none" (trans '(0 0 0) 0 1) "_none" (trans (vlax-curve-getFirstDeriv ent (vlax-curve-getParamAtPoint ent (vlax-curve-getEndPoint ent))) 0 1)
               "_none" (trans (vlax-curve-getEndPoint ent) 0 1))))
  (princ)
)
0 Likes
Message 11 of 11

Kent1Cooper
Consultant
Consultant
Accepted solution

@Kent1Cooper wrote:

.... define a Dimension Style with both extension lines suppressed, and your preferred arrowheads ..., and when drawing any linear Dimension with it, choose the Text option, and give it a single space as a text override.

....

Given a Style defined that way, here's all the command you need:

 

(defun C:ABE (); = Arrows Both Ends
  (command
    "_.dimstyle" "_restore" "YourArrowsBothEndsStyleName"
    "_.dimaligned" pause pause "_text" " " "@"
  )
(princ) )

It could add saving of the current Dimension Style and restoring it afterwards, for the sake of "real" Dimensions.

Kent Cooper, AIA