Author Topic: changing dimstyle scale factor  (Read 6712 times)

0 Members and 1 Guest are viewing this topic.

Coder

  • Swamp Rat
  • Posts: 827
changing dimstyle scale factor
« on: March 14, 2012, 03:52:43 AM »
hello

How can I change the dimstyle scale factor of a specific dimstyle ?

Code: [Select]
(setq a (entget (tblobjname "DIMSTYLE" "STANDARD")))

I couldn't find the DXF value 40 in the above extracts .

Thanks

HofCAD

  • Guest
Re: changing dimstyle scale factor
« Reply #1 on: March 14, 2012, 04:08:35 AM »
Try:
Code: [Select]
(setq a (tblsearch "DIMSTYLE" "STANDARD"))
Regards, HofCAD CSI.
« Last Edit: March 14, 2012, 04:11:57 AM by HofCAD »

Coder

  • Swamp Rat
  • Posts: 827
Re: changing dimstyle scale factor
« Reply #2 on: March 14, 2012, 04:28:20 AM »
Thank you .  :-)

How to change the scale factor of that dimstyle to 2.5 ?


irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: changing dimstyle scale factor
« Reply #3 on: March 14, 2012, 04:57:52 AM »
Either through setvar & DimStyle command-line. Or you need to go through the ActiveX settings instead of DXF.

Sorry, disregard the ActiveX thing.
« Last Edit: March 14, 2012, 05:13:00 AM by irneb »
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: changing dimstyle scale factor
« Reply #4 on: March 14, 2012, 06:39:14 AM »
DIMSCALE is DXF 40 (reference).

This group will not be present in the tblobjname entity data if the DimStyle DIMSCALE = 1
(similar to the behaviour of colour = ByLayer in graphical entities).

You can change the DIMSCALE for a specific DimStyle in the same way that you would alter any other Table Object, (such as a Layer), by using entmod with the tblobjname entity.

The following example will change the DIMSCALE of the Standard DimStyle to 1:

Code - Auto/Visual Lisp: [Select]
  1. (if (setq e (tblobjname "DIMSTYLE" "Standard"))
  2.     (if (setq s (assoc 40 (setq e (entget e))))
  3.         (entmod (subst '(40 . 1.0) s e))
  4.         (entmod (append e '((40 . 1.0))))
  5.     )
  6. )

If the DimStyle is the active DimStyle, you will also need to change the DIMSCALE System Variable to the same value, otherwise this will act as an override to the DimStyle settings.

HofCAD

  • Guest
Re: changing dimstyle scale factor
« Reply #5 on: March 14, 2012, 10:11:59 AM »
Dear Lee,

I get with your code:
Code: [Select]
(setq e (tblobjname "DIMSTYLE" "Standard"))returns
<Entity name: 7ee81240>
Code: [Select]
(setq e (entget e))returns
((-1 . <Entity name: 7ee81240>) (0 . "DIMSTYLE") (105 . "1B0") (330 . <Entity
name: 7ee7fc50>) (100 . "AcDbSymbolTableRecord") (100 .
"AcDbDimStyleTableRecord") (2 . "Standard") (70 . 0) (340 . <Entity name:
7ee7fc88>))
Code: [Select]
(setq s (assoc 40 (setq e (entget e)))) returns
Error: bad argument type: lentityp ((-1 . <Entity name: 7ee81240>) (0 .
"DIMSTYLE") (105 . "1B0") (330 . <Entity name: 7ee7fc50>) (100 .
"AcDbSymbolTableRecord") (100 . "AcDbDimStyleTableRecord") (2 . "Standard") (70
. 0) (340 . <Entity name: 7ee7fc88>))

Regards, HofCAD CSI.
« Last Edit: March 14, 2012, 10:44:07 AM by HofCAD »

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: changing dimstyle scale factor
« Reply #6 on: March 14, 2012, 10:27:49 AM »
Dear Lee,...
Just check your codes. You've introduced another entget. You only need one. The second one is expecting an ename, but you're sending it the DXF list obtained from the previous entget.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

HofCAD

  • Guest
Re: changing dimstyle scale factor
« Reply #7 on: March 14, 2012, 10:41:54 AM »
Dear Irneb,

I was checking the code from Lee.

Regards, HofCAD CSI.

Dear Lee,

Something like this:
Code: [Select]
(defun c:CDS (/ doc NewDimScale)
  (setq NewDimScale 2.5)
  (vl-load-com)
  (vlax-for dim (vla-get-Dimstyles
  (setq doc
(vla-get-ActiveDocument
   (vlax-get-acad-object)
)
  )
)
    (if (= (vla-get-name dim) "Standard")
      (progn
(vla-put-activeDimstyle doc dim)
(setvar "DIMSCALE" NewDimScale)
(vla-copyfrom dim doc)
      )
    )
  )
  (princ)
)

Regards, HofCAD CSI.
« Last Edit: March 14, 2012, 10:49:35 AM by HofCAD »

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: changing dimstyle scale factor
« Reply #8 on: March 14, 2012, 11:32:33 AM »
HofCAD,

As Irneb states:

You've introduced another entget. You only need one. The second one is expecting an ename, but you're sending it the DXF list obtained from the previous entget.

You've already set the variable 'e' to the DXF data list:

Code: [Select]
(setq e (entget e))returns
((-1 . <Entity name: 7ee81240>) (0 . "DIMSTYLE") (105 . "1B0") (330 . <Entity
name: 7ee7fc50>) (100 . "AcDbSymbolTableRecord") (100 .
"AcDbDimStyleTableRecord") (2 . "Standard") (70 . 0) (340 . <Entity name:
7ee7fc88>))

You then try to use 'entget' again on this DXF Data list, when 'entget' requires an ename argument:

Code: [Select]
(setq s (assoc 40 (setq e (entget e)))) returns
Error: bad argument type: lentityp ((-1 . <Entity name: 7ee81240>) (0 .
"DIMSTYLE") (105 . "1B0") (330 . <Entity name: 7ee7fc50>) (100 .
"AcDbSymbolTableRecord") (100 . "AcDbDimStyleTableRecord") (2 . "Standard") (70
. 0) (340 . <Entity name: 7ee7fc88>))

Notice that my code only calls 'entget' once.


Something like this:
Code: [Select]
(defun c:CDS (/ doc NewDimScale)
  (setq NewDimScale 2.5)
  (vl-load-com)
  (vlax-for dim (vla-get-Dimstyles
  (setq doc
(vla-get-ActiveDocument
   (vlax-get-acad-object)
)
  )
)
    (if (= (vla-get-name dim) "Standard")
      (progn
(vla-put-activeDimstyle doc dim)
(setvar "DIMSCALE" NewDimScale)
(vla-copyfrom dim doc)
      )
    )
  )
  (princ)
)

But what if there are other DimStyle Overrides active? i.e. other System Variables that do not match the settings in the current DimStyle.

When you set the 'Standard' DimStyle as active, these overrides will be wiped clean and will be replaced by the DimStyle settings for the 'Standard' Style.

Stefan

  • Bull Frog
  • Posts: 319
  • The most I miss IRL is the Undo button
Re: changing dimstyle scale factor
« Reply #9 on: March 14, 2012, 11:41:51 AM »
The code given by Lee is working, but it creates a Style Override.
This will save DimScale for an existent Dimstyle, but will delete any existent override:
Code: [Select]
(if
  (and
    (setq sc (getreal "\nNew Dimscale: "))
    (> sc 0.)
    (setq ds (getstring "\nDimStyle: "))
    (tblsearch "DIMSTYLE" ds)
    )
  (progn
    (command "_dimstyle" "r" ds)
    (setvar 'dimscale sc)
    (command "_dimstyle" "s" ds "y")
    )
  )

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: changing dimstyle scale factor
« Reply #10 on: March 14, 2012, 11:46:23 AM »
The code given by Lee is working, but it creates a Style Override.

I think there is some confusion.

My code is modifying the DimStyle itself, not creating an Override. Any override is created by the current settings of the System Variables, as noted in my previous post:

If the DimStyle is the active DimStyle, you will also need to change the DIMSCALE System Variable to the same value, otherwise this will act as an override to the DimStyle settings.

Your method is essentially the same as HofCAD :-)

Stefan

  • Bull Frog
  • Posts: 319
  • The most I miss IRL is the Undo button
Re: changing dimstyle scale factor
« Reply #11 on: March 14, 2012, 11:55:00 AM »
I did try your code and I get an OverRide DimStyle.

How can I change the dimstyle scale factor of a specific dimstyle ?
My code does change dimscale for a specific dimstyle. If this is not what OP intended, oh, well... my mistake.

EDIT: Lee, my mistake... again. After a reevaluation, I discovered that your code is saving the Dimstyle with the new Dimscale. But it does create an style override for the old Dimstyle settings.
« Last Edit: March 14, 2012, 12:06:38 PM by Stefan »

Coder

  • Swamp Rat
  • Posts: 827
Re: changing dimstyle scale factor
« Reply #12 on: March 14, 2012, 12:40:50 PM »
hello .

Stefan 's code worked very good but Lee 's code didn't work at all , and it overrides the dim style .

I wanted to have a programming solution and not by command  :oops:

many thanks for all

fixo

  • Guest
Re: changing dimstyle scale factor
« Reply #13 on: March 14, 2012, 12:50:43 PM »
hello .

Stefan 's code worked very good but Lee 's code didn't work at all , and it overrides the dim style .

Accepted on 2009

~'J'~

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: changing dimstyle scale factor
« Reply #14 on: March 14, 2012, 02:51:04 PM »
But it does create an style override for the old Dimstyle settings.

but Lee 's code didn't work at all , and it overrides the dim style .

Please re-read:  :roll:

If the DimStyle is the active DimStyle, you will also need to change the DIMSCALE System Variable to the same value, otherwise this will act as an override to the DimStyle settings.

If the DimStyle that you are altering is the active DimStyle then you will need to change the DIMSCALE System Variable to match the modified DimStyle DIMSCALE, otherwise this System Variable will act as an override.

I did not include this in my code since it is not required if the modified DimStyle is not active.

Stefan

  • Bull Frog
  • Posts: 319
  • The most I miss IRL is the Undo button
Re: changing dimstyle scale factor
« Reply #15 on: March 14, 2012, 05:12:27 PM »

Please re-read:  :roll:

If the DimStyle is the active DimStyle, you will also need to change the DIMSCALE System Variable to the same value, otherwise this will act as an override to the DimStyle settings.
You are right about that.
Sorry, happens all the time...   :-D