iconeo Posted November 30, 2015 Posted November 30, 2015 I am having problems with some MTEXT and DXF code 11. X-axis direction vector (in WCS)DXF: X value; APP: 3D vector NOTE A group code 50 (rotation angle in radians) passed as DXF input is converted to the equivalent direction vector (if both a code 50 and codes 11, 21, 31 are passed, the last one wins). This is provided as a convenience for conversions from text objects. How can I set: (11 1.0 6.66134e-016 0.0) to (11 1.0 0.0 0.0) I have this so far (again thanks to Lee Mac) but it doesn't seem to change it DXF code 11: (defun c:textfix (/ entity dxfdata old-dxf new-dxf dxfdata) (setq entity (car (entsel)) dxfdata (entget entity) old-dxf (assoc 11 dxfdata) new-dxf '(11 1.0 0.0 0.0) dxfdata (subst new-dxf old-dxf dxfdata) ) (entmod dxfdata) ) Any help is appreciated! Thanks. Quote
Happy Hobbit Posted November 30, 2015 Posted November 30, 2015 It may just be easier to use the torient command & type 0 at the prompt Assuming you have express tools loaded that is Quote
Jef! Posted November 30, 2015 Posted November 30, 2015 (edited) Hi Iconeo. if both a code 50 and codes 11, 21, 31 are passed, the last one wins, which in your case is the code 50. ((-1 . <Entity name: 7ffffb060b0>) (0 . "MTEXT") (330 . <Entity name: 7ffffb03f00>) (5 . "83") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbMText") (10 285.945 142.425 0.0) (40 . 2.5) (41 . 107.117) (46 . 0.0) (71 . 1) (72 . 5) (1 . "FDSDF") (7 . "Standard") (210 0.0 0.0 1.0) (11 -1.0 1.22465e-016 0.0) (42 . 11.6667) (43 . 2.5)[b] (50 . 3.14159) [/b](73 . 1) (44 . 1.0)) (defun c:textfix2 ( / entity dxfdata old-dxf new-dxf dxfdata ) (setq entity (car (entsel)) dxfdata (entget entity) old-dxf (assoc 50 dxfdata) new-dxf '(50 . 0.0) dxfdata (subst new-dxf old-dxf dxfdata) ) (entmod dxfdata) ) Command: (entget(car(entsel))) ;original upside down textSelect object: ((-1 . ) (0 . "MTEXT") (330 . ) (5 . "83") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbMText") (10 287.161 143.894 0.0) (40 . 2.5) (41 . 107.117) (46 . 0.0) (71 . 1) (72 . 5) (1 . "FDSDF") (7 . "Standard") (210 0.0 0.0 1.0) (11 -1.0 1.22465e-016 0.0) (42 . 11.6667) (43 . 2.5) (50 . 3.14159) (73 . 1) (44 . 1.0)) Command: TEXTFIX2 ;returned by entmod Select object: ((-1 . ) (0 . "MTEXT") (330 . ) (5 . "83") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbMText") (10 287.161 143.894 0.0) (40 . 2.5) (41 . 107.117) (46 . 0.0) (71 . 1) (72 . 5) (1 . "FDSDF") (7 . "Standard") (210 0.0 0.0 1.0) (11 -1.0 1.22465e-016 0.0) (42 . 11.6667) (43 . 2.5) (50 . 0.0) (73 . 1) (44 . 1.0)) Command: Command: (entget(car(entsel))) ;checking again the text Select object: ((-1 . ) (0 . "MTEXT") (330 . ) (5 . "83") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbMText") (10 287.161 143.894 0.0) (40 . 2.5) (41 . 107.117) (46 . 0.0) (71 . 1) (72 . 5) (1 . "FDSDF") (7 . "Standard") (210 0.0 0.0 1.0) (11 1.0 0.0 0.0) (42 . 11.6667) (43 . 2.5) (50 . 0.0) (73 . 1) (44 . 1.0)) As you can see, CAD takes care of fixing the 11 dxf according to the 50 dxf, but this time, at our advantage, instead of the other way around if you modify the dxf 11, CAD modify it back to match with the 50 dxf code... Cheers! Jef! Edited November 30, 2015 by Jef! Quote
iconeo Posted November 30, 2015 Author Posted November 30, 2015 So I tried this and it fixed code 50 but not 11. (defun c:textfix (/ entity dxfdata old-dxf new-dxf dxfdata) (setq entity (car (entsel)) dxfdata (entget entity) dxfdata2 dxfdata old-dxf (assoc 11 dxfdata) new-dxf '(11 1.0 0.0 0.0) dxfdata (subst new-dxf old-dxf dxfdata) old-dxf2 (assoc 50 dxfdata) new-dxf2 '(50 . 0.0) dxfdata2 (subst new-dxf2 old-dxf2 dxfdata2) ) (entmod dxfdata) (entmod dxfdata2) ) If I match it up to text that essentially has all of the same DXF codes except 11 is different I'm still seeing the error. It seems the only way to dispel it is to have the DXF code 11 set to (11 1.0 0.0 0.0). So how come I can't change it? Thanks. Quote
Jef! Posted November 30, 2015 Posted November 30, 2015 your second entmod does the job but your fisrt one is totally useless don't bother with the 11.. look at my previous post i added further explanations Quote
iconeo Posted November 30, 2015 Author Posted November 30, 2015 (edited) First off, thanks Jef! It turns out these drawing were getting funny text results because they had been rotated on their z-axis somehow. By funny I mean that when xref'd into another drawing you would get bold text. The code below fixed them right up. (defun c:textfix (/ entity dxfdata old-dxf new-dxf dxfdata) (command "ucs" "world") (setq entity (car (entsel)) dxfdata (entget entity) old-dxf (assoc 50 dxfdata) new-dxf '(50 . 0.0) dxfdata (subst new-dxf old-dxf dxfdata) ) (entmod dxfdata) ) Edited November 30, 2015 by iconeo Quote
Jef! Posted November 30, 2015 Posted November 30, 2015 I'm glad I could help. Few things.. 1: every thing you rotate using the rotate command is rotated around its z axis. The code I helped you create set it back to 0 "on their z axis". 2: the ucs world you added is not necessary. The values in mtext dxf code are all in relation the the world ucs. You can verify that using entget, than doing it again after changing the ucs. The dxf code remain the same. 3: A thing that could make you get unexpected results is the mtext dxf code 210, which correspond to the "extrusion direction" (the normal vector). If the text is not normal (on x/y plane, facing up), you will need to set it back to (210 0.0 0.0 1.0) You could force it, or even better, use a if statement to correct it only if required. Another thing, you could include some code to verify that the user did correctly selected a mtext, because if he misclicks, the entsel will return nil, and trying to (entget (car nil)) will trigger a bad argument type: lentityp nil error. You could do that in the following way: (while (eq nil entitydxf) (if (setq selectedentity (entsel)) (setq entitydxf (entget(car selectedentity))) (princ "\n Selection missed. Please try again")) ) That way you dont entget anything as long as selectedentity is bound to nil (so as long as you dont correctly select an object), and the while statement will run as long as the entity dxf is not retrieved. Note that I could have used a single variable, but used 2 to ease up the comprehension. Don't forget to localise the variables, as your while won't work as intended on the 2nd run. That being said, you still could test further, and force the user to select again if the selection is not a mtext... but i'll leave you some fun. I hope it helped further Cheers. ...next step, ssget all mtexts in the current space, and apply the entmod to the selection set. Quote
iconeo Posted November 30, 2015 Author Posted November 30, 2015 Yea, I just needed something quick and dirty else I would have added a bunch of error checking, etc. And I actually had to set the UCS to world in my case as I was dealing with an AutoCAD display bug with TTF fonts. If the DXF code 11 is not set correctly, DXF 50 doesn't matter as long as 11 is right, AutoCAD would display some of the text in a manner that looks bold when plotted and on screen even though it wasn't. This problem arises for a number of reasons such as incorrect Z value, xref scaling isn't uniform, rotated text, etc... Similar in vein to this problem... Quote
Jef! Posted December 1, 2015 Posted December 1, 2015 I took a look at the post you linked, I never used a conjunture of model space texts along with ttf fonts. It sure can be a pita when texts are in xrefs non uniformally scaled, or not inserted at the Z coord 0. If the DXF code 11 is not set correctly, DXF 50 doesn't matter as long as 11 is rightIt is funny, as this sentence contradict itself and/or the code you said was working in your post #6, which was, as I posted in the #3, only entmoding the dxf 50.Recap: Either 11 and 50 are both correct, either 11 and 50 are both incorrect. If they are incorrect, you only need to entmod the last one, because as you do, CAD will correct the first(s) one(s) accordingly so they always say the same thing. As simple as that. Check back on my first post, what my entmod returns (me only changing dxf 50 leaving 11 unchanged) compared to what is returned by entget'ing the mtext again. Cad automatically substituted the dxf11 too to reflect the changes made on the dxf 50. I hope it is more clear like that. Maybe the order 11/50 can change (i seriously doubt tho), in the tests I made dxf 50 was the last one, and dxf reference guide says that if more than one is provided, only the last one is taken in consideration. What you could do is reverse the list, look at assocs 1 by 1 until you find either 11 or 50, modify it, then reverse again before entmod'ing. Maybe it would not be as quick and dirty as you want tho 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.