Message 1 of 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, I need help with deleting a line and exploding the block after command is executed. What I'm trying to do is create a reference line by selecting two points and then use midpoint of that line to place base point of a block with angle orientation. When current code is executed, it does place the block as I intended, but it does not delete the reference line or explode after. I tried using "(ssdel (list connectingLine))" and when I do use this code instead of entde1, somehow it bypasses the code and does allow block to be exploded. The reference remains still un-deleted though... please help
(defun c:WQ (/ startPoint endPoint connectingLine)
(defun insert-block-at-midpoint (midpoint rotation length)
(setq roundedLength
(+ (fix length) (- (if (< (rem (fix length) 100) 50) 50 100) (rem (fix length) 100))))
(setq blockName (strcat (rtos roundedLength 2 0) "ec"))
(if (or (tblobjname "BLOCK" blockName)
(findfile (strcat blockName ".dwg")))
(command "_.INSERT" blockName "_non" midpoint 1.0 1.0 rotation)
(alert (strcat "Block '" blockName "' missing"))))
(setq startPoint (getpoint "\nSelect first and second points: "))
(setq endPoint (getpoint))
(setq connectingLine (entmake (list '(0 . "LINE") (cons 10 startPoint) (cons 11 endPoint))))
(setq midPoint (list (/ (+ (car startPoint) (car endPoint)) 2.0)
(/ (+ (cadr startPoint) (cadr endPoint)) 2.0)
0.0))
(setq rotation (angle startPoint endPoint))
(setq rotation (/ (* rotation 180.0) pi))
(insert-block-at-midpoint midPoint rotation (distance startPoint endPoint))
;; Delete the connecting line using entdel
(entdel connectingLine)
;; Execute explode command after a delay
(vl-cmdf "_.EXPLODE" "L" "")
)
(princ "\nType WT to use the command.")
Solved! Go to Solution.