insert specified block at the end of polyline
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hello
with an attached lisp I can to insert a block with the specified name to the end of the chosen polyline... but insertion done for both ends of polyline >>> i want to insert block for one side only ... thank you
(defun c:BAE ( / *error* _StartUndo _EndUndo _Insert _AngleAtParam doc block ss )
(vl-load-com)
(setq block "endtick") ;; << Block Name
(defun *error* ( msg )
(and doc (_EndUndo doc))
(or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
(princ (strcat "\n** Error: " msg " **")))
(princ)
)
(defun _StartUndo ( doc ) (_EndUndo doc)
(vla-StartUndoMark doc)
)
(defun _EndUndo ( doc )
(if (= 8 (logand 8 (getvar 'UNDOCTL)))
(vla-EndUndoMark doc)
)
)
(defun _Insert ( block point rotation )
(entmakex
(list
(cons 0 "INSERT")
(cons 2 block)
(cons 10 point)
(cons 50 rotation)
)
)
)
(defun _AngleatParam ( entity param )
(angle '(0. 0. 0.) (vlax-curve-getFirstDeriv entity param))
)
(setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
(cond
( (= 4 (logand 4 (cdr (assoc 70 (tblsearch "LAYER" (getvar 'CLAYER))))))
(princ "\n** Current Layer Locked **")
)
( (not
(or
(and (tblsearch "BLOCK" (vl-filename-base block))
(setq block (vl-filename-base block))
)
(and
(setq block
(findfile
(strcat block
(if (eq "" (vl-filename-extension block)) ".dwg" "")
)
)
)
(
(lambda ( / ocm )
(setq ocm (getvar 'CMDECHO)) (setvar 'CMDECHO 0)
(command "_.-insert" block) (command)
(setvar 'CMDECHO ocm)
(tblsearch "BLOCK" (setq block (vl-filename-base block)))
)
)
)
)
)
(princ "\n** Block not Found **")
)
( (not (setq ss (ssget '((0 . "*POLYLINE")))))
(princ "\n*Cancel*")
)
(t
(_StartUndo doc)
(
(lambda ( i / e )
(while (setq e (ssname ss (setq i (1+ i))))
(foreach param (list (vlax-curve-getStartParam e) (vlax-curve-getEndParam e))
(_Insert block (vlax-curve-getPointatParam e param) (_AngleAtParam e param))
)
)
)
-1
)
(_EndUndo doc)
)
)
(princ)
)