See the top rated post in this thread. Click here

Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 24

Thread: entget error on MText object, but only sometimes, why?

  1. #11
    Member
    Join Date
    2015-12
    Posts
    28
    Login to Give a bone
    0

    Default Re: entget error on MText object, but only sometimes, why?

    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

  2. #12
    Member
    Join Date
    2015-12
    Posts
    28
    Login to Give a bone
    0

    Default Re: entget error on MText object, but only sometimes, why?

    This is what I have come up with, it works, sort of.

    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)
    )
    Thank you for looking,
    Hunter
    Last edited by BlackBox; 2014-09-12 at 04:35 PM. Reason: Please use [CODE] Tags

  3. #13
    Active Member
    Join Date
    2009-03
    Posts
    63
    Login to Give a bone
    0

    Default Re: entget error on MText object, but only sometimes, why?

    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.

  4. #14
    Member
    Join Date
    2015-12
    Posts
    28
    Login to Give a bone
    0

    Default Re: entget error on MText object, but only sometimes, why?

    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



    Quote Originally Posted by ccalder View Post
    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.
    Last edited by ledgehead; 2014-09-16 at 04:24 PM.

  5. #15
    Active Member
    Join Date
    2009-03
    Posts
    63
    Login to Give a bone
    1

    Default Re: entget error on MText object, but only sometimes, why?

    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)
    )

  6. #16
    Member
    Join Date
    2015-12
    Posts
    28
    Login to Give a bone
    0

    Default Re: entget error on MText object, but only sometimes, why?

    ccalder,

    Thank you for your efforts, they are appreciated.

    Hunter

  7. #17
    Member
    Join Date
    2015-12
    Posts
    28
    Login to Give a bone
    0

    Default Re: entget error on MText object, but only sometimes, why?

    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

  8. #18
    Active Member
    Join Date
    2009-03
    Posts
    63
    Login to Give a bone
    2

    Default Re: entget error on MText object, but only sometimes, why?

    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.

    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)
    )
    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.

  9. #19
    Member
    Join Date
    2015-12
    Posts
    28
    Login to Give a bone
    0

    Default Re: entget error on MText object, but only sometimes, why?

    ccalder,

    You got it and it works perfectly!

    Thank you for your efforts, they are appreciated.

    Hunter

  10. #20
    Member
    Join Date
    2015-12
    Posts
    28
    Login to Give a bone
    0

    Default Re: entget error on MText object, but only sometimes, why?

    This routine stopped working in autocad 2016, could I get some assistance fixing it please (block to text copying stopped)?

    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)
    )
    Thank you,
    Hunter
    Last edited by Opie; 2015-03-26 at 12:37 PM. Reason: [code] tags added

Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. Lisp to add an MText object that contains an object property
    By sheila.bjerreskov717262 in forum AutoLISP
    Replies: 7
    Last Post: 2013-07-22, 05:58 PM
  2. Select & entget object information in XREF and block-in-block with Lisp
    By Wish List System in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2012-11-14, 09:11 AM
  3. Help with entget and assoc
    By domniki in forum AutoLISP
    Replies: 3
    Last Post: 2010-02-12, 07:39 PM
  4. Merge MTEXT objects into one MTEXT object
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2007-07-24, 02:33 PM
  5. Replies: 12
    Last Post: 2007-04-12, 09:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •