rcb007 Posted August 18, 2021 Posted August 18, 2021 I am having trouble finding a easier method to rotate objects (Mleaders, Text, Mtext, Blocks, etc) to a Viewport which was created with a DV Twist. I have found a bunch of routines that look like they need to have the viewport and the UCS match. Usually when picking inside the viewport, our UCS is still set to world. When creating a Mleader, it usually does not match the view, unless we rotate it. Thank you for any help and ideas. Quote
ronjonp Posted August 18, 2021 Posted August 18, 2021 (edited) Try this: (defun c:r2v (/ a b o s) ;; RJP » 2021-08-18 (cond ((setq s (ssget ":L")) (and (setq b (equal '(1. 0. 0.) (getvar 'ucsxdir))) (setvar 'cmdecho 0) (command "_.UCS" "_View") ) (setq a (angle (trans '(0. 0. 0.) 1 0) (trans '(1. 0. 0.) 1 0))) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (cond ((wcmatch (vla-get-objectname (setq o (vlax-ename->vla-object e))) "AcDbMText") (vl-catch-all-apply 'vlax-put (list o 'rotation 0.)) ) ((vlax-property-available-p o 'textrotation) (vl-catch-all-apply 'vlax-put (list o 'textrotation 0.)) ) ((vlax-property-available-p o 'rotation) (vl-catch-all-apply 'vlax-put (list o 'rotation a)) ) ) ) (and b (command "_.UCS" "_World") (setvar 'cmdecho 1)) ) ) (princ) ) Edited August 19, 2021 by ronjonp 1 Quote
rcb007 Posted August 19, 2021 Author Posted August 19, 2021 Thank you Ron. Its amazing the amount of code compared to the others i have see for the UCS. This is great and will save some sanity, thanks. Quote
ronjonp Posted August 19, 2021 Posted August 19, 2021 2 hours ago, rcb007 said: Thank you Ron. Its amazing the amount of code compared to the others i have see for the UCS. This is great and will save some sanity, thanks. Glad to help .. Why don't you set the UCS to view when drafting? If you do that, the objects will be at the correct orientation when drafting them. Quote
rcb007 Posted August 19, 2021 Author Posted August 19, 2021 we have had some instances where users have sent out coordinates from inside paperspace when it was set to view. Thats kinda what drove it this way. Just a thought. Can there be a way to where if you activate the mleader command or text mtext, etc. that it flips the ucs view on, then when the command is done it goes back to the world coordinate? Just didnt know. Quote
tombu Posted August 20, 2021 Posted August 20, 2021 FYI: Adding the command Name UCS, View Toggle Description Toggle between UCS View & UCS World Macro ^C^C(if(zerop (getvar 'worlducs))(command-s "UCS" "World")(command-s "UCS" "View")) comes in handy. If you set modemacro in acaddoc.lsp the "$(if,$(getvar,worlducs),,$(if,$(getvar,viewdir),$(getvar,ucsname) ,Plan ))" line in the code below lets you know on the status bar if you're in Plan View. (setvar 'MODEMACRO (strcat "$(If,$(Eq,$(Getvar,dbmod),0),,* )" ;The asterisk indicates the drawing has been modified. ; "$(getvar,cprofile)" ;Current Profile ; ", $(getvar,wscurrent)" ;Current Workspace "$(getvar,textstyle) " ; "$(*, $(rtos, $(getvar,cannoscalevalue), 2, 2), $(getvar,textsize)) " "$(rtos, $(*, $(getvar,cannoscalevalue), $(getvar,textsize)), 2, 2) " ; " $(getvar,textsize) " ; "$(if,$(and,1,$(getvar,cmdactive)),$(getvar, cmdnames))" "$(if,$(getvar,worlducs),,$(if,$(getvar,viewdir),$(getvar,ucsname) ,Plan ))" ;Thanks Kent Cooper ; "$(if,$(getvar,worlducs),,$(if,$(getvar,ucsname),UCS ,Plan ))" "$(if,$(and,1,$(getvar,pickstyle)),,<Group off> )" "$(if,$(and,2,$(getvar,groupdisplaymode)),[Group] )" "$(if,$(and,16384,$(getvar,osmode)),,$(if,$(and,1,$(getvar,osmode)),E))" "$(if,$(and,16384,$(getvar,osmode)),,$(if,$(and,2,$(getvar,osmode)),M))" "$(if,$(and,16384,$(getvar,osmode)),,$(if,$(and,4,$(getvar,osmode)),C))" "$(if,$(and,16384,$(getvar,osmode)),,$(if,$(and,8,$(getvar,osmode)),Nod))" "$(if,$(and,16384,$(getvar,osmode)),,$(if,$(and,16,$(getvar,osmode)),Q))" "$(if,$(and,16384,$(getvar,osmode)),,$(if,$(and,32,$(getvar,osmode)),Int))" "$(if,$(and,16384,$(getvar,osmode)),,$(if,$(and,4096,$(getvar,osmode)),Ex))" "$(if,$(and,16384,$(getvar,osmode)),,$(if,$(and,64,$(getvar,osmode)),Ins))" "$(if,$(and,16384,$(getvar,osmode)),,$(if,$(and,128,$(getvar,osmode)),Per))" "$(if,$(and,16384,$(getvar,osmode)),,$(if,$(and,256,$(getvar,osmode)),T))" "$(if,$(and,16384,$(getvar,osmode)),,$(if,$(and,512,$(getvar,osmode)),Nea))" "$(if,$(and,16384,$(getvar,osmode)),,$(if,$(and,2048,$(getvar,osmode)),A))" "$(if,$(and,16384,$(getvar,osmode)),,$(if,$(and,8192,$(getvar,osmode)),Par))" "$(if, $(!=, $(getvar,viewtwist), 0), Viewtwist: $(angtos, $(getvar,viewtwist) [, 0, 2]) , )" ;Thanks alanjt "$(if, $(!=, $(strlen,$(getvar,refeditname)), 0), Xref = $(getvar,refeditname))" "$(If,$(Eq,$(Getvar,PStyleMode),0),STB,CTB )" "$(if,$(>, $(getvar,dynmode), 0),$(if,$(=,$(getvar,dynpicoords),0),@,#),#)" ;Dynamic coordinate entry. " $(getvar, cmdnames)" ) ) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.