Lisp to set ucs and view

Lisp to set ucs and view

idigg-be
Enthusiast Enthusiast
1,327 Views
6 Replies
Message 1 of 7

Lisp to set ucs and view

idigg-be
Enthusiast
Enthusiast

so im trying to do it in action recorder, but i have failed.  wondering if lisp could do it instead....

 

basically the workflow im trying to consolidate is: ucsfollow to 1, setting the ucs to an object(which rotates the view), saving the ucs as "plan", and then turning ucsfollow off, and saving the view as "plan"(with no layer snapshot)

 

it seems pretty straightforward, but with action recorder i run into a problem when i try to save the ucs and/or view as plan if it already exists.  aka these are the commands i record:

 

ucsfollow

1

ucs

enter

ob

enter

(pauses for user input)

ucs

enter

save

enter

name of ucs(its the same all the time)

enter*****

-view

enter

save

enter

name of view(same all the time)

enter*****

 

*****- these are the points at which i run into issues, because if it exists, i have to record a Y and a enter to overwrite, but if i include a Y and and enter to overwrite and the named ucs/view doesnt exist in the drawing, i get an error.

 

Thanks all.  if this is possible via action recorder, im open to that solution as well.

0 Likes
1,328 Views
6 Replies
Replies (6)
Message 2 of 7

Moshe-A
Mentor
Mentor

@idigg-be ,

 

here's this macro in lisp command called actMacro, copy and paste the following into a notepad document save it as actmacro.lsp than load it into (or drag it in) autocad drawing, invoke ACTMACRO.

 

enjoy

Moshe

 

 

(defun c:actMacro ()
 (command "._undo" "_begin")
  
 (setvar "expert" 5) 
 (setvar "ucsfollow" 1)
 (command "._ucs" "_Object" pause)
 (command "._ucs" "_save" "plan")
 (setvar "ucsfollow" 0)
 (command "._view" "_save" "plan")
 (setvar "expert" 0)

 (command "._undo" "_end")
 (princ)
); actMacro

 

 

Message 3 of 7

Kent1Cooper
Consultant
Consultant

@idigg-be wrote:

.... i run into a problem when i try to save the ucs and/or view as plan if it already exists.  .... because if it exists, i have to record a Y and a enter to overwrite, but if i include a Y and and enter to overwrite and the named ucs/view doesnt exist in the drawing, i get an error. ....


If, when it exists, you intend to overwrite it anyway, then I suggest you simply Delete it at the beginning.

UCS / NAmed option / Delete option / give it the name.

If it exists, it will report that it Deleted one.  If it doesn't, it will simply report that it didn't find one with that name.  No error will result either way.  Then when you get to Saving a UCS under that name, it will never be there to cause it to ask whether to overwrite it.

Kent Cooper, AIA
Message 4 of 7

Sea-Haven
Mentor
Mentor

Do you need to save a view ? UCS R viewname plan.

0 Likes
Message 5 of 7

idigg-be
Enthusiast
Enthusiast

ohh, awesome, so expert mode, if im reading it correctly, essentially turns off the confirmations and if things exists, it overwrites them?  thats what i was missing.  thanks!!!!

0 Likes
Message 6 of 7

Kent1Cooper
Consultant
Consultant

@idigg-be wrote:

.... so expert mode, if im reading it correctly, essentially turns off the confirmations and if things exists, it overwrites them?  ....


Be careful.  It's not just "expert mode" as a monolithic thing, but has multiple possible settings, affecting varying degrees of what it turns off and/or overwrites.  Read about it in Help to be sure you're using a setting that gets you what you want.

Kent Cooper, AIA
0 Likes
Message 7 of 7

idigg-be
Enthusiast
Enthusiast

thanks.  i dont plan on using it, just looking to see what technique was used to get around the overwrite prompt.

 

 

one more question since im rusty with lsp's... if i wanted to invoke it using a different input... say "PV" (for plan view), what would i change?  the name of the .lsp file, or the actmacro behind defun, or the actmacro at the end?

0 Likes