Jump to content

Recommended Posts

Posted

I need to select all existaing MLeader on a specific MLeader Style and change them to an other MLeader style.

 

I already create a similar code to dimension that work good for exemple.

________________________________________________________________

(setq dimstyle_old (ssget "_X" '((0 . "*DIMENSION") (2 . "dimstyle_old") )))

(COMMAND "OPTCHPROP" dimstyle_old "" "D" "dimstyle_new" "")

________________________________________________________________

The problem is: I am not able to find a dxf group code that work for MLeaders...

 

Thank you

 

Patrick

Posted

Hello Patrick,

 

Firstly, welcome to CADTUTor.

 

Secondly, unfortunately there is no way to use the Mleader Style in ssget filter so you need to iterate through a selection set and gather the Mleader objects that match your desired Mleader Style then implement your task on the objects after all.

Posted

You will not be able to select Mleader objects since you added the object DIMENSION and the object name for Mleader objects is MULTILEADER.

 

Anyway have a look at the following routine and change the Mleader Style Name "Standard" to your old Style name and replace Mleader Style name "MyStyle" with your new one.

 

Here I am posting the codes because it is late here and I need to go to bed. :)

 

(defun c:test  (/ sel int obj)
 (if (setq sel (ssget "_:L" '((0 . "MULTILEADER"))))
   (repeat (setq int (sslength sel))
     (setq obj (vlax-ename->vla-object (ssname sel (setq int (1- int)))))
     (if (eq (vla-get-stylename obj) "Standard")
       (vla-put-stylename obj "MyStyle")
       )
     )
   )
 (princ)
 )(vl-load-com)

 

Happy coding.

Posted

A quick what is, typed this direct on command line (entget (car (entsel))) pick a mleader or for vl use dumpit.lsp both methods open up the answers very quickly about an object. Its not perfect but works for most straight forward Autocad objects.

Posted

If LISP is not necessarily required, you can accomplish this via out of the box via QSELECT and changing the style within the Properties Palette.

  • 10 months later...
Posted (edited)

firefox crash messed up post.

Edited by 3dwannab
Posted

(getvar 'SELECTSIMILARMODE)

64 is the value used for object style only.

 

So this could be written into a lisp like below.

Trouble is:

 

- The selectsimilarmode won't stick when the command is run

 

 

; All Objects by Filters
; Written 03/04/2017 by 3dwannab
; Some code from: http://www.cadforum.cz/cadforum_en/qaID.asp?tip=6365

(defun c:QS_OBJECT_ALL_BY_FILTERS ( /
   *error*
   ans
   cmde
   os
   smode
   ss
   )

(defun *error* (errmsg)
   (and acDoc (vla-EndUndoMark acDoc))
   (and errmsg

       (not (wcmatch (strcase errmsg) "*CANCEL*,*EXIT*"))
       (princ (strcat "\n<< Error: " errmsg " >>"))
       )
   (setvar 'cmdecho cmde)
   (setvar 'osmode os)
   (setvar 'selectsimilarmode smode)
   )

(setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
(or (vla-EndUndoMark acDoc) (vla-StartUndoMark acDoc))

(setq cmde (getvar 'cmdecho))
(setq os (getvar 'osmode))
(setq smode (getvar 'selectsimilarmode))
(setvar 'cmdecho 0)
(setvar 'osmode 0)

(initget "Colour Layer lineType linetypeScale lineWeight Plotstyle Objectstyle Name")
(setq ans (getkword "\nChoose Filter Type : [Colour/Layer/lineType/linetypeScale/lineWeight/Plotstyle/Objectstyle/Name] <Layer>: "))
(if (not ans) (setq ans "Layer"))

(sssetfirst nil)

(cond

   ((=  "Colour" ans)
       (setvar 'selectsimilarmode 1)
       (princ "****")
       )
   ((=  "Layer" ans)
       (setvar 'selectsimilarmode 2)
       )
   ((=  "lineType" ans)
       (setvar 'selectsimilarmode 4)
       )
   ((=  "linetypeScale" ans)
       (setvar 'selectsimilarmode 
       )
   ((=  "lineWeight" ans)
       (setvar 'selectsimilarmode 16)
       )
   ((=  "Plotstyle" ans)
       (setvar 'selectsimilarmode 32)
       )
   ((=  "Objectstyle" ans)
       (setvar 'selectsimilarmode 64)
       )
   ((=  "Name" ans)
       (setvar 'selectsimilarmode 128)
       )

   )

(if ans
   (progn
       (vl-cmdf "._selectsimilar" pause)

       )
   (prompt "\nNothing selected ")
   )

(*error* nil)

(vl-load-com)

(princ)

)

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