I am pretty much teaching myself so go easy on me. lol This routine works great... I added a tools based on the code for each of the variables. I do have one question however, for Dtext and Mtext the DXFvalue for rotation is 50, if you try to include Mleader text the DFXval for rotation is 41, how would I rewrite to allow the match to work with Mleader as well... I would have to setq an the additional DXF at the beginning and add an (if to the end to allow for this right?
You are aware of the fact that you just replied to a 12.5 years old post?
To answer your question, if setting rotation is all you wish to do, it might be best to rewrite that script to fit your needs.
To change it will require a lot of work, as it works with any DXF code. Which means you need to account for all variations, with 2 directions.
(copy the 41 rotation from the leader to text rotation at 50 -or- copy 41 width from text to leader at #?)
I think this should do it (untested):
You will have to complete the list of DXF codes that are different for it to work for all codes.
!!! NOTE/WARNING: This will copy the suplied DXF code from selected object to a target object, which means:
To copy DXF code 41 from a TEXT to MLEADER is NOT THE SAME as copying DXF code 41 from MLEADER to TEXT !!!
(defun c:tmatchdxf() (if dxfval (progn (setq xx dxfval) (setq dxfval (getint (strcat "\nDXF value?: <" (rtos xx 2 0) ">"))) (if (not dxfval) (setq dxfval xx) ) ) (setq dxfval (getint "\nDXF value?: ")) ) (setq ent (car (entsel "\nselect the text to match"))) (setq en (entget ent)) (redraw ent 3) (setq ins (cdr (assoc dxfval en))) (setq et1 (cdr (assoc 0 en))) (setq ss (ssget (list (cons 0 "TEXT,MTEXT,RTEXT,DTEXT,MLEADER")))) (redraw ent 4) (if (/= ss nil) (progn (repeat (sslength ss) (setq ent (ssname ss 0)) (setq en (entget ent)) (setq et2 (cdr (assoc 0 en))) (cond ; if we copy from (M/R/D/)TEXT to (M/R/D/)TEXT -or- MLEADER to MLEADER ; we can just copy to the same DXF code ((or (and (or (= et1 "TEXT")(= et1 "MTEXT")(= et1 "RTEXT")(= et1 "DTEXT")) (or (= et2 "TEXT")(= et2 "MTEXT")(= et2 "RTEXT")(= et2 "DTEXT")) ) (and (= et1 "MLEADER")(= et2 "MLEADER")) ) (entmod (subst (cons dxfval ins) (assoc dxfval en) en)) ) ; if we copy from TEXT to MLEADER, or vice versa, we need to swap numbers ((or (and (or (= et1 "TEXT")(= et1 "MTEXT")(= et1 "RTEXT")(= et1 "DTEXT")) (= et2 "MLEADER") ) (and (or (= et2 "TEXT")(= et2 "MTEXT")(= et2 "RTEXT")(= et2 "DTEXT")) (= et1 "MLEADER") ) (setq dxftar dxfval) (cond ; swap the target DXF codes which are different between TEXT and MLEADER ; ((= dxfval 40)(setq dxftar #?)) ((= dxfval 41)(setq dxftar 50)) ; ((= dxfval 42)(setq dxftar #?)) ; ((= dxfval 43)(setq dxftar #?)) ((= dxfval 50)(setq dxftar 41)) ) (entmod (subst (cons dxfval ins) (assoc dxftar en) en)) ) ) (ssdel ent ss) ) ) ) )
@jshore wrote:
.... I do have one question however, for Dtext and Mtext the DXFvalue for rotation is 50, if you try to include Mleader text the DFXval for rotation is 41, how would I rewrite to allow the match to work with Mleader as well....
[Nothing wrong with reviving an old thread if it's still relevant for you!] Rotation is actually 42 for MLeaders, so fix that in other suggestions, but in any case....
For a rotation-only version, this works for me. I had trouble getting (subst)/(entmod) to work assigning a rotation to MLeaders, for some reason I haven't figured out, so I used VLA methods for the assignment part. [The extraction part could be done that way, too, but that was working in the original form so I left it.] But it at least gives you a way of dealing with the difference, which you may be able to apply into a larger any-property matching routine. It sets a 'ml' variable for whether the object in question is a MultiLeader or not, and uses a different (assoc) number to extract the rotation from the source one depending on that variable, and a different VLA Property to assign that to in the target object(s) depending on that variable:
(defun C:MTR (/ tsel tdata ss ml rot tobj); = Match Text Rotation (if (and (setq tsel (entsel "\nTextual object source for Rotation: ")) (wcmatch (cdr (assoc 0 (setq tdata (entget (car tsel))))) "*TEXT,MULTILEADER") (setq ss (ssget '((0 . "*TEXT,MULTILEADER")))) ); and (progn (setq ml (member '(0 . "MULTILEADER") tdata) rot (cdr (assoc (if ml 42 50) tdata)) ); setq (repeat (setq n (sslength ss)) (setq tobj (vlax-ename->vla-object (ssname ss (setq n (1- n)))) ml (= (vla-get-ObjectName tobj) "AcDbMLeader") ); setq (vlax-put tobj (if ml 'TextRotation 'Rotation) rot) ); repeat ); progn ); if (princ) ); defun (vl-load-com)
BY THE WAY, forget/eliminate any references to DTEXT in things like (ssget) filter liists and options in other code. There is no such entity type. It's just TEXT.
Be careful. The text rotation property of mtext is different from that of text. The text rotation is relative to the WCS, but the mtext rotation is relative to the current UCS. I used to write routines including (command "_.UCS" "_W"), but I decided long ago to add code to figure out the difference and include it as an adjustment.
John F. Uhden