Hi,
How can this be made to work with text and dimensions? It also needs to be VBA as the 'textstring' is sometimes longer than 'assoc' will allow.
Thank you,
Hunter
|
Hi,
How can this be made to work with text and dimensions? It also needs to be VBA as the 'textstring' is sometimes longer than 'assoc' will allow.
Thank you,
Hunter
This is what I have come up with, it works, sort of.
Thank you for looking,Code:(DEFUN test2 () (prompt "\nSelect text string to Change: ") (setq en2 (entget (car (entsel)))) (setq en2 (subst (assoc 1 en) (assoc 1 en2) en2)) (entmod en2) (princ) ) (DEFUN C:TEST () (vl-load-com) (PROMPT "\nSelect text string to Copy: ") (setq en (entget (car (entsel)))) (if (= (field 0 en) "DIMENSION") (TEST2) ) ;; if you select a dimension it uses test2, that part works. ;; how do you pass en from above down to the WHILE statement below? (WHILE (NOT (SETQ EN (SSGET "_+.:E:S" '((-4 . "<or") (0 . "TEXT") (0 . "MTEXT") (-4 . "or>")) ) ) ) ) (setq EN (vlax-get-property (vlax-ename->vla-object (ssname en 0)) 'textstring ) ) (prompt "\nSelect text string to Change: ") (WHILE (NOT (SETQ EN1 (SSGET "_+.:E:S" '((-4 . "<or") (0 . "TEXT") (0 . "MTEXT") (-4 . "or>")) ) ) ) ) (vlax-put-property (vlax-ename->vla-object (ssname en1 0)) 'textstring en ) (princ) )
Hunter
Last edited by BlackBox; 2014-09-12 at 04:35 PM. Reason: Please use [CODE] Tags
ledgehead, are you trying to get the info from a dimension and copy to some text/mtext? or are you trying to copy some text and override it into the dimension? or both? it will be a different process depending on which way you want to go. Also a completly different beast then text/mtext objects, while dimensions do have a text aspect to them, the program does not treat dimension and text objects the same, so the routine will need to identify the selected objects and run differing code depending on if your going text->text text->dimension dimension->text or dimension->dimension.
ccalder,
It all started with the first post.
The routine in the first post will copy text to a dimension and text to text, it however will copy a dimension to text but if the "dimension text" is <> the text is made null.
The problem I was running into with the first routine is that entget will not get text or mtext if it exceeds a certain length, 250 characters ish. But the new vba routine will. I liked the ability of the first routine to copy text between dimensions and was trying to put that back in. If there is some way to combine the old and new routine that would work better than what I have, I'm all for it!
So, to answer your question text to text and dimension to dimension primarily, sometimes text to dimension (edited this sentence).
Thank you for looking,
Hunter
Last edited by ledgehead; 2014-09-16 at 04:24 PM.
Try this. It should also work going from dimension to text when the dimension has not been overridden, at least it did in my tests. if the dimension override has <> in it, it will copy the <> not the length, if the override is blank is should grab the measurement and any prefix/suffixes. I'm trying not to go to far overboard here. If you are working with custom overridden dimensions that you want to copy into text mtext frequently that can be added in but will require further tweaking of the code.
Code:(DEFUN C:CCAT (/ EN EN1 ) (vl-load-com) (PROMPT "\nSelect text string to Copy: ") (WHILE (NOT (SETQ EN (SSGET "_+.:E:S" '((0 . "TEXT,MTEXT,DIMENSION")) ) ))) (IF (= (CDR (ASSOC 0 (ENTGET (SSNAME EN 0)))) "DIMENSION") (PROGN (IF (= (VLAX-GET-PROPERTY (vlax-ename->vla-object (ssname en 0)) 'TextOverride) "") (PROGN (SETQ EN (vlax-ename->vla-object (ssname en 0))) (SETQ EN (STRCAT (VLAX-GET-PROPERTY EN 'TextPrefix) (RTOS (VLAX-GET-PROPERTY EN 'Measurement) (VLAX-GET-PROPERTY EN 'UnitsFormat) (VLAX-GET-PROPERTY EN 'PrimaryUnitsPrecision)) (VLAX-GET-PROPERTY EN 'TextSuffix) )) );PROGN );IF );PROGN (setq EN (vlax-get-property (vlax-ename->vla-object (ssname en 0)) 'textstring)) );IF (prompt "\nSelect text string to Change: ") (WHILE (NOT (SETQ EN1 (SSGET "_+.:E:S" '((0 . "TEXT,MTEXT,DIMENSION")) ) ))) (IF (= (CDR (ASSOC 0 (ENTGET (SSNAME EN1 0)))) "DIMENSION") (vlax-put-property (vlax-ename->vla-object (ssname en1 0)) 'TextOverride en) (vlax-put-property (vlax-ename->vla-object (ssname en1 0)) 'textstring en) );IF (PRINC) )
ccalder,
Thank you for your efforts, they are appreciated.
Hunter
ccalder,
As far as copying dimension text to mtext, I rarely do that if ever. The only problem with the original routine is that it will not copy long mtext strings. I do however need the routine to copy edited dimensions from one to another as in "<>/X CLEAR" (or similar formatted overridden dimension text).
Can your routine be modified to use my original routine with regards to dimensions? =IF dimension use original routine, =IF mtext or text use your routine?
Thank you for your help,
Hunter
yup, you kinda answered your own question at the end there, just reorganize to select both objects before running the rest and drop in an if function after the objects are selected, if both are dimensions run your code, else run mine.
this way if both objects are dimensions it uses the original entmod method, else uses vlax-put-property method. Had to tweak yours slightly to addapt to use ssget instead of entsel.Code:(DEFUN C:CCAT (/ EN EN1 ) (vl-load-com) (PROMPT "\nSelect text string to Copy: ") (WHILE (NOT (SETQ EN (SSGET "_+.:E:S" '((0 . "TEXT,MTEXT,DIMENSION")) ) ))) (PROMPT "\nSelect text string to Change: ") (WHILE (NOT (SETQ EN1 (SSGET "_+.:E:S" '((0 . "TEXT,MTEXT,DIMENSION")) ) ))) (IF (AND (= (CDR (ASSOC 0 (ENTGET (SSNAME EN 0)))) "DIMENSION") (= (CDR (ASSOC 0 (ENTGET (SSNAME EN1 0)))) "DIMENSION")) (PROGN (setq en (entget (SSNAME EN 0))) (setq en1 (entget (SSNAME EN1 0))) (setq en1 (subst (assoc 1 en) (assoc 1 en1) en1)) (entmod en1) );PROGN (PROGN (IF (= (CDR (ASSOC 0 (ENTGET (SSNAME EN 0)))) "DIMENSION") (PROGN (IF (= (VLAX-GET-PROPERTY (vlax-ename->vla-object (ssname en 0)) 'TextOverride) "") (PROGN (SETQ EN (vlax-ename->vla-object (ssname en 0))) (SETQ EN (STRCAT (VLAX-GET-PROPERTY EN 'TextPrefix) (RTOS (VLAX-GET-PROPERTY EN 'Measurement) (VLAX-GET-PROPERTY EN 'UnitsFormat) (VLAX-GET-PROPERTY EN 'PrimaryUnitsPrecision)) (VLAX-GET-PROPERTY EN 'TextSuffix) )) );PROGN );IF );PROGN (setq EN (vlax-get-property (vlax-ename->vla-object (ssname en 0)) 'textstring)) );IF (IF (= (CDR (ASSOC 0 (ENTGET (SSNAME EN1 0)))) "DIMENSION") (vlax-put-property (vlax-ename->vla-object (ssname en1 0)) 'TextOverride en) (vlax-put-property (vlax-ename->vla-object (ssname en1 0)) 'textstring en) );IF );PROGN );IF (PRINC) )
ccalder,
You got it and it works perfectly!
Thank you for your efforts, they are appreciated.
Hunter
This routine stopped working in autocad 2016, could I get some assistance fixing it please (block to text copying stopped)?
Thank you,Code:(DEFUN C:ccat (/ EN EN1 ) (vl-load-com) (PROMPT "\nSelect text string to Copy: ") (WHILE (NOT (SETQ EN (SSGET "_+.:E:S" '((0 . "TEXT,MTEXT,DIMENSION")) ) ))) (PROMPT "\nSelect text string to Change: ") (WHILE (NOT (SETQ EN1 (SSGET "_+.:E:S" '((0 . "TEXT,MTEXT,DIMENSION")) ) ))) (IF (AND (= (CDR (ASSOC 0 (ENTGET (SSNAME EN 0)))) "DIMENSION") (= (CDR (ASSOC 0 (ENTGET (SSNAME EN1 0)))) "DIMENSION")) (PROGN (setq en (entget (SSNAME EN 0))) (setq en1 (entget (SSNAME EN1 0))) (setq en1 (subst (assoc 1 en) (assoc 1 en1) en1)) (entmod en1) );PROGN (PROGN (IF (= (CDR (ASSOC 0 (ENTGET (SSNAME EN 0)))) "DIMENSION") (PROGN (IF (= (VLAX-GET-PROPERTY (vlax-ename->vla-object (ssname en 0)) 'TextOverride) "") (PROGN (SETQ EN (vlax-ename->vla-object (ssname en 0))) (SETQ EN (STRCAT (VLAX-GET-PROPERTY EN 'TextPrefix) (RTOS (VLAX-GET-PROPERTY EN 'Measurement) (VLAX-GET-PROPERTY EN 'UnitsFormat) (VLAX-GET-PROPERTY EN 'PrimaryUnitsPrecision)) (VLAX-GET-PROPERTY EN 'TextSuffix) )) );PROGN );IF );PROGN (setq EN (vlax-get-property (vlax-ename->vla-object (ssname en 0)) 'textstring)) );IF (IF (= (CDR (ASSOC 0 (ENTGET (SSNAME EN1 0)))) "DIMENSION") (vlax-put-property (vlax-ename->vla-object (ssname en1 0)) 'TextOverride en) (vlax-put-property (vlax-ename->vla-object (ssname en1 0)) 'textstring en) );IF );PROGN );IF (PRINC) )
Hunter
Last edited by Opie; 2015-03-26 at 12:37 PM. Reason: [code] tags added