tzframpton Posted October 30, 2013 Posted October 30, 2013 Hello all! I'm curious.... The LAYMCUR command is something I use significantly. I actually have it set in my PGP file as the WW command for quick access. After doing some research, as far as I can tell LAYMCUR is the only command of its type, and it's only for Layers. Is there a LISP routine floating around where it automatically reads what type of object it is, and sets the object type's style to current? For instance, if you select a dimension and run the command, it'll set the style of the dimension you picked as the current Dim Style. Mleader Styles, Table Styles, Dim Styles, Text Styles, etc.... the whole nine yards. Again, just curious is all. Thanks! - Tannar Quote
jdiala Posted October 30, 2013 Posted October 30, 2013 Add all the entities that you want to be included and get the current style of that entity. (defun C:test () (setq e (car (entsel)) v (cdr (assoc 0 (entget e))) e (vlax-ename->vla-object e)) (cond ((= v "DIMENSION") (vla-put-stylename e (getvar 'dimstyle)) ) ((= v "MULTILEADER") (vla-put-stylename e (getvar 'cmleaderstyle)) ) ((or (= v "MTEXT") (= v "TEXT")) (vla-put-stylename e (getvar 'textstyle)) ) ((= v "ACAD_TABLE") (vla-put-stylename e (getvar 'ctablestyle)) ) (t (princ "Do the rest 6 yards...")) ) (princ) ) Quote
Lee Mac Posted October 30, 2013 Posted October 30, 2013 Try the following Tannar: (defun c:stymcur ( / ent lst obj sty typ ) (setq lst '( ("TEXT,MTEXT" . textstyle) ("MULTILEADER" . cmleaderstyle) ("ACAD_TABLE" . ctablestyle) ) ) (while (progn (setvar 'errno 0) (setq ent (car (entsel))) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ( (null ent) nil ) ( (not (vlax-property-available-p (setq obj (vlax-ename->vla-object ent)) 'stylename)) (princ "\nObject does not have a style.") ) ( (progn (setq typ (cdr (assoc 0 (entget ent))) sty (vla-get-stylename obj) ) (vl-some '(lambda ( x ) (if (wcmatch typ (car x)) (setvar (cdr x) sty))) lst) ) nil ) ( (wcmatch typ "*DIMENSION") ;; they have to be awkward... (command "_.-dimstyle" "_R" sty) ) ( (princ "\nThis program is not compatible with that object.")) ) ) ) (princ) ) (vl-load-com) (princ) Quote
tzframpton Posted October 30, 2013 Author Posted October 30, 2013 Perfection, Lee... absolute perfection. Adding this one to my already robust Lee Mac arsenal of customization's. Thanks again!! Quote
Lee Mac Posted October 30, 2013 Posted October 30, 2013 Perfection, Lee... absolute perfection. Adding this one to my already robust Lee Mac arsenal of customization's. Thanks again!! Excellent - thanks Tannar! Quote
tzframpton Posted October 30, 2013 Author Posted October 30, 2013 Not that I have any "say so" in your programs and website, but this nifty routine would be excellent to add to your list of programs on your site. I know many people would get value out of that one. Just thinking out loud is all. Quote
rkent Posted October 30, 2013 Posted October 30, 2013 Tannar - There is the ADDSELECTED command built-in that works in a similar fashion in that it will start the command and set the style and layer for that instance. It won't leave the layer or style set to that one selected, returning instead to where it was when the command was started. Quote
Lee Mac Posted October 30, 2013 Posted October 30, 2013 Not that I have any "say so" in your programs and website, but this nifty routine would be excellent to add to your list of programs on your site. Many thanks for the suggestion Tannar - I don't tend to publish many of the small 'throwaway' programs that I post on the various forums unless I decide to develop them further - for example, if I were to publish this program to my site, I would probably look to develop it into a general application for all object properties (Layer, Colour, Linetype etc.) not solely the style. But where this application is concerned, I think most would use the ADDSELECTED command (available from the right-click menu) - introduced in 2011 I believe. I appreciate the suggestion nonetheless! Lee EDIT: rkent beat me to it with the ADDSELECTED suggestion! Quote
tzframpton Posted October 30, 2013 Author Posted October 30, 2013 rkent and Lee - thanks for your responses. Add Selected is something I do use, but the permanent switch is what I was after and I surely have that now. @Lee, your response makes sense regarding the addition to your downloads section. Quote
Lee Mac Posted October 30, 2013 Posted October 30, 2013 @Lee, your response makes sense regarding the addition to your downloads section. .......... 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.