- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi.
I have put together a LISP routine (please see below) that creates a dimension with specific text 'REFER SCHEDULE'.
It allocates the layer for the new dimension as '25CONT'.
That all works fine.
Please help with the following:
Once having executed the routine I would like to return the current layer '25CONT' to the previously used layer.
I am trying to use 'LAYERP' to achieve this though something isn't working.
Everything works fine though the layer remains on '25CONT' once having placed the dimension.
Any suggestions for improvement would be greatly appreciated.
Thank you.
(defun c:REF19 ( / pt1 pt2 angle dimEnt layName prevLay dimObj)
;; Define target layer
(setq layName "25CONT")
;; Save current layer name using a variable
(setq prevLay (getvar "CLAYER"))
;; Use command to change to 25CONT and allow LAYERP to track it
(if (not (tblsearch "LAYER" layName))
(command "._-LAYER" "Make" layName "Color" "7" "" "")
)
;; Use LAYER command to ensure LAYERP recognizes it
(command "._-LAYER" "Set" layName "")
;; Prompt for dimension points
(setq pt1 (getpoint "\nSpecify first extension line origin: "))
(setq pt2 (getpoint pt1 "\nSpecify second extension line origin: "))
(setq angle (getangle pt1 "\nSpecify rotation angle for dimension: "))
;; Create aligned dimension (user picks text location)
(command "._DIMALIGNED" pt1 pt2 pause)
(setq dimEnt (entlast))
;; Apply REFER/SCHEDULE text and rotation
(if (and dimEnt (entget dimEnt))
(progn
(setq dimObj (vlax-ename->vla-object dimEnt))
(vla-put-TextOverride dimObj "REFER\\XSCHEDULE") ; Above/Below text
(vla-put-Rotation dimObj angle)
(vla-put-TextDirection dimObj (vlax-3d-point '(1 0 0))) ; Left-to-right
)
)
(command "._LAYERP")
(princ)
)
Solved! Go to Solution.