barry2104 Posted August 17, 2011 Posted August 17, 2011 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? Quote
Tyke Posted August 17, 2011 Posted August 17, 2011 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. Quote
barry2104 Posted August 17, 2011 Author Posted August 17, 2011 Thanks Tyke big up to germany! I've been livign/working in Munich since January! Quote
dbroada Posted August 17, 2011 Posted August 17, 2011 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. Quote
barry2104 Posted August 17, 2011 Author Posted August 17, 2011 (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 August 17, 2011 by SLW210 placed code in tags. Quote
Tyke Posted August 17, 2011 Posted August 17, 2011 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 PS don't forget to wrap any code in code tags, before one of the Mods gets you. Quote
SLW210 Posted August 17, 2011 Posted August 17, 2011 barry2104, Please read the CODE POSTING GUIDELINES. I got you covered this time. Quote
3dwannab Posted December 28, 2024 Posted December 28, 2024 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 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.