Author Topic: Need assistance with expand ing a routines capabilities  (Read 5488 times)

0 Members and 1 Guest are viewing this topic.

pochrist

  • Guest
Need assistance with expand ing a routines capabilities
« Reply #15 on: June 15, 2005, 03:05:48 PM »
Quote
Are you sure? It works for me.


I think I see the problem...

I loaded a bland profile in Acad (ADT 2005) inserted a Standard Table put some text in the a field. Added some mtext and it does copy the text in or out of the table.

So does Marks.

So now I have to find out what is causing it. Thanks I'll report back When I figure it out.

pochrist

  • Guest
Ok It gets more interesting.....
« Reply #16 on: June 16, 2005, 11:58:28 AM »
1st I'm doing this all from a New Drawing in a Generic Profile - Then I try to use them in my Normal dwgs.

1) Both Marks & Cranks do the same things in the following areas.  :arrow:

Yes the Text does copy from outside into a Table, But ONLY if the Font style in the table is set to "Standard".  :?:

Here's where it gets interesting, If I Match / Replace text from a Mtext, Dtext, etc. source to a field in The table the text will only remain until I go to edit the field or the Table - then all the text that was changed gets undone back to what it was before.  :shock:  

Example (If I put a "X" in all the blank fields, I I Match / Replace to various text stings, if I try to edit ANY part of the table - ALL fields revert back to "X") Its Almost a Tease  :wink:  

At one point I Matched / Replaced text from 12 Mtext entities to 12 fields, I then tried edit the Table by right click - The whole table was selected but I couldn't get the Right click menu to come up. I Then went to the format menu and Modified the Font Style in the Table to my desired font style (Arial) and all the chnages were gone.  :cry:

It Seems like some where its not saving the change to the Field but its kind of Temporary.

Thanks for all the Help, I hope this only a minor fix. TIA

ronjonp

  • Needs a day job
  • Posts: 7531
Need assistance with expand ing a routines capabilities
« Reply #17 on: June 16, 2005, 12:16:01 PM »
Quote
Here's where it gets interesting, If I Match / Replace text from a Mtext, Dtext, etc. source to a field in The table the text will only remain until I go to edit the field or the Table - then all the text that was changed gets undone back to what it was before.


I experienced this as well....

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

pochrist

  • Guest
So this means the routine can't be fixed?
« Reply #18 on: June 21, 2005, 02:57:51 PM »
I'd love to be able fix this routine myself or even Cranks for that matter,

I stand a much better chance solveing the problem if I can understand why its Not working....

Remeber I did ask for help not a hand out, I do try to follow it's command progression :?, but unlike most of my other routines its rather complex and or maybe most of my routines have text break downs explaing what each function is doing...  

I really think its close to working, if the text would autually stay in the Table after I've accessed it would be nice... :wink:

Any help would be greatly appreciated.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Need assistance with expand ing a routines capabilities
« Reply #19 on: June 21, 2005, 03:33:36 PM »
Well I've spent about an hour trying to solve the problem. It seems you have to access the table via ActiceX in order to save changes. I haven't had any luck at this as of yet.
TheSwamp.org  (serving the CAD community since 2003)

Crank

  • Water Moccasin
  • Posts: 1503
Need assistance with expand ing a routines capabilities
« Reply #20 on: June 21, 2005, 05:12:21 PM »
The same error happens when you try to change a dimension: it seems fine until you stretch that dimension.
In both cases the problem is that somehow the displayed MTEXT is changed, but not the real dimension or table. For a dimension you can use NEWTEXT to modify the value.

When I tried to change the DXF-codes of the table, I found out that it's almost impossible to find the right cell data, so I wanted to try a different approach:
Because you know the position of the selected mtext you can also edit the cell on that location:
Code: [Select]

(setq p1 (cadr (nentsel))); Find position of text in table
(command ".tabledit" p1 "New_text"); place the new string

The problem with this is that I had no luck with removing the existing text. The new string is placed before the existing string, so the cell must be cleared first.
If you first can add CTRL+A or SHIFT+END in the keyboard buffer it should work, but I didn't have any luck with that.

Of course you can make some sort of 'work around':
  • First add a unique string before the cell text with tabledit.
  • Then you can seach in the dxfcodes for a string that contains this unique part and replace this text with the new text.
  • ENTUPD on the table
  • [/list:u]

    I know: this isn't pretty, but it should work.
    Perhaps someone else has a better idea.
Vault Professional 2023     +     AEC Collection

Crank

  • Water Moccasin
  • Posts: 1503
Need assistance with expand ing a routines capabilities
« Reply #21 on: June 21, 2005, 05:15:14 PM »
Code: [Select]

; ReplaceText.lsp by J.J.Damstra - Copyright ©2005.
; Replaces any selected string for another
; 21-06-05 first release
;   09-07-05   tableindicator

(defun c:rt (/ ch_txt ENTITY ENTITYLIST TXT_STR OBJECT pickpnt E-TYPE n ti)
  (defun ch_txt (TXT_STR ENTITY / ENTITYLIST OLD NEW ENT)
       (setq ENT (car ENTITY)
             ENTITYLIST (entget ENT)
             OLD (assoc 1 ENTITYLIST)
             NEW (cons  1 TXT_STR)
             ENTITYLIST (subst NEW OLD ENTITYLIST))
       (entmod ENTITYLIST)
       (entupd ENT)
  )

  (command ".undo" "begin")
  (setq ti (getvar "TABLEINDICATOR"))(setvar "TABLEINDICATOR" 0)
  (setq ENTITY (nentsel "\nSelect source text: ")
        ENTITYLIST (entget (car ENTITY))
        TXT_STR (cdr (assoc 1 ENTITYLIST)))

  (while (setq ENTITY (nentsel "\nSelect text to change: ")) ; NIL > WEND
        (if (> (length ENTITY) 3) ; insert/dimension/table
            (progn
                (setq OBJECT (car (last ENTITY))
                      ENTITYLIST (entget OBJECT)
                      pickpnt (cadr ENTITY)
                      E-TYPE (cdr (assoc 0 ENTITYLIST)))
                (cond
                    ((= E-TYPE "INSERT")
                        (ch_txt TXT_STR ENTITY)
                    )
                    ((wcmatch E-TYPE "*DIMENSION")
                        (command ".dim1" "newtext" TXT_STR OBJECT "")
                    )
                    ((= E-TYPE "ACAD_TABLE")
                        (command ".tabledit" pickpnt "@#@")
                        (setq ENTITYLIST (entget OBJECT))
                        (foreach n ENTITYLIST
                          (if (eq (car n) 1)
                            (if (eq (substr (cdr n) 1 3) "@#@")
                                (entmod (subst (cons 1 TXT_STR) n ENTITYLIST))
                            )
                          )
                        )
                    )
                )
                (entupd OBJECT)
            )
        ; else
            (ch_txt TXT_STR ENTITY) ; text/mtext/attribute
        )
  )

  (setvar "TABLEINDICATOR" ti)
  (command ".undo" "end")
  (princ)
)
Vault Professional 2023     +     AEC Collection

pochrist

  • Guest
Need assistance with expand ing a routines capabilities
« Reply #22 on: June 22, 2005, 04:16:23 PM »
Crank you Nailed it! :dood:

That's Exactly what I was looking for,  :D

As for copying text into an empty field 1st, No problem, that's easy, its what you did with the routine that's the hard thing.

Even does Dimensions, that's impressive I've wanted that ability for a while, but I never thought it a real "Need" so I lived without. Thanks alot this is some Nice code. It should be placed in the "Show your stuff section" IMHO

Crank

  • Water Moccasin
  • Posts: 1503
Need assistance with expand ing a routines capabilities
« Reply #23 on: June 22, 2005, 04:58:57 PM »
Made some minor changes to it.

Quote from: pochrist
[...]

As for copying text into an empty field 1st, No problem, that's easy[...]

You can also click on the border of an empty cell to place the new text in it.

Quote from: pochrist
[...]
Even does Dimensions, [...]

It also works on a nested attribute or (m)text in a block.
Vault Professional 2023     +     AEC Collection