Jump to content

Match Properties in reverse pick order


Recommended Posts

Posted

Normally when applying the matchprop command in CAD, one has to first pick the template element, and then select the elements which should have this template element's properties copied to/matched.

 

is it possible (via lisp perhaps?) to reverse this order, so that i can select a bunch of elements (e.g. through the quickselect icon) and THEN apply a matchpropertieslisp command, then select a single template element which the initially selected elements should mimic?

Posted

In principle, yes it would be possible to create and populate a selection set in LISP, then pick your template object and then assign that object's properties to each object in the selection set.

 

Personally I've never seen such a routine, but there are many more qualified people than me here in the forum to answer that question.

Posted

Thanks Tyke

 

big up to germany! I've been livign/working in Munich since January!

Posted

if you know the properties you want to match rather than match an object you can select your elements and then use the properties palette.

Posted (edited)

got the nugget i was after from Lee Mac on another forum. Works perfectly:

 

 

(defun c:mp ( / ss )
   (if (setq ss (ssget "_:L"))
       (command "_.matchprop" pause ss "")
   )
   (princ)
)

Edited by SLW210
placed code in tags.
Posted
got the nugget i was after from Lee Mac on another forum. Works perfectly:

 

 

(defun c:mp ( / ss )
   (if (setq ss (ssget "_:L"))
       (command "_.matchprop" pause ss "")
   )
   (princ)

)

 

Careful what you say now Barry, Lee Mac is VERY active in this forum too and you will no doubt get a response from him here, right Lee ;)

 

Are you using a German or Engish version of AutoCAD?

 

See you at the Oktoberfest :beer:

 

PS don't forget to wrap any code in code tags, before one of the Mods gets you.

  • 13 years later...
Posted

To expand on @barry2104's answers here's one that I wrote.

 

(vl-load-com)

;|

Match objects in reverse order to the normal MATCHPROP or MA command.

Written by 3dwannab 2024.12.28

ABOUT:
 - This uses the normal MA command, there redefining it.
 - With this you can have the destination objects selected first and then you pick the object you want to get the properties from.
 - If you don't have anything selected, the program will run the MATCHPROP command as normal.

BUGS:
 - None

|;

(command "_.undefine" "MA") ;; Undefine the shortcut MA for MATCHPROP so this program can use it.

(defun c:MA (/ *error* acDoc en ss) 

  (defun *error* (errmsg) 
    (and acDoc (vla-EndUndoMark acDoc))
    (and errmsg 
         (not (wcmatch (strcase errmsg) "*CANCEL*,*EXIT*"))
         (princ (strcat "\n<< Error: " errmsg " >>\n"))
    )
  )

  ;; Start the undo mark
  (setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
  (or (vla-EndUndoMark acDoc) (vla-StartUndoMark acDoc))

  ;; Get a preselection if one exists
  ;; There's a bug when only using the "_I" Implied selection when the selection set only contains one object.
  ;; So set the selection to the ss variable with "_:L" which only allows for the selection of unlocked layers.
  (if (ssget "_I") 
    (setq ss (ssget "_:L"))
  )

  ;; Check for a selection set if one has been selected.
  (if ss 
    (progn 
      (progn (setvar 'errno 0) 
             (while 
               (not 
                 (or 
                   (= 52 (getvar 'errno))
                   (setq en (car (entsel "\nSelect source object: ")))
                 )
               )
               (princ "\nNothing Selected.")
             )
             en
      )

      ;; If a selection set exists, perform inverted match properties
      (progn 
        (princ "\nUsing inverted MATCHPROP command...")
        (command "_.matchprop" "_non" en "_non" ss "")
      )
    )
    ;; Otherwise, use the default MATCHPROP command
    (progn 
      (princ "\nNo selection detected. Using default MATCHPROP command...")
      (command "matchprop")
    )
  )

  (vla-EndUndoMark acDoc)
  (*error* nil)
  (princ)
)

(princ "\nMatchPropsMod.lsp loaded...")

; (c:MA) ;; Unblock for testing

 

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