Jump to content

Recommended Posts

Posted

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

Posted

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)
)

Posted

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)

Posted

Perfection, Lee... absolute perfection. Adding this one to my already robust Lee Mac arsenal of customization's. Thanks again!!

 

8)

Posted
Perfection, Lee... absolute perfection. Adding this one to my already robust Lee Mac arsenal of customization's. Thanks again!!

 

Excellent - thanks Tannar!

Posted

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.

 

:)

Posted

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.

Posted
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! :)

Posted

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.

Posted
@Lee, your response makes sense regarding the addition to your downloads section.

 

;) ..........

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...