Author Topic: Set UCS, run ordinate dim, restore original UCS  (Read 566 times)

0 Members and 1 Guest are viewing this topic.

jlogan02

  • Bull Frog
  • Posts: 327
Set UCS, run ordinate dim, restore original UCS
« on: February 09, 2023, 06:28:08 PM »
I stole this ucsl routine from Lee Mac, #6 off of this thread.
https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/set-ucs-by-xyz-coordinates-of-two-points-in-lisp/td-p/5090526

Code - Auto/Visual Lisp: [Select]
  1. (defun c:STA_Ordinate ( / )
  2.  (defun ucsl ( / ent enx )
  3.     (if ;; If the following expressions return a non-nil value
  4.         (and ;; If ALL of the following expressions return a non-nil value
  5.             (setq ent (car (entsel "\nSelect Line: "))) ;; Prompt the user to select a line
  6.             (= "LINE" (cdr (assoc 0 (setq enx (entget ent))))) ;; Is it a line?
  7.         ) ;; end AND
  8.         (command ;; Evaluate the following expressions at the command-line
  9.             "_.ucs" ;; Invoke the UCS command
  10.             "_non"  ;; Ignore Object Snap for the following point
  11.             (trans (cdr (assoc 10 enx)) 0 1) ;; Pass the start point of the line (in UCS)
  12.             "_non"  ;; Ignore Object Snap for the following point
  13.             (trans (cdr (assoc 11 enx)) 0 1) ;; Pass the end point of the line (in UCS)
  14.             "\\" ;; Pause for user input
  15.         ) ;; end COMMAND
  16.     ) ;; end IF
  17.    (command "_view" "S" "Ordinate_V") ;; Save ordinate UCS
  18.  )
  19.     (setvar "osmode" 1)  
  20.     (command "DIMORDINATE")
  21.  
  22.         (while (< 0 (getvar 'cmdactive)) ;; While the command is active, pause
  23.          (command "\\") ;; Pause for user input
  24.         ) ;; end WHILE |;  
  25.    
  26.    (command "-view" "R" "UCS_Origin" "") ;; Reset Origin UCS
  27.     (princ) ;; Suppress the return of the last evaluated expression
  28. ) ;; end DEFUN

Trying to get a user created UCS, Save the UCS in a view, lay down ordinate dims and then restore a Saved View for the Original UCS that is 0,0 of the bottom left corner of the drawing template. What should happen, or what I'm not making happen is a repeatable ordinate dimension so a user can lay down several ord dims at a time. Right now, every enter causes the routine to start over at the beginning to create a UCS.

How do I make it so ordinate dims can be laid down in succession and then return the View to it's original state. I'm not sure I really need to save that Ordinate_V view. But that's not getting in the way at the moment.
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

BIGAL

  • Swamp Rat
  • Posts: 1396
  • 40 + years of using Autocad
Re: Set UCS, run ordinate dim, restore original UCS
« Reply #1 on: February 09, 2023, 06:49:36 PM »
A couple of suggestions to try,

check does UCS "VIEW V" exist
UCS OB pick line
UCS S "VIEW V" can do say "view x" where x keeps increasing each time a new UCS is made.

(while (setq pt (getpoint "\pick point "))
(command "DIMORDINATE" pt pause)
) ; end while

Look at UCS R "VIEW V"
A man who never made a mistake never made anything

jlogan02

  • Bull Frog
  • Posts: 327
Re: Set UCS, run ordinate dim, restore original UCS
« Reply #2 on: February 09, 2023, 07:22:28 PM »
Spot on!!! Thanks.
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10