mikeSIEMENS Posted November 5, 2010 Posted November 5, 2010 On some projects we work in Solid Edge, and then translate the drawings to AutoCAD for the customer. When Solid Edge is installed on a machine it installs certain fonts, one of which is a symbols font for Geometric Tolerances. If a customer opens the autocad translation they can't see the geo tol symbols because they don't have the fonts on their machines. Some are ok with us sending them the fonts, others are not. So I'd like to write a lisp that would change the style to use the autocad gdt font, after finding and replacing the text of the solid edge font with the letters that the autocad gdt font uses. This will have to work within blocks and probably mtext. So I would need to be able to find and replace single letters that only occur on a certain text style, so all the letters in the drawing aren't replaced. Quote
Lee Mac Posted November 5, 2010 Posted November 5, 2010 You could select all Text/MText of a certain TextStyle using: (ssget "_X" '((0 . "TEXT,MTEXT") (7 . "YourTextStyleHere"))) Or perhaps all Text/MText of a certain style, and all attributed blocks: (ssget "_X" '( (-4 . "<OR") (-4 . "<AND") (0 . "TEXT,MTEXT") (7 . "YourTextStyleHere") (-4 . "AND>") (-4 . "<AND") (0 . "INSERT") (66 . 1) (-4 . "AND>") (-4 . "OR>") ) ) Quote
mikeSIEMENS Posted November 5, 2010 Author Posted November 5, 2010 Will the first one work for text within non-attributed blocks? Quote
Lee Mac Posted November 5, 2010 Posted November 5, 2010 Will the first one work for text within non-attributed blocks? No, ssget will only select primary entities, for text entities within blocks you will need to look through and modify the block definition within the block table. Quote
mikeSIEMENS Posted November 5, 2010 Author Posted November 5, 2010 Now how do I find & replace within the selection set. Quote
Lee Mac Posted November 5, 2010 Posted November 5, 2010 If you wanted to dig through block definitions, this would be how I might approach it: (defun GetBlockEntities ( block / lst ) (reverse (if (setq block (tblobjname "BLOCK" block)) (while (setq block (entnext block)) (setq lst (cons block lst)) ) ) ) ) Or recursively, (defun GetBlockEntities ( block ) (defun EntnextToEnd ( e ) (if (setq e (entnext e)) (cons e (EntnextToEnd e)) ) ) (if (setq block (tblobjname "BLOCK" block)) (EntnextToEnd block) ) ) Quote
Lee Mac Posted November 5, 2010 Posted November 5, 2010 Now how do I find & replace within the selection set. Well, first you'd have to iterate through the items in the selection set using a loop construct coupled with ssname perhaps. Then, there are many ways to perform the replacement - you could use substr to look through each character individually, or vl-string-subst within a loop to account for all occurrences, or even RegularExpressions using the RegExp object. 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.