Zootango,
If you are having reason not to accept dimensions, I changed the routine based on your request.
If you are accepting dimensions as solution, I hope that it is going to help someone else, at least for educational purpose.
@Anonymous wrote:
Thanks dicra,
Your lisp is kinda there, it seems that whatever layer is current when the lisp is loaded the first time is the layer that is always used to create the objects even if you reload the lisp with a different layer current.
Would like the arrowheads solid ( what controls the arrowhead size?)
Would like all objects to be on the current layer.
Would like the text to be of the current text style and height and have a foot mark (253.45')
Other than these items your lisp is there though.
-It is making everything in current layer, block, text and arrows are in current layer, but objects which are in block definition are now stored in layer "0".
If block if defined, you will have to purge block, so that it will be recreated.
-Arrows are now solid, arrow size is based on length of line:
(setq block-scale (/ len 3));arrow scale - you can change this line to real value, if you wan't it to be constant (setq block-scale 1.0), or you can change it to (if (not block-scale) (setq block-scale (getreal "\nArrow size:")))
and remove block scale from local variables.
-Object is on current layer
-You have now foot mark on text, and if you want to put some another text style, you can do that in scs:addtext function, by adding line:
(vla-put-stylename thetext "Your_style_name")
Here is the changed code:
(vl-load-com)
(defun c:arrowline (/ p1 p2 len block-scale txtheight txtins )
(if (not (tblsearch "BLOCK" "ARROW")) (make_block))
(setq p1 (getpoint "\nFirst Point:")
p2 (getpoint "\nSecond Point:")
)
(entmakex (list (cons 0 "LINE")
(cons 10 p1)
(cons 11 p2)))
(setq len (distance p1 p2)
)
(setq block-scale (/ len 3));arrow scale
(Insertblock "ARROW" p1 block-scale block-scale (angle p1 p2))
(Insertblock "ARROW" p2 block-scale block-scale (angle p2 p1))
(setq txtheight (/ len 30));text height
(setq txtins (polar (polar p1 (angle p1 p2) (/ len 2)) (+ (/ pi 2)(angle p1 p2)) (* txtheight 0.3)))
(scs:addtext txtins txtheight (strcat (rtos len 2 2) "'") (angle p1 p2))
);end defun
(defun InsertBlock (Name InsPt XScale YScale Rot)
(vla-insertblock
((if (eq (getvar "cvport") 1)
vla-get-paperspace
vla-get-modelspace
) ;_ if
(vla-get-ActiveDocument
(vlax-get-acad-object)
) ;_ vla-get-ActiveDocument
)
(vlax-3d-point InsPt)
Name
XScale
YScale
XScale
Rot
) ;_ vla-insert-block
)
;Block definition
(defun make_block ()
;BLOCK Header definition:
(entmake'((0 . "BLOCK") (2 . "ARROW") (70 . 2) (10 0.0 0.0 0.0)))
;LWPOLYLINE definition:
(lwpoly1 '((0. 0. 0.) (0.18 0.03 0.) (0.18 -0.03 0.)) 1)
;HATCH definition:
(make_hatch '(0. 0. 0.)'(0.18 0.03 0.)'(0.18 -0.03 0.))
;BLOCK's ending definition:
(entmake '((0 . "ENDBLK")))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;polyline
(defun LWPoly1 (lst cls)
(entmake (append (list (cons 0 "LWPOLYLINE")
(cons 100 "AcDbEntity")
(cons 100 "AcDbPolyline")
(cons 8 "0")
(cons 90 (length lst))
(cons 70 cls)
)
(mapcar (function (lambda (p) (cons 10 p))) lst)))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;HATCH
(defun make_hatch (p1 p2 p3 /)
(entmake
(list (cons 0 "HATCH")
'(100 . "AcDbEntity")
(cons 8 "0")
'(100 . "AcDbHatch")
(cons 62 256)
(cons 10 (list 0.0 0.0 0.0))
(cons 210 (list 0.0 0.0 1.0))
;;changed z
(cons 2 "SOLID")
(cons 70 1)(cons 71 0)(cons 91 1)(cons 92 1)(cons 93 3)
(cons 72 1)(cons 10 p1)(cons 11 p2)
(cons 72 1)(cons 10 p2)(cons 11 p3)
(cons 72 1)(cons 10 p3)(cons 11 p1)
(cons 97 0)(cons 75 2)(cons 76 1)
(cons 98 1)
(cons 10 (list 0.0 0.0 0.0))
(cons 470 "LINEAR")
)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;TEXT
(defun scs:addText (apt ht thestring rotation / mspace thetext)
(vl-load-com)
(setq mspace (vla-get-modelspace
(vla-get-activedocument
(vlax-get-acad-object)
)
)
)
(setq thetext (vla-AddText
mspace
thestring
(vlax-3d-point apt)
ht
)
)
(vla-put-rotation thetext rotation)
(vla-put-Alignment thetext acAlignmentBottomCenter)
(vla-put-TextAlignmentPoint thetext (vlax-3d-point apt))
(princ)
) ;defun
PS Note that I changed function name to "arrowline"
I hope it helps!
dicra