Author Topic: how can I change all the "dimscale" by lisp?  (Read 3355 times)

0 Members and 1 Guest are viewing this topic.

litss

  • Guest
how can I change all the "dimscale" by lisp?
« on: March 09, 2008, 05:13:46 AM »
Is there any way to change the "dimscale" of all the "dimstyle"s in my drawing by lisp?

I've tried "(setvar "DIMSCALE" 100)", but seemed not working. I wanna change the textsize  by this way. Can somebody help me?




Crank

  • Water Moccasin
  • Posts: 1503
Re: how can I change all the "dimscale" by lisp?
« Reply #1 on: March 09, 2008, 06:36:58 AM »
When you change a dim variable an override of the dimstyle is active.

You wil have to save those changes to the dimstyle again:
Code: [Select]
(command "._dimstyle" "save" (getvar "DIMSTYLE") "YES")

If your dimstyle has 'children' (bla$0, bla$1, etc.) you'll have to save the changes to every child to see the changes everywhere.
Vault Professional 2023     +     AEC Collection

litss

  • Guest
Re: how can I change all the "dimscale" by lisp?
« Reply #2 on: March 11, 2008, 08:59:18 AM »
it works!

thx, Crank!

Could that be solved by "entmod"?

litss

  • Guest
Re: how can I change all the "dimscale" by lisp?
« Reply #3 on: March 11, 2008, 11:06:02 AM »
Here's my code, why it can't run? (acad2000&acad2007)


Code: [Select]
(SETQ DIMLST-0 (LIST "1:100" "1:50" "1:25"));LIST OF DIMSTYLE NAMES I USED
(SETQ I 0);SETQ
(REPEAT (LENGTH DIMLST-0)
  (SETQ TEST0 (TBLSEARCH "DIMSTYLE" (NTH I DIMLST-0)))
  (SETQ DIMNAME (NTH I DIMLST-0))
  (IF (/= TEST0 NIL);EXIST
    (PROGN
      (command "-dimstyle" "r" DIMNAME)
      (setvar "DIMSCALE" 100)
      (command "-dimstyle" "save" (getvar "DIMSTYLE") "YES")
    );PROGN
  );IF
  (SETQ I (1+ I))
)
;REPEAT

ronjonp

  • Needs a day job
  • Posts: 7529
Re: how can I change all the "dimscale" by lisp?
« Reply #4 on: March 11, 2008, 11:36:10 AM »
Just guessing here...but you might need an enter after "YES". Something like  (..."YES" "").


Here is a sample using foreach so you do not have to worry about the index of the item in the list:
Code: [Select]
(foreach ds '("1-100" "1-50" "1-25")
  (if (TBLSEARCH "DIMSTYLE" ds)
    (progn
      (command "-dimstyle" "r" ds)
      (setvar 'dimscale 100)
      (command "-dimstyle" "save" ds "YES" "")
    )
  )
)

*also the names you are using are invalid because of the colon.
« Last Edit: March 11, 2008, 11:40:14 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

litss

  • Guest
Re: how can I change all the "dimscale" by lisp?
« Reply #5 on: March 12, 2008, 10:26:34 AM »
thank u, ronjonp! good example for the "foreach" function

I'll try the code when I get the chance. thx again!

ronjonp

  • Needs a day job
  • Posts: 7529
Re: how can I change all the "dimscale" by lisp?
« Reply #6 on: March 12, 2008, 10:38:46 AM »
thank u, ronjonp! good example for the "foreach" function

I'll try the code when I get the chance. thx again!


Glad to help :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

litss

  • Guest
Re: how can I change all the "dimscale" by lisp?
« Reply #7 on: March 13, 2008, 10:51:07 AM »
I've tried ur code,  ronjonp.  Here's the result,

In the ACAD2007, the (command "-dimstyle" "save" ds "YES" "") could run, but the enter after  "YES"  is not needed, or it will return "nil". 

thx!