Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
ronjonp's code taken from here: https://www.cadtutor.net/forum/topic/73618-auto-add-a-block-to-the-end-of-polylines/
How can I rotate the block placed at the pline end 180 degrees? Solved: Removed + pi
Also, how would I use a variable in place of the hard coded 50 dxf in the entmake?
(defun ins_Term_R (/ _ang a ep p r s sp blk)
;; RJP » 2021-08-24
(setq blk "T2S_Straight_001")
(defun _ang (e pt / a pa)
(if (and (setq pa (vlax-curve-getparamatpoint e pt))
(setq a (angle '(0 0 0) (vlax-curve-getfirstderiv e pa)))
)
a
)
)
(cond ((null (tblobjname "block" blk)) (alert (strcat "Block " blk " needed!")))
((setq s ss_center1);(ssget '((0 . "LWPOLYLINE"))))
(foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
;(setq r (cons (list (setq sp (vlax-curve-getstartpoint e)) (_ang e sp)) r))
(setq r (cons (list (setq ep (vlax-curve-getendpoint e)) (+ pi (_ang e ep))) r))
)
(while (setq p (car r)) (princ (cadr p))
(or (vl-some '(lambda (x) (and (equal (car p) (car x) 1e-1) (setq a (cons x a))))
(append a (setq r (cdr r)))
)
(entmake (list '(0 . "INSERT")
'(100 . "AcDbEntity")
'(67 . 0)
'(8 . "CABLE 1")
'(48 . 0.0006)
'(100 . "AcDbBlockReference")
'(2 . "T2S_Straight_001")
(cons 10 (car p))
'(41 . 1.)
'(42 . 1.)
'(43 . 1.)
(cons 50 (cadr p))
'(70 . 0)
'(71 . 0)
'(44 . 0.)
'(45 . 0.)
'(210 0. 0. 1.)
)
)
)
)
)
)
(setq ss_term2 (ssget "l"))
(princ)
)
AutoCad 2018 (full)
Win 11 Pro
Win 11 Pro
Solved! Go to Solution.