Message 1 of 6
Arrow on 3d polyline to show water flow direction - LISP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I will appreciate if someone could help modify this nice LISP written by Stefan and Jonathan that I founded here:
https://www.cadtutor.net/forum/topic/57478-arrow-on-3d-polyline-to-show-water-flow-direction/
This lisp adds arrows symbol to a 3D polyline to show water flow direction (based on Z values).
Is it possible to modify it so instead of arrows created in 2D polylines, all the arrows on a single object will turn to a block with an insertion point in the middle of it.
I have attached a DWG file with an example of the current situation and the desired one (made manually).
Thank you very much in advance
This is the lisp:
;Show flow direction
;Stefan M. - 26.07.2015
(defun c:flow ( / *error* ms ss e l key d i n c y p f a p1 p2 p3 ar) ; Variable 'i' localised (Jonathan Handojo)
(or acDoc (setq acDoc (vla-get-activedocument (vlax-get-acad-object))))
(setq ms (vlax-get acDoc (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace)))
(vla-startundomark acDoc)
(defun *error* (msg)
(and
msg
(not (wcmatch (strcase msg) "*CANCEL*,*QUIT*,*EXIT*"))
(princ (strcat "\nError: " msg))
)
(vla-endundomark acDoc)
(princ)
)
(if
(eq (vla-get-lock (vla-get-activelayer acdoc)) :vlax-true)
(progn
(princ "\nCurrent Layer is locked.")
(exit)
)
)
(if
(setq ss (ssget '((0 . "POLYLINE") (-4 . "&=") (70 . 8)))) ; Modified to multiple selection (Jonathan Handojo)
(progn
(or (tblsearch "layer" "arrow") (vla-add (vla-get-layers acDoc) "arrow"))
;;; (setq e (ssname ss 0) ; Commented (Jonathan Handojo)
;;; l (vlax-curve-getdistatpoint e (vlax-curve-getendpoint e))
;;; )
(initget "Distance Items" 1)
(setq key (getkword "\nChoose a method [Distance/Items]: ")) ; Modified (Jonathan Handojo)
(if
(eq key "Distance")
(setq d (getdist "\nDistance between arrows: "))
(setq n (getint "\nNumber of arrows: "))
)
(repeat (setq i (sslength ss)) ; Repeat loop (Jonathan Handojo)
(setq i (1- i) e (ssname ss i) ; Curve details moved here (Jonathan Handojo)
l (vlax-curve-getdistatpoint e (vlax-curve-getendpoint e))
)
(if n (setq d (/ l n)))
(if d
(progn
(setq c 0.0 y (/ d 5.0))
(while (< (setq c (+ c d)) l)
(setq p (vlax-curve-getpointatdist e c)
f (vlax-curve-getfirstderiv e (vlax-curve-getparamatpoint e p))
a (angle '(0.0 0.0) f)
p1 (polar p a (if (minusp (caddr f)) (- y) y))
p2 (polar p1 (+ a (* pi 0.5)) (* 0.4 y))
p3 (polar p1 (- a (* pi 0.5)) (* 0.4 y))
ar (vla-Add3DPoly ms
(vlax-safearray-fill
(vlax-make-safearray vlax-vbDouble '(0 . 8))
(append p2 p p3)
)
)
)
(vla-put-closed ar :vlax-true)
;;; (vla-put-color ar (if (minusp (caddr f)) acred acyellow))
(vla-put-layer ar "arrow")
)
)
)
) ; Repeat loop end (Jonathan Handojo)
)
)
(*error* nil)
(princ)
)