Hi,
I am struggling with UCS command in AutoLISP. I am repositioning UCS by shifting its origin to start of a LINE and aligning X-axis to the LINE itself. The point on XY plane can be choosen manually. This routine should make a user choose a line and then reposition UCS accordingly.
(setq current_line (entsel "\n Select the LINE: "))
(setq point1_wcs (cdr (assoc 10 (entget (car current_line))))); one end of the line in WCS
(setq point1_ucs (trans point1_wcs 0 1)) ; same end of the line in UCS
(setq point2_wcs (cdr (assoc 11 (entget (car current_line))))); another end of the line in WCS
(setq point2_ucs (trans point1_wcs 0 1)) ; same end of the line in UCS
(command "ucs" point1_ucs pause pause)
I figured out how to pass origin point to LISP but can't seem to figure out what to pass as a second argument. I would assume it must be a second point from the line but whenever I pass coordinates of the other end of the line (either point2_wcs or point2_ucs), X axis is not aligned to the line.
Is there a way to pass a point based on X,Y,Z coordinates to UCS command.
Thank you for your help.
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
Change
(setq point2_ucs (trans point1_wcs 0 1)) ; same end of the line in UCS
to
(setq point2_ucs (trans point2_wcs 0 1)) ; same end of the line in UCS
and
(command "ucs" point1_ucs pause pause)
to
(command "ucs" "_3p" point1_ucs point2_ucs pause)
Henrique
Here is some commented code to help you:
(defun c:ucsl ( / ent enx ) (if ;; If the following expressions return a non-nil value (and ;; If ALL of the following expressions return a non-nil value (setq ent (car (entsel "\nSelect Line: "))) ;; Prompt the user to select a line (= "LINE" (cdr (assoc 0 (setq enx (entget ent))))) ;; Is it a line? ) ;; end AND (command ;; Evaluate the following expressions at the command-line "_.ucs" ;; Invoke the UCS command "_non" ;; Ignore Object Snap for the following point (trans (cdr (assoc 10 enx)) 0 1) ;; Pass the start point of the line (in UCS) "_non" ;; Ignore Object Snap for the following point (trans (cdr (assoc 11 enx)) 0 1) ;; Pass the end point of the line (in UCS) "\\" ;; Pause for user input ) ;; end COMMAND ) ;; end IF (princ) ;; Suppress the return of the last evaluated expression ) ;; end DEFUN