Jump to content

Recommended Posts

Posted

Hallo

 

I am a new user on Autocad and this fortum.

Have run Microstation before and this is very new for me.

I got a problem.

I have more then >100 dwg files there i need too increase postions z value of text and even change text too the new value of z

Text are on 3 diffrents levels/layers.

 

Example of old text and z value

Text contents = "Z90.00" or "Z 90.00"

Text alignment = 90.0000

Text position z = 90.0000

Result will be ( increase .28)

Text contents = "Z90.28" or "Z 90.28"

Text alignment = 90.28

Text position z = 90.28

 

Is it possible too do on a easy way?

 

/Beginner

  • Replies 28
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    15

  • automicro

    12

  • eldon

    2

Posted

Firstly, welcome to the forums, hope you like it here and find what you need :)

 

Yes, I think this could be accomplished using LISP - I do have a few minor questions however:

 

  • Is it a 0.28 increase for all text on the three layers?
  • Could you provide the exact names of the layers on which the text resides?

Posted
Firstly, welcome to the forums, hope you like it here and find what you need :)

 

Yes, I think this could be accomplished using LISP - I do have a few minor questions however:

  • Is it a 0.28 increase for all text on the three layers?
  • Could you provide the exact names of the layers on which the text resides?

 

Thanks Lee Mac.

 

Yes all text on this three layers (LEVEL, LEVEL-KYL, LEVEL-S)

 

Discovered that I must use the value in the text and this value is to be increase by 0.28.

That text be changed to the new value after that are calculated.

And the text position z value will be the same as text.

 

 

/automicro

Posted

Try this:

 

[b][color=BLACK]([/color][/b]defun c:txtupd [b][color=FUCHSIA]([/color][/b]/ ss eLst tpt ntpt zval lst[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]if [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget [color=#2f4f4f]"X"[/color] [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]cons 0 [color=#2f4f4f]"*TEXT"[/color][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]cons 8 [color=#2f4f4f]"LEVEL,LEVEL-KYL,LEVEL-S"[/color][b][color=BLUE])[/color][/b]
    [b][color=BLUE]([/color][/b]if [b][color=RED]([/color][/b]getvar [color=#2f4f4f]"CTAB"[/color][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]cons 410 [b][color=PURPLE]([/color][/b]getvar [color=#2f4f4f]"CTAB"[/color][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]cons 67 [b][color=PURPLE]([/color][/b]- 1 [b][color=TEAL]([/color][/b]getvar [color=#2f4f4f]"TILEMODE"[/color][b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
   [b][color=NAVY]([/color][/b]progn
     [b][color=MAROON]([/color][/b]setq eLst [b][color=GREEN]([/color][/b]mapcar 'entget [b][color=BLUE]([/color][/b]mapcar 'cadr [b][color=RED]([/color][/b]ssnamex ss[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
     [b][color=MAROON]([/color][/b]foreach ent eLst
   [b][color=GREEN]([/color][/b]setq tpt  [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]assoc 10 ent[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b]
         ntpt [b][color=BLUE]([/color][/b]+ [b][color=RED]([/color][/b]last tpt[b][color=RED])[/color][/b] 0.28[b][color=BLUE])[/color][/b]
         zval [b][color=BLUE]([/color][/b]subst ntpt [b][color=RED]([/color][/b]last tpt[b][color=RED])[/color][/b] tpt[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
   [b][color=GREEN]([/color][/b]mapcar '[b][color=BLUE]([/color][/b]lambda [b][color=RED]([/color][/b]new old[b][color=RED])[/color][/b] [b][color=RED]([/color][/b]setq lst [b][color=PURPLE]([/color][/b]subst new old ent[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b]
         [b][color=BLUE]([/color][/b]list [b][color=RED]([/color][/b]cons 10 zval[b][color=RED])[/color][/b] [b][color=RED]([/color][/b]cons 1 [b][color=PURPLE]([/color][/b]strcat [color=#2f4f4f]"Z"[/color] [b][color=TEAL]([/color][/b]rtos ntpt[b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b]
         [b][color=BLUE]([/color][/b]list [b][color=RED]([/color][/b]assoc 10 ent[b][color=RED])[/color][/b] [b][color=RED]([/color][/b]assoc 1 ent[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
   [b][color=GREEN]([/color][/b]entmod lst[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
   [b][color=NAVY]([/color][/b]princ [color=#2f4f4f]"\n<!> No Text Found <!>"[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]princ[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]
   

Posted

You are my hero Lee Mac, its works very fine.

But when i show my boss, he say

 

Rule 1: All texts will increase the z-text with 0.28.

Rule 2: If text Z position> 0, z positions increase by 0.28

 

Is it possible to change the scrip to do so?

 

/automicro

Posted

If you can select only text, then you could use the MOVE command @0,0,0.28

This would move all text by 0.28 in the z coordinate.

Posted
If you can select only text, then you could use the MOVE command @0,0,0.28

This would move all text by 0.28 in the z coordinate.

 

True Eldon, but then I suppose he would still have to update the content of all the text to include the z-coord. :P

 

*LISPing is much more fun*

 

Thanks for the suggestion though :)

Posted
You are my hero Lee Mac, its works very fine.

But when i show my boss, he say

 

Rule 1: All texts will increase the z-text with 0.28.

Rule 2: If text Z position> 0, z positions increase by 0.28

 

Is it possible to change the scrip to do so?

 

/automicro

 

I'm sorry, I'm not sure that I completely understand you,

 

Are you saying that only text with z-coord greater than zero needs to be moved and have its content updated?

 

It seems "rule 1" and "rule 2" contradict each other - could you please clarify for me :P

Posted

I would have had to use a two stage process using the lisp TEXTMATH to alter the text of the levels, and then used MOVE to physically move everything in the z direction.

 

All the tools are in existence, and you are just providing a Rolls-Royce service. Keep up the good work :D

Posted
I'm sorry, I'm not sure that I completely understand you,

 

Are you saying that only text with z-coord greater than zero needs to be moved and have its content updated?

 

It seems "rule 1" and "rule 2" contradict each other - could you please clarify for me :P

 

Sorry about my bad english or bad declaration

1:

All text on layer Level, level-kyl, level-s

Needs too increase text value widht 0.28

Example "Z 90.00" will be "z 90.28"

2:

Next step is too increase z coordinate (+0.28) on all text coordinates

there the Z coordinate are greater then 0

3:

Text coordinates widht Z value 0 shall not change.

 

I hop you understand now.

 

/automicro

Posted

Give this a shot :)

 

 

[b][color=BLACK]([/color][/b]defun c:txtupd [b][color=FUCHSIA]([/color][/b]/ ss eLst tpt tval npt lst[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]vl-load-com[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]if [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget [color=#2f4f4f]"X"[/color] [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]cons 0 [color=#2f4f4f]"*TEXT"[/color][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]cons 8 [color=#2f4f4f]"LEVEL,LEVEL-KYL,LEVEL-S"[/color][b][color=BLUE])[/color][/b]
    [b][color=BLUE]([/color][/b]if [b][color=RED]([/color][/b]getvar [color=#2f4f4f]"CTAB"[/color][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]cons 410 [b][color=PURPLE]([/color][/b]getvar [color=#2f4f4f]"CTAB"[/color][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]cons 67 [b][color=PURPLE]([/color][/b]- 1 [b][color=TEAL]([/color][/b]getvar [color=#2f4f4f]"TILEMODE"[/color][b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
   [b][color=NAVY]([/color][/b]progn
     [b][color=MAROON]([/color][/b]setq eLst [b][color=GREEN]([/color][/b]mapcar 'entget [b][color=BLUE]([/color][/b]mapcar 'cadr [b][color=RED]([/color][/b]ssnamex ss[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
     [b][color=MAROON]([/color][/b]foreach ent eLst
   [b][color=GREEN]([/color][/b]setq tpt [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]assoc 10 ent[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] tval [b][color=BLUE]([/color][/b]rtos [b][color=RED]([/color][/b]+ [b][color=PURPLE]([/color][/b]last tpt[b][color=PURPLE])[/color][/b] 0.28[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
   [b][color=GREEN]([/color][/b]if [b][color=BLUE]([/color][/b]> [b][color=RED]([/color][/b]last tpt[b][color=RED])[/color][/b] 0[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]setq npt [b][color=RED]([/color][/b]subst [b][color=PURPLE]([/color][/b]+ [b][color=TEAL]([/color][/b]last tpt[b][color=TEAL])[/color][/b] 0.28[b][color=PURPLE])[/color][/b] [b][color=PURPLE]([/color][/b]last tpt[b][color=PURPLE])[/color][/b] tpt[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]setq npt tpt[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
   [b][color=GREEN]([/color][/b]mapcar '[b][color=BLUE]([/color][/b]lambda [b][color=RED]([/color][/b]new old[b][color=RED])[/color][/b] [b][color=RED]([/color][/b]setq lst [b][color=PURPLE]([/color][/b]subst new old ent[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b]
       [b][color=BLUE]([/color][/b]list [b][color=RED]([/color][/b]cons 10 npt[b][color=RED])[/color][/b] [b][color=RED]([/color][/b]cons 1 [b][color=PURPLE]([/color][/b]strcat [color=#2f4f4f]"Z"[/color] tval[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b]
       [b][color=BLUE]([/color][/b]list [b][color=RED]([/color][/b]assoc 10 ent[b][color=RED])[/color][/b] [b][color=RED]([/color][/b]assoc 1 ent[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
   [b][color=GREEN]([/color][/b]entmod lst[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
   [b][color=NAVY]([/color][/b]princ [color=#2f4f4f]"\n<!> No Text Found <!>"[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]princ[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

Posted
Give this a shot :)

 

 

Not that i mean, perhaps this explain better

 

FOR ELEMENT=0 TO ALL.ELEMENT ::rem ALL ELEMENT IN FILE

IF Layer = "LEVEL" or Layer = "LEVEL-KYL" or Layer = "LEVEL-S" THEN

IF Txt.txt = "Z xx.xx" or Txt.txt = "Zxx.xx" THEN

Txt.txt = Txt.txt + ".28"

::rem example Txt.txt = "Z 90.00" ==> Txt.txt = "Z 90.28"

::rem example Txt.txt = "Z90.00" ==> Txt.txt = "Z90.28"

IF Txt.Z.COORD > 0 THEN Txt.Z.COORD = TEXT.Z.COORD + 0.28

::rem example ONLY when Txt.Z.COORD >0 else Txt.Z.COORD = 0

ENDIF

ENDIF

NEXT ELEMENT

 

Can some one show me, how i can read hole dwgfile in a

"FOR" loop in VB and check all elementyp and change element values?

Are very bad on lisp.

´

/automicro

Posted

Your lisp program don't increase text value

My text z88.52 ==> Z0.2800 with your program

but i expect Z88.80

 

Your program does not increase the value of the Z-text without replacing it to 0.28

 

/automicro

Posted
Hmm, that is weird, that doesn't happen when I run it (see attached.)

 

I think you pick the z value from the "z coordinate" of text and

not from the "text value"

Many texts are on z coordinate 0 but shall not change.

 

Thanks for all help Lee Mac

 

/automicro

Posted

Ok, try this - sorry for confusion earlier:

 

(defun c:txtupd (/ ss eLst tpt tval npt lst)
 (vl-load-com)
 (if (setq ss (ssget "X" (list (cons 0 "*TEXT") (cons 8 "0")
    (if (getvar "CTAB") (cons 410 (getvar "CTAB")) (cons 67 (- 1 (getvar "TILEMODE")))))))
   (progn
     (setq eLst (mapcar 'entget (mapcar 'cadr (ssnamex ss))))
     (foreach ent eLst
       (setq tpt (cdr (assoc 10 ent)))
   (if (eq (nth 1 (vl-string->list (cdr (assoc 1 ent)))) 32)
     (setq tval (rtos (+ (distof (substr (cdr (assoc 1 ent)) 3)) 0.28)))
     (setq tval (rtos (+ (distof (substr (cdr (assoc 1 ent)) 2)) 0.28))))
       (if (> (last tpt) 0) (setq npt (subst (+ (last tpt) 0.28) (last tpt) tpt)) (setq npt tpt))
       (mapcar '(lambda (new old) (setq lst (subst new old ent)))
                (list (cons 10 npt) (cons 1 (strcat "Z" tval)))
                (list (assoc 10 ent) (assoc 1 ent)))
       (entmod lst)))
   (princ "\n<!> No Text Found <!>"))
 (princ))

Posted

When i run this i get a error message.

 

Command: _appload txtupd-2009-03-10.lsp successfully loaded.

Command: txtupd

; error: bad argument type: numberp: nil

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...