- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The image below shows the latest offset correction doesn't comly with command. any tips to correct this.
(defun c:RDD_Roofdimn ( / ent obj coords n i j p1 p2 mid offset object_offset offset_direction)
;; Set or create dimension layer
(if (tblsearch "layer" "PV-TEXT-DIMN")
(setvar "clayer" "PV-TEXT-DIMN")
(command "._LAYER" "_Make" "PV-TEXT-DIMN" "")
)
;; Prompt for polyline
(setq ent (car (entsel "\nSelect 2D closed polyline (roof outline): ")))
(if (and ent (= (cdr (assoc 0 (entget ent))) "LWPOLYLINE"))
(progn
(setq obj (vlax-ename->vla-object ent))
;; Check if closed
(if (not (= (vla-get-Closed obj) :vlax-true))
(progn
(prompt "\nPolyline is not closed.")
(command "._UNDO" "_End")
(exit)
)
)
;; Determine offset direction
(setq object_offset (car (vlax-invoke obj 'Offset 150.0)))
(setq offset_direction (if (> (vla-get-Area object_offset) (vla-get-Area obj)) -2 2))
(vla-delete object_offset)r
;; Get polyline coordinates
(setq coords (vlax-get obj 'Coordinates))
(setq n (/ (length coords) 2))
(setq i 0)
(setq offset 100.0)
;; Loop through vertices
(while (< i n)
(setq p1 (list (nth (* i 2) coords) (nth (+ 1 (* i 2)) coords) 2.0))
(setq j (if (= i (- n 1)) 0 (+ i 1)))
(setq p2 (list (nth (* j 2) coords) (nth (+ 1 (* j 2)) coords) 2.0))
;; Midpoint for dimension placement
(setq mid (polar
(mapcar '(lambda (a b) (/ (+ a b) 2.0)) p1 p2)
(+ (* -1.5 pi) (angle p1 p2))
(* offset_direction offset)
))
;; Place dimension
(command "._DIMALIGNED" p1 p2 mid)
(setq i (1+ i))
)
(prompt (strcat "\n" (itoa n) " aligned dimensions placed."))
)
(prompt "\nInvalid selection. Please select a closed LWPOLYLINE.")
)
(princ)
)
Solved! Go to Solution.